[PATCH] KVM: arm64: Check cpu_has_spe() before initializing PMSCR_EL1 in VHE
Mukesh Ojha
mukesh.ojha at oss.qualcomm.com
Tue Oct 7 11:23:56 PDT 2025
commit efad60e46057 ("KVM: arm64: Initialize PMSCR_EL1 when in VHE")
initializes PMSCR_EL1 to 0 which is making the boot up stuck when KVM
runs in VHE mode and reverting the change is fixing the issue.
[ 2.967447] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 2.974061] PCI: CLS 0 bytes, default 64
[ 2.978171] Unpacking initramfs...
[ 2.982889] kvm [1]: nv: 568 coarse grained trap handlers
[ 2.988573] kvm [1]: IPA Size Limit: 40 bits
Lets guard the change with cpu_has_spe() check so that it only affects
the cpu which has SPE feature supported.
Fixes: efad60e46057 ("KVM: arm64: Initialize PMSCR_EL1 when in VHE")
Signed-off-by: Mukesh Ojha <mukesh.ojha at oss.qualcomm.com>
---
arch/arm64/kvm/debug.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
index 3515a273eaa2..d9fd45f0db9a 100644
--- a/arch/arm64/kvm/debug.c
+++ b/arch/arm64/kvm/debug.c
@@ -15,6 +15,14 @@
#include <asm/kvm_arm.h>
#include <asm/kvm_emulate.h>
+static int cpu_has_spe(void)
+{
+ u64 dfr0 = read_sysreg(id_aa64dfr0_el1);
+
+ return cpuid_feature_extract_unsigned_field(dfr0, ID_AA64DFR0_EL1_PMSVer_SHIFT) &&
+ !(read_sysreg_s(SYS_PMBIDR_EL1) & PMBIDR_EL1_P);
+}
+
/**
* kvm_arm_setup_mdcr_el2 - configure vcpu mdcr_el2 value
*
@@ -80,8 +88,7 @@ void kvm_init_host_debug_data(void)
if (has_vhe())
return;
- if (cpuid_feature_extract_unsigned_field(dfr0, ID_AA64DFR0_EL1_PMSVer_SHIFT) &&
- !(read_sysreg_s(SYS_PMBIDR_EL1) & PMBIDR_EL1_P))
+ if (cpu_has_spe())
host_data_set_flag(HAS_SPE);
/* Check if we have BRBE implemented and available at the host */
@@ -101,8 +108,8 @@ void kvm_init_host_debug_data(void)
void kvm_debug_init_vhe(void)
{
- /* Clear PMSCR_EL1.E{0,1}SPE which reset to UNKNOWN values. */
- if (SYS_FIELD_GET(ID_AA64DFR0_EL1, PMSVer, read_sysreg(id_aa64dfr0_el1)))
+ if (cpu_has_spe())
+ /* Clear PMSCR_EL1.E{0,1}SPE which reset to UNKNOWN values. */
write_sysreg_el1(0, SYS_PMSCR);
}
--
2.50.1
More information about the linux-arm-kernel
mailing list