]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arm64: KVM: pmu: Fix AArch32 cycle counter access
authorWei Huang <wei@redhat.com>
Wed, 16 Nov 2016 09:20:57 +0000 (09:20 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2016 08:56:53 +0000 (09:56 +0100)
commit 9e3f7a29694049edd728e2400ab57ad7553e5aa9 upstream.

We're missing the handling code for the cycle counter accessed
from a 32bit guest, leading to unexpected results.

Signed-off-by: Wei Huang <wei@redhat.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/kvm/sys_regs.c

index e51367d159d0250aaa7e53d33803caddfbae9de8..31c144f7339a08371f1624d55b0cf50a500bf2cf 100644 (file)
@@ -602,8 +602,14 @@ static bool access_pmu_evcntr(struct kvm_vcpu *vcpu,
 
                        idx = ARMV8_PMU_CYCLE_IDX;
                } else {
-                       BUG();
+                       return false;
                }
+       } else if (r->CRn == 0 && r->CRm == 9) {
+               /* PMCCNTR */
+               if (pmu_access_event_counter_el0_disabled(vcpu))
+                       return false;
+
+               idx = ARMV8_PMU_CYCLE_IDX;
        } else if (r->CRn == 14 && (r->CRm & 12) == 8) {
                /* PMEVCNTRn_EL0 */
                if (pmu_access_event_counter_el0_disabled(vcpu))
@@ -611,7 +617,7 @@ static bool access_pmu_evcntr(struct kvm_vcpu *vcpu,
 
                idx = ((r->CRm & 3) << 3) | (r->Op2 & 7);
        } else {
-               BUG();
+               return false;
        }
 
        if (!pmu_counter_idx_valid(vcpu, idx))