summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/lib/arm64/gic_v3.c
diff options
context:
space:
mode:
authorMaximilian Dittgen <mdittgen@amazon.de>2025-11-19 14:57:43 +0100
committerOliver Upton <oupton@kernel.org>2025-11-19 12:38:59 -0800
commit31df012da496968d8d4368f693ad45dfcbfba40b (patch)
treec3546bf1db63555a38ded9fd2d4aac601ee5bd4f /tools/testing/selftests/kvm/lib/arm64/gic_v3.c
parentcb17d79ff51d41f656bcf7928330b2e9c0003583 (diff)
KVM: selftests: Assert GICR_TYPER.Processor_Number matches selftest CPU number
The selftests GIC library and tests assume that the GICR_TYPER.Processor_number associated with a given CPU is the same as the CPU's selftest index. Since this assumption is not guaranteed by specification, add an assert in gicv3_cpu_init() that validates this is true. Signed-off-by: Maximilian Dittgen <mdittgen@amazon.de> Link: https://msgid.link/20251119135744.68552-1-mdittgen@amazon.de Signed-off-by: Oliver Upton <oupton@kernel.org>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/arm64/gic_v3.c')
-rw-r--r--tools/testing/selftests/kvm/lib/arm64/gic_v3.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/lib/arm64/gic_v3.c b/tools/testing/selftests/kvm/lib/arm64/gic_v3.c
index 66d05506f78b..f81025cd32e2 100644
--- a/tools/testing/selftests/kvm/lib/arm64/gic_v3.c
+++ b/tools/testing/selftests/kvm/lib/arm64/gic_v3.c
@@ -298,12 +298,17 @@ static void gicv3_cpu_init(unsigned int cpu)
volatile void *sgi_base;
unsigned int i;
volatile void *redist_base_cpu;
+ u64 typer;
GUEST_ASSERT(cpu < gicv3_data.nr_cpus);
redist_base_cpu = gicr_base_cpu(cpu);
sgi_base = sgi_base_from_redist(redist_base_cpu);
+ /* Verify assumption that GICR_TYPER.Processor_number == cpu */
+ typer = readq_relaxed(redist_base_cpu + GICR_TYPER);
+ GUEST_ASSERT_EQ(GICR_TYPER_CPU_NUMBER(typer), cpu);
+
gicv3_enable_redist(redist_base_cpu);
/*