Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Maximilian Dittgen and committed by
Oliver Upton
31df012d cb17d79f

+5
+5
tools/testing/selftests/kvm/lib/arm64/gic_v3.c
··· 298 298 volatile void *sgi_base; 299 299 unsigned int i; 300 300 volatile void *redist_base_cpu; 301 + u64 typer; 301 302 302 303 GUEST_ASSERT(cpu < gicv3_data.nr_cpus); 303 304 304 305 redist_base_cpu = gicr_base_cpu(cpu); 305 306 sgi_base = sgi_base_from_redist(redist_base_cpu); 307 + 308 + /* Verify assumption that GICR_TYPER.Processor_number == cpu */ 309 + typer = readq_relaxed(redist_base_cpu + GICR_TYPER); 310 + GUEST_ASSERT_EQ(GICR_TYPER_CPU_NUMBER(typer), cpu); 306 311 307 312 gicv3_enable_redist(redist_base_cpu); 308 313