Skip to content

Commit bf4086b

Browse files
author
Marc Zyngier
committed
KVM: arm64: Prevent vcpu_has_ptrauth from generating OOL functions
So far, vcpu_has_ptrauth() is implemented in terms of system_supports_*_auth() calls, which are declared "inline". In some specific conditions (clang and SCS), the "inline" very much turns into an "out of line", which leads to a fireworks when this predicate is evaluated on a non-VHE system (right at the beginning of __hyp_handle_ptrauth). Instead, make sure vcpu_has_ptrauth gets expanded inline by directly using the cpus_have_final_cap() helpers, which are __always_inline, generate much better code, and are the only thing that make sense when running at EL2 on a nVHE system. Fixes: 29eb5a3 ("KVM: arm64: Handle PtrAuth traps early") Reported-by: Nathan Chancellor <natechancellor@gmail.com> Reported-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Tested-by: Nathan Chancellor <natechancellor@gmail.com> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> Link: https://lore.kernel.org/r/20200722162231.3689767-1-maz@kernel.org
1 parent b9e10d4 commit bf4086b

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

arch/arm64/include/asm/kvm_host.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,14 @@ struct kvm_vcpu_arch {
380380
#define vcpu_has_sve(vcpu) (system_supports_sve() && \
381381
((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE))
382382

383-
#define vcpu_has_ptrauth(vcpu) ((system_supports_address_auth() || \
384-
system_supports_generic_auth()) && \
385-
((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_PTRAUTH))
383+
#ifdef CONFIG_ARM64_PTR_AUTH
384+
#define vcpu_has_ptrauth(vcpu) \
385+
((cpus_have_final_cap(ARM64_HAS_ADDRESS_AUTH) || \
386+
cpus_have_final_cap(ARM64_HAS_GENERIC_AUTH)) && \
387+
(vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_PTRAUTH)
388+
#else
389+
#define vcpu_has_ptrauth(vcpu) false
390+
#endif
386391

387392
#define vcpu_gp_regs(v) (&(v)->arch.ctxt.gp_regs)
388393

0 commit comments

Comments
 (0)