Skip to content

Commit 2c3db77

Browse files
author
Marc Zyngier
committed
KVM: arm64: pauth: Use ctxt_sys_reg() instead of raw sys_regs access
Now that we have a wrapper for the sysreg accesses, let's use that consistently. Signed-off-by: Marc Zyngier <[email protected]>
1 parent 308472c commit 2c3db77

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,14 @@ static inline bool esr_is_ptrauth_trap(u32 esr)
364364
return false;
365365
}
366366

367-
#define __ptrauth_save_key(regs, key) \
368-
({ \
369-
regs[key ## KEYLO_EL1] = read_sysreg_s(SYS_ ## key ## KEYLO_EL1); \
370-
regs[key ## KEYHI_EL1] = read_sysreg_s(SYS_ ## key ## KEYHI_EL1); \
371-
})
367+
#define __ptrauth_save_key(ctxt, key) \
368+
do { \
369+
u64 __val; \
370+
__val = read_sysreg_s(SYS_ ## key ## KEYLO_EL1); \
371+
ctxt_sys_reg(ctxt, key ## KEYLO_EL1) = __val; \
372+
__val = read_sysreg_s(SYS_ ## key ## KEYHI_EL1); \
373+
ctxt_sys_reg(ctxt, key ## KEYHI_EL1) = __val; \
374+
} while(0)
372375

373376
static inline bool __hyp_handle_ptrauth(struct kvm_vcpu *vcpu)
374377
{
@@ -380,11 +383,11 @@ static inline bool __hyp_handle_ptrauth(struct kvm_vcpu *vcpu)
380383
return false;
381384

382385
ctxt = &__hyp_this_cpu_ptr(kvm_host_data)->host_ctxt;
383-
__ptrauth_save_key(ctxt->sys_regs, APIA);
384-
__ptrauth_save_key(ctxt->sys_regs, APIB);
385-
__ptrauth_save_key(ctxt->sys_regs, APDA);
386-
__ptrauth_save_key(ctxt->sys_regs, APDB);
387-
__ptrauth_save_key(ctxt->sys_regs, APGA);
386+
__ptrauth_save_key(ctxt, APIA);
387+
__ptrauth_save_key(ctxt, APIB);
388+
__ptrauth_save_key(ctxt, APDA);
389+
__ptrauth_save_key(ctxt, APDB);
390+
__ptrauth_save_key(ctxt, APGA);
388391

389392
vcpu_ptrauth_enable(vcpu);
390393

0 commit comments

Comments
 (0)