summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Krause <minipli@grsecurity.net>2021-07-06 15:27:14 +0200
committerBruno Martins <bgcngm@gmail.com>2023-11-06 09:28:24 +0000
commitdadcdb870e6a31f63789d7556ca4987359be6c5d (patch)
tree1c0c3c2300717f1f4a819f5c5c454ca6d39a00ac
parent7d5fcdcf62f01cff58dc84080e265a6da1e91e92 (diff)
crypto: curve25519-x86_64: solve register constraints with reserved registers
The register constraints for the inline assembly in fsqr() and fsqr2() are pretty tight on what the compiler may assign to the remaining three register variables. The clobber list only allows the following to be used: RDI, RSI, RBP and R12. With RAP reserving R12 and a kernel having CONFIG_FRAME_POINTER=y, claiming RBP, there are only two registers left so the compiler rightfully complains about impossible constraints. Provide alternatives that'll allow a memory reference for 'out' to solve the allocation constraint dilemma for this configuration. Also make 'out' an input-only operand as it is only used as such. This not only allows gcc to optimize its usage further, but also works around older gcc versions, apparently failing to handle multiple alternatives correctly, as in failing to initialize the 'out' operand with its input value. Signed-off-by: Mathias Krause <minipli@grsecurity.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Change-Id: I7027868359c31d4e514118a2f79b4726e259ddb0
-rw-r--r--drivers/net/wireguard/crypto/zinc/curve25519/curve25519-x86_64.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/net/wireguard/crypto/zinc/curve25519/curve25519-x86_64.c b/drivers/net/wireguard/crypto/zinc/curve25519/curve25519-x86_64.c
index 79716c425b0c..f26ed5d897ac 100644
--- a/drivers/net/wireguard/crypto/zinc/curve25519/curve25519-x86_64.c
+++ b/drivers/net/wireguard/crypto/zinc/curve25519/curve25519-x86_64.c
@@ -581,8 +581,8 @@ static inline void fsqr(u64 *out, const u64 *f, u64 *tmp)
" cmovc %%rdx, %%rax;"
" add %%rax, %%r8;"
" movq %%r8, 0(%0);"
- : "+&r" (tmp), "+&r" (f), "+&r" (out)
- :
+ : "+&r,&r" (tmp), "+&r,&r" (f)
+ : "r,m" (out)
: "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%rbx", "%r13", "%r14", "%r15", "memory", "cc"
);
}
@@ -743,8 +743,8 @@ static inline void fsqr2(u64 *out, const u64 *f, u64 *tmp)
" cmovc %%rdx, %%rax;"
" add %%rax, %%r8;"
" movq %%r8, 32(%0);"
- : "+&r" (tmp), "+&r" (f), "+&r" (out)
- :
+ : "+&r,&r" (tmp), "+&r,&r" (f)
+ : "r,m" (out)
: "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%rbx", "%r13", "%r14", "%r15", "memory", "cc"
);
}