arm/arm64: Use 'max' cpu and gic types
v2 cover arm/arm64: Use 'max' cpu and gic types
The arm64 'max' CPU type enables all features, so it makes sense to use it for testing to ensure we're testing the latest models. The 'max' GIC is used to pick the latest GIC model by default which is better than defaulting to gicv2 since it tests a later model and, when more than 8 CPUs are configured, it'll actually work. We don't need to convert 'max' to 'host' with KVM/HVF since 'max' is an alias for 'host' when those accelerators are enabled.
v2:
- Forgot to test with efi on v1 and testing now found an issue. Add a patch to allow '-cpu max', which has LPA2, to work with efi.
Andrew Jones (3):
arm64: Prepare for LPA2
arm/arm64: Use 'max' gic type
arm64: Use 'max' cpu type
arm/run | 8 +------ configure | 2 +- lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------ 3 files changed, 29 insertions(+), 30 deletions(-)
Signature · 1 line
2.44.0
PATCH v2 1/3 arm64: Prepare for LPA2
When checking for supported granules also check for the values which indicate support when LPA2 is implemented.
--- lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-)
lib/arm64/asm/processor.h +27 -22
@@ -110,31 +110,36 @@ 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_SUPPORTED (r) \ +({ \ + u64 __v = ((r) >> ID_AA64MMFR0_TGRAN4_SHIFT) & 0xf; \ + (__v) == 0 || (__v) == 1; \ +}) + +#define ID_AA64MMFR0_TGRAN64_SUPPORTED (r) \ +({ \ + u64 __v = ((r) >> ID_AA64MMFR0_TGRAN64_SHIFT) & 0xf; \ + (__v) == 0; \ +}) + +#define ID_AA64MMFR0_TGRAN16_SUPPORTED (r) \ +({ \ + u64 __v = ((r) >> ID_AA64MMFR0_TGRAN16_SHIFT) & 0xf; \ + (__v) == 1 || (__v) == 2; \ +})static inline bool system_supports_granule (size_t granule) { -u32 shift; -u32 val; -u64 mmfr0; - -if (granule ==SZ_4K ) { - shift =ID_AA64MMFR0_TGRAN4_SHIFT ; - val =ID_AA64MMFR0_TGRAN4_SUPPORTED ; - }else if (granule ==SZ_16K ) { - shift =ID_AA64MMFR0_TGRAN16_SHIFT ; - val =ID_AA64MMFR0_TGRAN16_SUPPORTED ; - }else { -assert (granule ==SZ_64K ); - shift =ID_AA64MMFR0_TGRAN64_SHIFT ; - val =ID_AA64MMFR0_TGRAN64_SUPPORTED ; - } - - mmfr0 =get_id_aa64mmfr0_el1 (); - -return ((mmfr0 >> shift) &0xf ) == val; +u64 mmfr0 =get_id_aa64mmfr0_el1 (); + +if (granule ==SZ_4K ) +return ID_AA64MMFR0_TGRAN4_SUPPORTED (mmfr0); + +if (granule ==SZ_16K ) +return ID_AA64MMFR0_TGRAN16_SUPPORTED (mmfr0); + +assert (granule ==SZ_64K ); +return ID_AA64MMFR0_TGRAN64_SUPPORTED (mmfr0); }#endif /* !__ASSEMBLY__ */
Signature · 1 line
2.44.0
PATCH v2 2/3 arm/arm64: Use 'max' gic type
In reply to Andrew JonesThe 'max' GIC type has been supported for six years (Mar. 2018). Ever since its introduction we've considered switching to it for the default in the run scripts. Now, with commit 5dd20ec76ea6 ("runtime:
Update MAX_SMP probe"), we no longer always check and restrict MAX_SMP, so we'd have better luck with configurations working by default by finally doing the switch. Of course we also get the benefits of testing more modern models by default and requiring less command line modifications when converting TCG to KVM/HVF.
--- arm/run | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
arm/run +1 -7
@@ -29,13 +29,7 @@ if ! $qemu -machine '?' | grep -q 'ARM Virtual Machine'; then exit 2 fi -M='-machine virt' - -if [ "$ACCEL" = "kvm" ]; then - if $qemu $M,\? | grep -q gic-version; then - M+=',gic-version=host' - fi -fi +M='-machine virt,gic-version=max' if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then
Signature · 1 line
2.44.0
PATCH v2 3/3 arm64: Use 'max' cpu type
In reply to Andrew JonesThe 'max' GIC type has been supported for six years (Mar. 2018). Ever since its introduction we've considered switching to it for the default in the run scripts in order to test more modern models by default. Let's finally do it!
(HVF's support for '-cpu max' is younger (only 2 years), but that should also be old enough.)
--- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
@@ -273,7 +273,7 @@ fi [ -z "$processor" ] && processor="$arch" if [ "$processor" = "arm64" ]; then - processor="cortex-a57" + processor="max" elif [ "$processor" = "arm" ]; then processor="cortex-a15" fi
Signature · 1 line
2.44.0
Quoted 17 lines · Andrew Jones
The arm64 'max' CPU type enables all features, so it makes sense to use it for testing to ensure we're testing the latest models. The 'max' GIC is used to pick the latest GIC model by default which is better than defaulting to gicv2 since it tests a later model and, when more than 8 CPUs are configured, it'll actually work. We don't need to convert 'max' to 'host' with KVM/HVF since 'max' is an alias for 'host' when those accelerators are enabled.
v2:
- Forgot to test with efi on v1 and testing now found an issue. Add a patch to allow '-cpu max', which has LPA2, to work with efi.Andrew Jones (3):
arm64: Prepare for LPA2
arm/arm64: Use 'max' gic type
arm64: Use 'max' cpu type
Quoted 8 lines
arm/run | 8 +------ configure | 2 +- lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------ 3 files changed, 29 insertions(+), 30 deletions(-)Signature · 1 line
2.44.0
I see our gitlab CI is failing for a branch with these patches. That's because the QEMU used is pretty old on the CI and it doesn't have commit 312b71abce30 ("target/arm: Limit LPA2 effective output address when TCR.DS == 0"). I either need to force the CI to use 'cortex-a57', like it always did before (and would be similar to how I've forced riscv to use 'rv64'), or we should update the CI to use a later QEMU.
Thanks,
drew
Re: [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2
In reply to Andrew JonesQuoted 4 lines · Andrew Jones
When checking for supported granules also check for the values which indicate support when LPA2 is implemented.
Signed-off-by Andrew Jones <[email protected]>
Quoted 67 lines
--- lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-)lib/arm64/asm/processor.h +27
-22@@ -110,31 +110,36 @@ 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_SUPPORTED (r) \ +({ \ + u64 __v = ((r) >> ID_AA64MMFR0_TGRAN4_SHIFT) & 0xf; \ + (__v) == 0 || (__v) == 1; \ +}) + +#define ID_AA64MMFR0_TGRAN64_SUPPORTED (r) \ +({ \ + u64 __v = ((r) >> ID_AA64MMFR0_TGRAN64_SHIFT) & 0xf; \ + (__v) == 0; \ +}) + +#define ID_AA64MMFR0_TGRAN16_SUPPORTED (r) \ +({ \ + u64 __v = ((r) >> ID_AA64MMFR0_TGRAN16_SHIFT) & 0xf; \ + (__v) == 1 || (__v) == 2; \ +})static inline bool system_supports_granule (size_t granule) { -u32 shift; -u32 val; -u64 mmfr0; - -if (granule ==SZ_4K ) { - shift =ID_AA64MMFR0_TGRAN4_SHIFT ; - val =ID_AA64MMFR0_TGRAN4_SUPPORTED ; - }else if (granule ==SZ_16K ) { - shift =ID_AA64MMFR0_TGRAN16_SHIFT ; - val =ID_AA64MMFR0_TGRAN16_SUPPORTED ; - }else { -assert (granule ==SZ_64K ); - shift =ID_AA64MMFR0_TGRAN64_SHIFT ; - val =ID_AA64MMFR0_TGRAN64_SUPPORTED ; - } - - mmfr0 =get_id_aa64mmfr0_el1 (); - -return ((mmfr0 >> shift) &0xf ) == val; +u64 mmfr0 =get_id_aa64mmfr0_el1 (); + +if (granule ==SZ_4K ) +return ID_AA64MMFR0_TGRAN4_SUPPORTED (mmfr0); + +if (granule ==SZ_16K ) +return ID_AA64MMFR0_TGRAN16_SUPPORTED (mmfr0); + +assert (granule ==SZ_64K ); +return ID_AA64MMFR0_TGRAN64_SUPPORTED (mmfr0); }#endif /* !__ASSEMBLY__ */
Re: [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2
In reply to Andrew JonesHi Drew,
Quoted 4 lines · Andrew Jones
When checking for supported granules also check for the values which indicate support when LPA2 is implemented.
Signed-off-by Andrew Jones <[email protected]>
Eric
Quoted 67 lines
--- lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-)lib/arm64/asm/processor.h +27
-22@@ -110,31 +110,36 @@ 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_SUPPORTED (r) \ +({ \ + u64 __v = ((r) >> ID_AA64MMFR0_TGRAN4_SHIFT) & 0xf; \ + (__v) == 0 || (__v) == 1; \ +}) + +#define ID_AA64MMFR0_TGRAN64_SUPPORTED (r) \ +({ \ + u64 __v = ((r) >> ID_AA64MMFR0_TGRAN64_SHIFT) & 0xf; \ + (__v) == 0; \ +}) + +#define ID_AA64MMFR0_TGRAN16_SUPPORTED (r) \ +({ \ + u64 __v = ((r) >> ID_AA64MMFR0_TGRAN16_SHIFT) & 0xf; \ + (__v) == 1 || (__v) == 2; \ +})static inline bool system_supports_granule (size_t granule) { -u32 shift; -u32 val; -u64 mmfr0; - -if (granule ==SZ_4K ) { - shift =ID_AA64MMFR0_TGRAN4_SHIFT ; - val =ID_AA64MMFR0_TGRAN4_SUPPORTED ; - }else if (granule ==SZ_16K ) { - shift =ID_AA64MMFR0_TGRAN16_SHIFT ; - val =ID_AA64MMFR0_TGRAN16_SUPPORTED ; - }else { -assert (granule ==SZ_64K ); - shift =ID_AA64MMFR0_TGRAN64_SHIFT ; - val =ID_AA64MMFR0_TGRAN64_SUPPORTED ; - } - - mmfr0 =get_id_aa64mmfr0_el1 (); - -return ((mmfr0 >> shift) &0xf ) == val; +u64 mmfr0 =get_id_aa64mmfr0_el1 (); + +if (granule ==SZ_4K ) +return ID_AA64MMFR0_TGRAN4_SUPPORTED (mmfr0); + +if (granule ==SZ_16K ) +return ID_AA64MMFR0_TGRAN16_SUPPORTED (mmfr0); + +assert (granule ==SZ_64K ); +return ID_AA64MMFR0_TGRAN64_SUPPORTED (mmfr0); }#endif /* !__ASSEMBLY__ */
Re: [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2
In reply to Andrew JonesQuoted 7 lines · Andrew Jones
When checking for supported granules also check for the values which indicate support when LPA2 is implemented.
Signed-off-by Andrew Jones <[email protected]>--- lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-)
Queued
https://gitlab.com/jones-drew/kvm-unit-tests/-/commits/arm/queue?ref_type=heads