* [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types
@ 2024-04-02 13:27 Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2 Andrew Jones
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Andrew Jones @ 2024-04-02 13:27 UTC (permalink / raw)
To: kvmarm; +Cc: alexandru.elisei, eric.auger, nikos.nikoleris, shahuang
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(-)
--
2.44.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2
2024-04-02 13:27 [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
@ 2024-04-02 13:27 ` Andrew Jones
2024-04-03 8:50 ` Nikos Nikoleris
` (2 more replies)
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 2/3] arm/arm64: Use 'max' gic type Andrew Jones
` (2 subsequent siblings)
3 siblings, 3 replies; 8+ messages in thread
From: Andrew Jones @ 2024-04-02 13:27 UTC (permalink / raw)
To: kvmarm; +Cc: alexandru.elisei, eric.auger, nikos.nikoleris, shahuang
When checking for supported granules also check for the values
which indicate support when LPA2 is implemented.
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h
index 1c73ba32725a..bab9c26c2c9e 100644
--- a/lib/arm64/asm/processor.h
+++ b/lib/arm64/asm/processor.h
@@ -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__ */
--
2.44.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [kvm-unit-tests PATCH v2 2/3] arm/arm64: Use 'max' gic type
2024-04-02 13:27 [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2 Andrew Jones
@ 2024-04-02 13:27 ` Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 3/3] arm64: Use 'max' cpu type Andrew Jones
2024-04-02 16:57 ` [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
3 siblings, 0 replies; 8+ messages in thread
From: Andrew Jones @ 2024-04-02 13:27 UTC (permalink / raw)
To: kvmarm; +Cc: alexandru.elisei, eric.auger, nikos.nikoleris, shahuang
The '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.
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
arm/run | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/arm/run b/arm/run
index efdd44ce86a7..120e406fc703 100755
--- a/arm/run
+++ b/arm/run
@@ -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
--
2.44.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [kvm-unit-tests PATCH v2 3/3] arm64: Use 'max' cpu type
2024-04-02 13:27 [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2 Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 2/3] arm/arm64: Use 'max' gic type Andrew Jones
@ 2024-04-02 13:27 ` Andrew Jones
2024-04-02 16:57 ` [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
3 siblings, 0 replies; 8+ messages in thread
From: Andrew Jones @ 2024-04-02 13:27 UTC (permalink / raw)
To: kvmarm; +Cc: alexandru.elisei, eric.auger, nikos.nikoleris, shahuang
The '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.)
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure b/configure
index 49f047cb2d7d..078271822b10 100755
--- a/configure
+++ b/configure
@@ -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
--
2.44.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types
2024-04-02 13:27 [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
` (2 preceding siblings ...)
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 3/3] arm64: Use 'max' cpu type Andrew Jones
@ 2024-04-02 16:57 ` Andrew Jones
3 siblings, 0 replies; 8+ messages in thread
From: Andrew Jones @ 2024-04-02 16:57 UTC (permalink / raw)
To: kvmarm; +Cc: alexandru.elisei, eric.auger, nikos.nikoleris, shahuang
On Tue, Apr 02, 2024 at 03:27:40PM +0200, Andrew Jones wrote:
> 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(-)
>
> --
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2 Andrew Jones
@ 2024-04-03 8:50 ` Nikos Nikoleris
2024-04-09 11:54 ` Eric Auger
2024-05-10 15:06 ` Andrew Jones
2 siblings, 0 replies; 8+ messages in thread
From: Nikos Nikoleris @ 2024-04-03 8:50 UTC (permalink / raw)
To: Andrew Jones, kvmarm; +Cc: alexandru.elisei, eric.auger, shahuang
On 02/04/2024 14:27, Andrew Jones wrote:
> When checking for supported granules also check for the values
> which indicate support when LPA2 is implemented.
>
> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
> ---
> lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------
> 1 file changed, 27 insertions(+), 22 deletions(-)
>
> diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h
> index 1c73ba32725a..bab9c26c2c9e 100644
> --- a/lib/arm64/asm/processor.h
> +++ b/lib/arm64/asm/processor.h
> @@ -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__ */
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2 Andrew Jones
2024-04-03 8:50 ` Nikos Nikoleris
@ 2024-04-09 11:54 ` Eric Auger
2024-05-10 15:06 ` Andrew Jones
2 siblings, 0 replies; 8+ messages in thread
From: Eric Auger @ 2024-04-09 11:54 UTC (permalink / raw)
To: Andrew Jones, kvmarm; +Cc: alexandru.elisei, nikos.nikoleris, shahuang
Hi Drew,
On 4/2/24 15:27, Andrew Jones wrote:
> When checking for supported granules also check for the values
> which indicate support when LPA2 is implemented.
>
> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------
> 1 file changed, 27 insertions(+), 22 deletions(-)
>
> diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h
> index 1c73ba32725a..bab9c26c2c9e 100644
> --- a/lib/arm64/asm/processor.h
> +++ b/lib/arm64/asm/processor.h
> @@ -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__ */
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2 Andrew Jones
2024-04-03 8:50 ` Nikos Nikoleris
2024-04-09 11:54 ` Eric Auger
@ 2024-05-10 15:06 ` Andrew Jones
2 siblings, 0 replies; 8+ messages in thread
From: Andrew Jones @ 2024-05-10 15:06 UTC (permalink / raw)
To: Andrew Jones
Cc: kvmarm, alexandru.elisei, eric.auger, nikos.nikoleris, shahuang
On Tue, Apr 02, 2024 at 03:27:41PM GMT, Andrew Jones wrote:
> When checking for supported granules also check for the values
> which indicate support when LPA2 is implemented.
>
> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
> ---
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-05-10 15:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-02 13:27 [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2 Andrew Jones
2024-04-03 8:50 ` Nikos Nikoleris
2024-04-09 11:54 ` Eric Auger
2024-05-10 15:06 ` Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 2/3] arm/arm64: Use 'max' gic type Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 3/3] arm64: Use 'max' cpu type Andrew Jones
2024-04-02 16:57 ` [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox