Skip to content

Commit 0c729ba

Browse files
committed
Bugfix: mark outputs as early clobber in scalar x86_64 asm
In the existing code, the compiler is allowed to allocate the RSI register for outputs m0, m1, or m2, which are written to before the input in RSI is read from. Fix this by marking them as early clobber. Reported by ehoffman2 in bitcoin-core/secp256k1#766
1 parent 3353d3c commit 0c729ba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/scalar_4x64_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static void secp256k1_scalar_reduce_512(secp256k1_scalar *r, const uint64_t *l)
383383
"movq %%r10, %q5\n"
384384
/* extract m6 */
385385
"movq %%r8, %q6\n"
386-
: "=g"(m0), "=g"(m1), "=g"(m2), "=g"(m3), "=g"(m4), "=g"(m5), "=g"(m6)
386+
: "=&g"(m0), "=&g"(m1), "=&g"(m2), "=g"(m3), "=g"(m4), "=g"(m5), "=g"(m6)
387387
: "S"(l), "i"(SECP256K1_N_C_0), "i"(SECP256K1_N_C_1)
388388
: "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "cc");
389389

0 commit comments

Comments
 (0)