aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2017-03-27 17:03:38 +0100
committerChristoffer Dall <cdall@linaro.org>2017-04-09 07:49:13 -0700
commit24d5950f6befae3f4b7eaab890ad9bc0988824b6 (patch)
tree276aea69bae328c49c63336c6976af4d03ea45d7 /arch
parentarm64: KVM: PMU: Refactor pmu_*_el0_disabled (diff)
downloadlinux-dev-24d5950f6befae3f4b7eaab890ad9bc0988824b6.tar.xz
linux-dev-24d5950f6befae3f4b7eaab890ad9bc0988824b6.zip
arm64: KVM: PMU: Inject UNDEF exception on illegal register access
Both pmu_*_el0_disabled() and pmu_counter_idx_valid() perform checks on the validity of an access, but only return a boolean indicating if the access is valid or not. Let's allow these functions to also inject an UNDEF exception if the access was illegal. Reviewed-by: Christoffer Dall <cdall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to '')
-rw-r--r--arch/arm64/kvm/sys_regs.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 036efc971e89..750c129fa3b8 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -465,6 +465,9 @@ static bool check_pmu_access_disabled(struct kvm_vcpu *vcpu, u64 flags)
u64 reg = vcpu_sys_reg(vcpu, PMUSERENR_EL0);
bool enabled = (reg & flags) || vcpu_mode_priv(vcpu);
+ if (!enabled)
+ kvm_inject_undefined(vcpu);
+
return !enabled;
}
@@ -564,8 +567,10 @@ static bool pmu_counter_idx_valid(struct kvm_vcpu *vcpu, u64 idx)
pmcr = vcpu_sys_reg(vcpu, PMCR_EL0);
val = (pmcr >> ARMV8_PMU_PMCR_N_SHIFT) & ARMV8_PMU_PMCR_N_MASK;
- if (idx >= val && idx != ARMV8_PMU_CYCLE_IDX)
+ if (idx >= val && idx != ARMV8_PMU_CYCLE_IDX) {
+ kvm_inject_undefined(vcpu);
return false;
+ }
return true;
}