Skip to content

Commit 9e3f7a2

Browse files
huangweiMarc Zyngier
authored andcommitted
arm64: KVM: pmu: Fix AArch32 cycle counter access
We're missing the handling code for the cycle counter accessed from a 32bit guest, leading to unexpected results. Cc: stable@vger.kernel.org # 4.6+ Signed-off-by: Wei Huang <wei@redhat.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent d42c797 commit 9e3f7a2

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

arch/arm64/kvm/sys_regs.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,16 +597,22 @@ static bool access_pmu_evcntr(struct kvm_vcpu *vcpu,
597597

598598
idx = ARMV8_PMU_CYCLE_IDX;
599599
} else {
600-
BUG();
600+
return false;
601601
}
602+
} else if (r->CRn == 0 && r->CRm == 9) {
603+
/* PMCCNTR */
604+
if (pmu_access_event_counter_el0_disabled(vcpu))
605+
return false;
606+
607+
idx = ARMV8_PMU_CYCLE_IDX;
602608
} else if (r->CRn == 14 && (r->CRm & 12) == 8) {
603609
/* PMEVCNTRn_EL0 */
604610
if (pmu_access_event_counter_el0_disabled(vcpu))
605611
return false;
606612

607613
idx = ((r->CRm & 3) << 3) | (r->Op2 & 7);
608614
} else {
609-
BUG();
615+
return false;
610616
}
611617

612618
if (!pmu_counter_idx_valid(vcpu, idx))

0 commit comments

Comments
 (0)