arm64: KVM: PMU: Inject UNDEF on read access to PMSWINC_EL0
authorMarc Zyngier <marc.zyngier@arm.com>
Mon, 27 Mar 2017 16:03:41 +0000 (17:03 +0100)
committerChristoffer Dall <cdall@linaro.org>
Sun, 9 Apr 2017 14:49:14 +0000 (07:49 -0700)
PMSWINC_EL0 is a WO register, so let's UNDEF when reading from it
(in the highly hypothetical case where this doesn't UNDEF at EL1).

Reviewed-by: Christoffer Dall <cdall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm64/kvm/sys_regs.c

index 20f90c01af33ba9d86788d7eda7f15b1b27e3c23..3fef01d751642dac7802ac6a506e0a7072d072ff 100644 (file)
@@ -772,16 +772,15 @@ static bool access_pmswinc(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
        if (!kvm_arm_pmu_v3_ready(vcpu))
                return trap_raz_wi(vcpu, p, r);
 
+       if (!p->is_write)
+               return read_from_write_only(vcpu, p);
+
        if (pmu_write_swinc_el0_disabled(vcpu))
                return false;
 
-       if (p->is_write) {
-               mask = kvm_pmu_valid_counter_mask(vcpu);
-               kvm_pmu_software_increment(vcpu, p->regval & mask);
-               return true;
-       }
-
-       return false;
+       mask = kvm_pmu_valid_counter_mask(vcpu);
+       kvm_pmu_software_increment(vcpu, p->regval & mask);
+       return true;
 }
 
 static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,