Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm64: Add MT_S2{,_FWB}_AS_S1 encodings

pKVM usage of S2 translation on the host is purely for isolation
purposes, not translation. To that effect, the memory attributes
being used must be that of S1.

With FWB=0, this is easily achieved by using the Normal Cacheable
type (which is the weakest possible memory type) at S2, and let S1
pick something stronger as required.

With FWB=1, the attributes are combined in a different way, and we
cannot arbitrarily use Normal Cacheable. We can, however, use a
memattr encoding that indicates that the final attributes are that
of Stage-1.

Add these encoding and a few pointers to the relevant parts of the
specification. It might come handy some day.

Reviewed-by: Joey Gouly <joey.gouly@arm.com>
Reviewed-by: Fuad Tabba <tabba@google.com>
Tested-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260123191637.715429-2-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>

+8 -3
+8 -3
arch/arm64/include/asm/memory.h
··· 175 175 #define MT_DEVICE_nGnRE 4 176 176 177 177 /* 178 - * Memory types for Stage-2 translation 178 + * Memory types for Stage-2 translation when HCR_EL2.FWB=0. See R_HMNDG, 179 + * R_TNHFM, R_GQFSF and I_MCQKW for the details on how these attributes get 180 + * combined with Stage-1. 179 181 */ 180 182 #define MT_S2_NORMAL 0xf 181 183 #define MT_S2_NORMAL_NC 0x5 182 184 #define MT_S2_DEVICE_nGnRE 0x1 185 + #define MT_S2_AS_S1 MT_S2_NORMAL 183 186 184 187 /* 185 - * Memory types for Stage-2 translation when ID_AA64MMFR2_EL1.FWB is 0001 186 - * Stage-2 enforces Normal-WB and Device-nGnRE 188 + * Memory types for Stage-2 translation when HCR_EL2.FWB=1. Stage-2 enforces 189 + * Normal-WB and Device-nGnRE, unless we actively say that S1 wins. See 190 + * R_VRJSW and R_RHWZM for details. 187 191 */ 188 192 #define MT_S2_FWB_NORMAL 6 189 193 #define MT_S2_FWB_NORMAL_NC 5 190 194 #define MT_S2_FWB_DEVICE_nGnRE 1 195 + #define MT_S2_FWB_AS_S1 7 191 196 192 197 #ifdef CONFIG_ARM64_4K_PAGES 193 198 #define IOREMAP_MAX_ORDER (PUD_SHIFT)