Re: [PATCH] KVM: arm64: Read PMUVer as unsigned
From: James Clark
Date: Thu Mar 05 2026 - 08:14:31 EST
On 05/03/2026 11:59 am, Marc Zyngier wrote:
On Thu, 05 Mar 2026 11:50:01 +0000,
James Clark <james.clark@xxxxxxxxxx> wrote:
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.
Fixes: 2417218f2f23 ("KVM: arm64: Get rid of __kvm_get_mdcr_el2() and related warts")
Signed-off-by: James Clark <james.clark@xxxxxxxxxx>
---
arch/arm64/kvm/debug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
index 3ad6b7c6e4ba..b8632edba9a3 100644
--- a/arch/arm64/kvm/debug.c
+++ b/arch/arm64/kvm/debug.c
@@ -76,7 +76,7 @@ void kvm_init_host_debug_data(void)
{
u64 dfr0 = read_sysreg(id_aa64dfr0_el1);
- if (cpuid_feature_extract_signed_field(dfr0, ID_AA64DFR0_EL1_PMUVer_SHIFT) > 0)
+ if (cpuid_feature_extract_unsigned_field(dfr0, ID_AA64DFR0_EL1_PMUVer_SHIFT) > 0)
*host_data_ptr(nr_event_counters) = FIELD_GET(ARMV8_PMU_PMCR_N,
read_sysreg(pmcr_el0));
How does this work on a system that advertises a non-architected PMU?
M.
Hmmm yeah I suppose it doesn't, there's actually already pmuv3_implemented() and has_pmuv3() which open code the same check again. Maybe I can try re-using something and tidying it up.