Skip to content

Commit 5513394

Browse files
author
Marc Zyngier
committed
KVM: arm64: nv: Work around lack of pauth support in old toolchains
We still support GCC 8.x, and it appears that this toolchain usually comes with an assembler that does not understand "pauth" as a valid architectural extension. This results in the NV ERETAx code breaking the build, as it relies on this extention to make use of the PACGA instruction (required by assemblers such as LLVM's). Work around it by hand-assembling the instruction, which removes the requirement for any assembler directive. Fixes: 6ccc971 ("KVM: arm64: nv: Add emulation for ERETAx instructions") Reported-by: Linaro Kernel Functional Testing <[email protected]> Suggested-by: Mark Rutland <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent 814ad8f commit 5513394

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

arch/arm64/kvm/pauth.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,20 @@
1414

1515
#include <linux/kvm_host.h>
1616

17+
#include <asm/gpr-num.h>
1718
#include <asm/kvm_emulate.h>
1819
#include <asm/pointer_auth.h>
1920

21+
/* PACGA Xd, Xn, Xm */
22+
#define PACGA(d,n,m) \
23+
asm volatile(__DEFINE_ASM_GPR_NUMS \
24+
".inst 0x9AC03000 |" \
25+
"(.L__gpr_num_%[Rd] << 0) |" \
26+
"(.L__gpr_num_%[Rn] << 5) |" \
27+
"(.L__gpr_num_%[Rm] << 16)\n" \
28+
: [Rd] "=r" ((d)) \
29+
: [Rn] "r" ((n)), [Rm] "r" ((m)))
30+
2031
static u64 compute_pac(struct kvm_vcpu *vcpu, u64 ptr,
2132
struct ptrauth_key ikey)
2233
{
@@ -36,8 +47,7 @@ static u64 compute_pac(struct kvm_vcpu *vcpu, u64 ptr,
3647
__ptrauth_key_install_nosync(APGA, ikey);
3748
isb();
3849

39-
asm volatile(ARM64_ASM_PREAMBLE ".arch_extension pauth\n"
40-
"pacga %0, %1, %2" : "=r" (pac) : "r" (ptr), "r" (mod));
50+
PACGA(pac, ptr, mod);
4151
isb();
4252

4353
__ptrauth_key_install_nosync(APGA, gkey);

0 commit comments

Comments
 (0)