summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Clark <james.clark@linaro.org>2026-03-05 19:28:17 +0300
committerWill Deacon <will@kernel.org>2026-03-24 15:33:48 +0300
commit2e30447b233a8e7a561bb51995b8d4944282bf62 (patch)
treeebd812ee72883a2b673ebf416afd6cf43e6955db
parent1f318b96cc84d7c2ab792fcc0bfd42a7ca890681 (diff)
downloadlinux-2e30447b233a8e7a561bb51995b8d4944282bf62.tar.xz
KVM: arm64: Read PMUVer as unsigned
ID_AA64DFR0_EL1.PMUVer is an unsigned field, so this skips initialization of host_data_ptr(nr_event_counters) for PMUv3 for Armv8.8 onwards as they appear as negative values. Fix it by reading it as unsigned. Now ID_AA64DFR0_EL1_PMUVer_IMP_DEF needs to be special cased, so use pmuv3_implemented() which already does it. Fixes: 2417218f2f23 ("KVM: arm64: Get rid of __kvm_get_mdcr_el2() and related warts") Signed-off-by: James Clark <james.clark@linaro.org> Reviewed-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Colton Lewis <coltonlewis@google.com> Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--arch/arm64/kvm/debug.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
index 3ad6b7c6e4ba..f4d7b12045e8 100644
--- a/arch/arm64/kvm/debug.c
+++ b/arch/arm64/kvm/debug.c
@@ -10,6 +10,7 @@
#include <linux/kvm_host.h>
#include <linux/hw_breakpoint.h>
+#include <asm/arm_pmuv3.h>
#include <asm/debug-monitors.h>
#include <asm/kvm_asm.h>
#include <asm/kvm_arm.h>
@@ -75,8 +76,10 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu)
void kvm_init_host_debug_data(void)
{
u64 dfr0 = read_sysreg(id_aa64dfr0_el1);
+ unsigned int pmuver = cpuid_feature_extract_unsigned_field(dfr0,
+ ID_AA64DFR0_EL1_PMUVer_SHIFT);
- if (cpuid_feature_extract_signed_field(dfr0, ID_AA64DFR0_EL1_PMUVer_SHIFT) > 0)
+ if (pmuv3_implemented(pmuver))
*host_data_ptr(nr_event_counters) = FIELD_GET(ARMV8_PMU_PMCR_N,
read_sysreg(pmcr_el0));