aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMathias Krause <minipli@grsecurity.net>2021-07-06 15:27:14 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-12-06 22:47:01 +0100
commit3c9f3b6997fe8cbb5e7b80ea5d622b5d0e827003 (patch)
tree947e37aebe7e8f77b3dd64e43e30a48a5a6348ec
parentcompat: udp_tunnel: don't take reference to non-init namespace (diff)
downloadwireguard-linux-compat-3c9f3b6997fe8cbb5e7b80ea5d622b5d0e827003.tar.xz
wireguard-linux-compat-3c9f3b6997fe8cbb5e7b80ea5d622b5d0e827003.zip
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>
-rw-r--r--src/crypto/zinc/curve25519/curve25519-x86_64.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/crypto/zinc/curve25519/curve25519-x86_64.c b/src/crypto/zinc/curve25519/curve25519-x86_64.c
index 79716c4..f26ed5d 100644
--- a/src/crypto/zinc/curve25519/curve25519-x86_64.c
+++ b/src/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"
);
}