]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: arm64: Guard PMSCR_EL1 initialization with SPE presence check
authorMukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Fri, 10 Oct 2025 17:47:07 +0000 (23:17 +0530)
committerMarc Zyngier <maz@kernel.org>
Mon, 13 Oct 2025 13:26:36 +0000 (14:26 +0100)
commitc35dd838666d47de2848639234ec32e3ba22b49f
tree7ecf9dd6e69394a2efa75b72cbc2dfd5bc358af9
parent9a7f87eb587da49993f47f44c4c5535d8de76750
KVM: arm64: Guard PMSCR_EL1 initialization with SPE presence check

Commit efad60e46057 ("KVM: arm64: Initialize PMSCR_EL1 when in VHE")
does not perform sufficient check before initializing PMSCR_EL1 to 0
when running in VHE mode. On some platforms, this causes the system to
hang during boot, as EL3 has not delegated access to the Profiling
Buffer to the Non-secure world, nor does it reinject an UNDEF on sysreg
trap.

To avoid this issue, restrict the PMSCR_EL1 initialization to CPUs that
support Statistical Profiling Extension (FEAT_SPE) and have the
Profiling Buffer accessible in Non-secure EL1. This is determined via a
new helper `cpu_has_spe()` which checks both PMSVer and PMBIDR_EL1.P.

This ensures the initialization only affects CPUs where SPE is
implemented and usable, preventing boot failures on platforms where SPE
is not properly configured.

Fixes: efad60e46057 ("KVM: arm64: Initialize PMSCR_EL1 when in VHE")
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/debug.c