Skip to content

Commit 8118c24

Browse files
minipli-osszx2c4
authored andcommitted
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. Signed-off-by: Mathias Krause <minipli@grsecurity.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 2974725 commit 8118c24

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/crypto/zinc/curve25519/curve25519-x86_64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static inline void fsqr(u64 *out, const u64 *f, u64 *tmp)
581581
" cmovc %%rdx, %%rax;"
582582
" add %%rax, %%r8;"
583583
" movq %%r8, 0(%0);"
584-
: "+&r" (tmp), "+&r" (f), "+&r" (out)
584+
: "+&r,&r" (tmp), "+&r,&r" (f), "+&r,m" (out)
585585
:
586586
: "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%rbx", "%r13", "%r14", "%r15", "memory", "cc"
587587
);
@@ -743,7 +743,7 @@ static inline void fsqr2(u64 *out, const u64 *f, u64 *tmp)
743743
" cmovc %%rdx, %%rax;"
744744
" add %%rax, %%r8;"
745745
" movq %%r8, 32(%0);"
746-
: "+&r" (tmp), "+&r" (f), "+&r" (out)
746+
: "+&r,&r" (tmp), "+&r,&r" (f), "+&r,m" (out)
747747
:
748748
: "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%rbx", "%r13", "%r14", "%r15", "memory", "cc"
749749
);

0 commit comments

Comments
 (0)