Skip to content

Commit 8a04986

Browse files
author
Marc Zyngier
committed
KVM: arm64: Fix early exit ptrauth handling
The previous rework of the early exit code to provide an EC-based decoding tree missed the fact that we have two trap paths for ptrauth: the instructions (EC_PAC) and the sysregs (EC_SYS64). Rework the handlers to call the ptrauth handling code on both paths. Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Fuad Tabba <[email protected]> Tested-by: Fuad Tabba <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5f39efc commit 8a04986

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,6 @@ static inline bool handle_tx2_tvm(struct kvm_vcpu *vcpu)
282282

283283
static inline bool esr_is_ptrauth_trap(u32 esr)
284284
{
285-
u32 ec = ESR_ELx_EC(esr);
286-
287-
if (ec == ESR_ELx_EC_PAC)
288-
return true;
289-
290-
if (ec != ESR_ELx_EC_SYS64)
291-
return false;
292-
293285
switch (esr_sys64_to_sysreg(esr)) {
294286
case SYS_APIAKEYLO_EL1:
295287
case SYS_APIAKEYHI_EL1:
@@ -323,8 +315,7 @@ static bool kvm_hyp_handle_ptrauth(struct kvm_vcpu *vcpu, u64 *exit_code)
323315
struct kvm_cpu_context *ctxt;
324316
u64 val;
325317

326-
if (!vcpu_has_ptrauth(vcpu) ||
327-
!esr_is_ptrauth_trap(kvm_vcpu_get_esr(vcpu)))
318+
if (!vcpu_has_ptrauth(vcpu))
328319
return false;
329320

330321
ctxt = this_cpu_ptr(&kvm_hyp_ctxt);
@@ -353,6 +344,9 @@ static bool kvm_hyp_handle_sysreg(struct kvm_vcpu *vcpu, u64 *exit_code)
353344
__vgic_v3_perform_cpuif_access(vcpu) == 1)
354345
return true;
355346

347+
if (esr_is_ptrauth_trap(kvm_vcpu_get_esr(vcpu)))
348+
return kvm_hyp_handle_ptrauth(vcpu, exit_code);
349+
356350
return false;
357351
}
358352

0 commit comments

Comments
 (0)