Commit 9008c235 authored by Marc Zyngier's avatar Marc Zyngier Committed by Christoffer Dall

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: default avatarChristoffer Dall <cdall@linaro.org>
Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
parent 24d5950f
...@@ -709,8 +709,10 @@ static bool access_pminten(struct kvm_vcpu *vcpu, struct sys_reg_params *p, ...@@ -709,8 +709,10 @@ static bool access_pminten(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
if (!kvm_arm_pmu_v3_ready(vcpu)) if (!kvm_arm_pmu_v3_ready(vcpu))
return trap_raz_wi(vcpu, p, r); return trap_raz_wi(vcpu, p, r);
if (!vcpu_mode_priv(vcpu)) if (!vcpu_mode_priv(vcpu)) {
kvm_inject_undefined(vcpu);
return false; return false;
}
if (p->is_write) { if (p->is_write) {
u64 val = p->regval & mask; u64 val = p->regval & mask;
...@@ -780,8 +782,10 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, ...@@ -780,8 +782,10 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
return trap_raz_wi(vcpu, p, r); return trap_raz_wi(vcpu, p, r);
if (p->is_write) { if (p->is_write) {
if (!vcpu_mode_priv(vcpu)) if (!vcpu_mode_priv(vcpu)) {
kvm_inject_undefined(vcpu);
return false; return false;
}
vcpu_sys_reg(vcpu, PMUSERENR_EL0) = p->regval vcpu_sys_reg(vcpu, PMUSERENR_EL0) = p->regval
& ARMV8_PMU_USERENR_MASK; & ARMV8_PMU_USERENR_MASK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment