Skip to content

Commit 2e30447

Browse files
james-c-linarowilldeacon
authored andcommitted
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: 2417218 ("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>
1 parent 1f318b9 commit 2e30447

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

arch/arm64/kvm/debug.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/kvm_host.h>
1111
#include <linux/hw_breakpoint.h>
1212

13+
#include <asm/arm_pmuv3.h>
1314
#include <asm/debug-monitors.h>
1415
#include <asm/kvm_asm.h>
1516
#include <asm/kvm_arm.h>
@@ -75,8 +76,10 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu)
7576
void kvm_init_host_debug_data(void)
7677
{
7778
u64 dfr0 = read_sysreg(id_aa64dfr0_el1);
79+
unsigned int pmuver = cpuid_feature_extract_unsigned_field(dfr0,
80+
ID_AA64DFR0_EL1_PMUVer_SHIFT);
7881

79-
if (cpuid_feature_extract_signed_field(dfr0, ID_AA64DFR0_EL1_PMUVer_SHIFT) > 0)
82+
if (pmuv3_implemented(pmuver))
8083
*host_data_ptr(nr_event_counters) = FIELD_GET(ARMV8_PMU_PMCR_N,
8184
read_sysreg(pmcr_el0));
8285

0 commit comments

Comments
 (0)