Skip to content

Commit aff2348

Browse files
James-A-ClarkMarc Zyngier
authored andcommitted
KVM: arm64: PMU: Fix PMCR_EL0 reset value
ARMV8_PMU_PMCR_N_MASK is an unshifted value which results in the wrong reset value for PMCR_EL0, so shift it to fix it. This fixes the following error when running qemu: $ qemu-system-aarch64 -cpu host -machine type=virt,accel=kvm -kernel ... target/arm/helper.c:1813: pmevcntr_rawwrite: Assertion `counter < pmu_num_counters(env)' failed. Fixes: 292e8f1 ("KVM: arm64: PMU: Simplify PMCR_EL0 reset handling") Signed-off-by: James Clark <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 753d734 commit aff2348

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
646646
return;
647647

648648
/* Only preserve PMCR_EL0.N, and reset the rest to 0 */
649-
pmcr = read_sysreg(pmcr_el0) & ARMV8_PMU_PMCR_N_MASK;
649+
pmcr = read_sysreg(pmcr_el0) & (ARMV8_PMU_PMCR_N_MASK << ARMV8_PMU_PMCR_N_SHIFT);
650650
if (!kvm_supports_32bit_el0())
651651
pmcr |= ARMV8_PMU_PMCR_LC;
652652

0 commit comments

Comments
 (0)