Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

James Clark and committed by
Will Deacon
2e30447b 1f318b96

+4 -1
+4 -1
arch/arm64/kvm/debug.c
··· 10 10 #include <linux/kvm_host.h> 11 11 #include <linux/hw_breakpoint.h> 12 12 13 + #include <asm/arm_pmuv3.h> 13 14 #include <asm/debug-monitors.h> 14 15 #include <asm/kvm_asm.h> 15 16 #include <asm/kvm_arm.h> ··· 76 75 void kvm_init_host_debug_data(void) 77 76 { 78 77 u64 dfr0 = read_sysreg(id_aa64dfr0_el1); 78 + unsigned int pmuver = cpuid_feature_extract_unsigned_field(dfr0, 79 + ID_AA64DFR0_EL1_PMUVer_SHIFT); 79 80 80 - if (cpuid_feature_extract_signed_field(dfr0, ID_AA64DFR0_EL1_PMUVer_SHIFT) > 0) 81 + if (pmuv3_implemented(pmuver)) 81 82 *host_data_ptr(nr_event_counters) = FIELD_GET(ARMV8_PMU_PMCR_N, 82 83 read_sysreg(pmcr_el0)); 83 84