Skip to content

Commit d4236f1

Browse files
author
Marc Zyngier
committed
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>
1 parent 9ace475 commit d4236f1

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

arch/arm64/include/asm/memory.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,24 @@
175175
#define MT_DEVICE_nGnRE 4
176176

177177
/*
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.
179181
*/
180182
#define MT_S2_NORMAL 0xf
181183
#define MT_S2_NORMAL_NC 0x5
182184
#define MT_S2_DEVICE_nGnRE 0x1
185+
#define MT_S2_AS_S1 MT_S2_NORMAL
183186

184187
/*
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.
187191
*/
188192
#define MT_S2_FWB_NORMAL 6
189193
#define MT_S2_FWB_NORMAL_NC 5
190194
#define MT_S2_FWB_DEVICE_nGnRE 1
195+
#define MT_S2_FWB_AS_S1 7
191196

192197
#ifdef CONFIG_ARM64_4K_PAGES
193198
#define IOREMAP_MAX_ORDER (PUD_SHIFT)

0 commit comments

Comments
 (0)