[kvm-unit-tests PATCH v1 2/2] arm/mmu: widen the page size check to account for LPA2
Alex Bennée
alex.bennee at linaro.org
Tue Jul 2 09:35:15 PDT 2024
If FEAT_LPA2 is enabled there are different valid TGran values
possible to indicate the granule is supported for 52 bit addressing.
This will cause most tests to abort on QEMU's -cpu max with the error:
lib/arm/mmu.c:216: assert failed: system_supports_granule(PAGE_SIZE): Unsupported translation granule 4096
Expand the test to tale this into account.
Signed-off-by: Alex Bennée <alex.bennee at linaro.org>
Cc: Anders Roxell <anders.roxell at linaro.org>
---
lib/arm64/asm/processor.h | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h
index 1c73ba32..4a213aec 100644
--- a/lib/arm64/asm/processor.h
+++ b/lib/arm64/asm/processor.h
@@ -110,31 +110,30 @@ static inline unsigned long get_id_aa64mmfr0_el1(void)
#define ID_AA64MMFR0_TGRAN64_SHIFT 24
#define ID_AA64MMFR0_TGRAN16_SHIFT 20
-#define ID_AA64MMFR0_TGRAN4_SUPPORTED 0x0
-#define ID_AA64MMFR0_TGRAN64_SUPPORTED 0x0
-#define ID_AA64MMFR0_TGRAN16_SUPPORTED 0x1
+#define ID_AA64MMFR0_TGRAN4_OK 0x0
+#define ID_AA64MMFR0_TGRAN4_52_OK 0x1
+#define ID_AA64MMFR0_TGRAN64_OK 0x0
+#define ID_AA64MMFR0_TGRAN16_OK 0x1
+#define ID_AA64MMFR0_TGRAN16_52_OK 0x2
static inline bool system_supports_granule(size_t granule)
{
- u32 shift;
u32 val;
- u64 mmfr0;
+ u64 mmfr0 = get_id_aa64mmfr0_el1();
if (granule == SZ_4K) {
- shift = ID_AA64MMFR0_TGRAN4_SHIFT;
- val = ID_AA64MMFR0_TGRAN4_SUPPORTED;
+ val = ((mmfr0 >> ID_AA64MMFR0_TGRAN4_SHIFT) & 0xf);
+ return (val == ID_AA64MMFR0_TGRAN4_OK) ||
+ (val == ID_AA64MMFR0_TGRAN4_52_OK);
} else if (granule == SZ_16K) {
- shift = ID_AA64MMFR0_TGRAN16_SHIFT;
- val = ID_AA64MMFR0_TGRAN16_SUPPORTED;
+ val = ((mmfr0 >> ID_AA64MMFR0_TGRAN16_SHIFT) & 0xf);
+ return val == ID_AA64MMFR0_TGRAN16_OK;
} else {
assert(granule == SZ_64K);
- shift = ID_AA64MMFR0_TGRAN64_SHIFT;
- val = ID_AA64MMFR0_TGRAN64_SUPPORTED;
+ val = ((mmfr0 >> ID_AA64MMFR0_TGRAN64_SHIFT) & 0xf);
+ return (val == ID_AA64MMFR0_TGRAN64_OK) ||
+ (val == ID_AA64MMFR0_TGRAN4_52_OK);
}
-
- mmfr0 = get_id_aa64mmfr0_el1();
-
- return ((mmfr0 >> shift) & 0xf) == val;
}
#endif /* !__ASSEMBLY__ */
--
2.39.2
More information about the linux-arm-kernel
mailing list