[PATCH] KVM: arm64: Read PMUVer as unsigned

Marc Zyngier maz at kernel.org
Thu Mar 5 03:59:36 PST 2026


On Thu, 05 Mar 2026 11:50:01 +0000,
James Clark <james.clark at linaro.org> 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 at linaro.org>
> ---
>  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.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list