diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2017-03-27 18:03:39 +0200 |
---|---|---|
committer | Christoffer Dall <cdall@linaro.org> | 2017-04-09 16:49:13 +0200 |
commit | 9008c235cb8162a4110c9153cace8530bc716210 (patch) | |
tree | 8549f245bfc9b196d2630d7f046ce856418e9734 /arch | |
parent | arm64: KVM: PMU: Inject UNDEF exception on illegal register access (diff) | |
download | linux-9008c235cb8162a4110c9153cace8530bc716210.tar.xz linux-9008c235cb8162a4110c9153cace8530bc716210.zip |
arm64: KVM: PMU: Inject UNDEF on non-privileged accesses
access_pminten() and access_pmuserenr() can only be accessed when
the CPU is in a priviledged mode. If it is not, let's inject an
UNDEF exception.
Reviewed-by: Christoffer Dall <cdall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm64/kvm/sys_regs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 750c129fa3b8..d343c0febdd6 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -709,8 +709,10 @@ static bool access_pminten(struct kvm_vcpu *vcpu, struct sys_reg_params *p, if (!kvm_arm_pmu_v3_ready(vcpu)) return trap_raz_wi(vcpu, p, r); - if (!vcpu_mode_priv(vcpu)) + if (!vcpu_mode_priv(vcpu)) { + kvm_inject_undefined(vcpu); return false; + } if (p->is_write) { u64 val = p->regval & mask; @@ -780,8 +782,10 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return trap_raz_wi(vcpu, p, r); if (p->is_write) { - if (!vcpu_mode_priv(vcpu)) + if (!vcpu_mode_priv(vcpu)) { + kvm_inject_undefined(vcpu); return false; + } vcpu_sys_reg(vcpu, PMUSERENR_EL0) = p->regval & ARMV8_PMU_USERENR_MASK; |