curve25519: fix confusing SP adjustments
The curve25519 assembly routines do very non-Go-ABI SP adjustments.
These would thoroughly confuse traceback if it were to fire in one of
these functions (say, because of a signal). Plus, we're about to make
the assembler track SP balance through more operations (which it
should have done all along), and the SP alignment performed by these
functions is going to make the assembler think the SP is out of
balance.
Fix this by eliminating the SP alignment prologue from all four
assembly functions. They don't do any operations that care about SP
alignment, so this is simply unnecessary. square and freeze don't even
use the stack for anything other that saving what were presumably
"callee save" registers in some other ABI, so for these we can
eliminate the stack frame entirely.
Change-Id: If9dbb2fb6800d9cd733daa91f483eb2937e95f0f
Reviewed-on: https://go-review.googlesource.com/31579
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
diff --git a/curve25519/ladderstep_amd64.s b/curve25519/ladderstep_amd64.s
index 3949f9c..af17c0a 100644
--- a/curve25519/ladderstep_amd64.s
+++ b/curve25519/ladderstep_amd64.s
@@ -8,15 +8,9 @@
// +build amd64,!gccgo,!appengine
// func ladderstep(inout *[5][5]uint64)
-TEXT ·ladderstep(SB),0,$384-8
+TEXT ·ladderstep(SB),0,$352-8
MOVQ inout+0(FP),DI
- MOVQ SP,R11
- MOVQ $31,CX
- NOTQ CX
- ANDQ CX,SP
- ADDQ $32,SP
-
MOVQ R11,0(SP)
MOVQ R12,8(SP)
MOVQ R13,16(SP)
@@ -1392,7 +1386,6 @@
MOVQ 32(SP),R15
MOVQ 40(SP),BX
MOVQ 48(SP),BP
- MOVQ R11,SP
MOVQ DI,AX
MOVQ SI,DX
RET