1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:46:16 -07:00

runtime, syscall: use FP instead of SP for parameters

Consistently access function parameters using the FP pseudo-register
instead of SP (e.g., x+0(FP) instead of x+4(SP) or x+8(SP), depending
on register size). Two reasons: 1) doc/asm says the SP pseudo-register
should use negative offsets in the range [-framesize, 0), and 2)
cmd/vet only validates parameter offsets when indexed from the FP
pseudo-register.

No binary changes to the compiled object files for any of the affected
package/OS/arch combinations.

Change-Id: I0efc6079bc7519fcea588c114ec6a39b245d68b0
Reviewed-on: https://go-review.googlesource.com/30085
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Matthew Dempsky 2016-09-29 21:34:44 -07:00
parent 79db1625b9
commit 9828b7c468
14 changed files with 113 additions and 114 deletions

View File

@ -237,8 +237,8 @@ TEXT runtime·madvise(SB),NOSPLIT,$0
RET
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVQ new+8(SP), DI
MOVQ old+16(SP), SI
MOVQ new+0(FP), DI
MOVQ old+8(FP), SI
MOVQ $53, AX
SYSCALL
JCC 2(PC)

View File

@ -229,8 +229,8 @@ TEXT runtime·madvise(SB),NOSPLIT,$0
RET
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVQ new+8(SP), DI
MOVQ old+16(SP), SI
MOVQ new+0(FP), DI
MOVQ old+8(FP), SI
MOVQ $53, AX
SYSCALL
JCC 2(PC)

View File

@ -379,8 +379,8 @@ nog:
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVL $186, AX // sigaltstack
MOVL new+4(SP), BX
MOVL old+8(SP), CX
MOVL new+0(FP), BX
MOVL old+4(FP), CX
INVOKE_SYSCALL
CMPL AX, $0xfffff001
JLS 2(PC)

View File

@ -445,8 +445,8 @@ nog:
JMP -3(PC) // keep exiting
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVQ new+8(SP), DI
MOVQ old+16(SP), SI
MOVQ new+0(FP), DI
MOVQ old+8(FP), SI
MOVQ $131, AX
SYSCALL
CMPQ AX, $0xfffffffffffff001

View File

@ -285,8 +285,8 @@ TEXT runtime·lwp_tramp(SB),NOSPLIT,$0
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVL $281, AX // sys___sigaltstack14
MOVL new+4(SP), BX
MOVL old+8(SP), CX
MOVL new+0(FP), BX
MOVL old+4(FP), CX
INT $0x80
CMPL AX, $0xfffff001
JLS 2(PC)

View File

@ -290,8 +290,8 @@ TEXT runtime·madvise(SB),NOSPLIT,$0
RET
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVQ new+8(SP), DI // arg 1 - nss
MOVQ old+16(SP), SI // arg 2 - oss
MOVQ new+0(FP), DI // arg 1 - nss
MOVQ old+8(FP), SI // arg 2 - oss
MOVQ $281, AX // sys___sigaltstack14
SYSCALL
JCC 2(PC)

View File

@ -294,8 +294,8 @@ TEXT runtime·tfork(SB),NOSPLIT,$12
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVL $288, AX // sys_sigaltstack
MOVL new+4(SP), BX
MOVL old+8(SP), CX
MOVL new+0(FP), BX
MOVL old+4(FP), CX
INT $0x80
CMPL AX, $0xfffff001
JLS 2(PC)

View File

@ -278,8 +278,8 @@ TEXT runtime·madvise(SB),NOSPLIT,$0
RET
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVQ new+8(SP), DI // arg 1 - nss
MOVQ old+16(SP), SI // arg 2 - oss
MOVQ new+0(FP), DI // arg 1 - nss
MOVQ old+8(FP), SI // arg 2 - oss
MOVQ $288, AX // sys_sigaltstack
SYSCALL
JCC 2(PC)

View File

@ -178,8 +178,8 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0
RET
// save args
MOVL ureg+4(SP), CX
MOVL note+8(SP), DX
MOVL ureg+0(FP), CX
MOVL note+4(FP), DX
// change stack
MOVL g_m(BX), BX

View File

@ -179,8 +179,8 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0
RET
// save args
MOVQ ureg+8(SP), CX
MOVQ note+16(SP), DX
MOVQ ureg+0(FP), CX
MOVQ note+8(FP), DX
// change stack
MOVQ g_m(BX), BX

View File

@ -309,7 +309,7 @@ TEXT runtime·callbackasm1+0(SB),NOSPLIT,$0
// void tstart(M *newm);
TEXT runtime·tstart(SB),NOSPLIT,$0
MOVL newm+4(SP), CX // m
MOVL newm+0(FP), CX // m
MOVL m_g0(CX), DX // g
// Layout new m scheduler stack on os stack.
@ -337,7 +337,7 @@ TEXT runtime·tstart(SB),NOSPLIT,$0
// uint32 tstart_stdcall(M *newm);
TEXT runtime·tstart_stdcall(SB),NOSPLIT,$0
MOVL newm+4(SP), BX
MOVL newm+0(FP), BX
PUSHL BX
CALL runtime·tstart(SB)

View File

@ -11,124 +11,123 @@
// func Syscall(syscall uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr)
TEXT ·Syscall(SB),NOSPLIT,$0-28
BL runtime·entersyscall(SB)
MOVW syscall+4(SP), R12
MOVW a1+8(SP), R0
MOVW a2+12(SP), R1
MOVW a3+16(SP), R2
MOVW syscall+0(FP), R12
MOVW a1+4(FP), R0
MOVW a2+8(FP), R1
MOVW a3+12(FP), R2
SWI $0x80
BCC ok
MOVW $-1, R1
MOVW R1, r1+20(SP) // r1
MOVW R1, r1+16(FP) // r1
MOVW $0, R2
MOVW R2, r2+24(SP) // r2
MOVW R0, errno+28(SP) // errno
MOVW R2, r2+20(FP) // r2
MOVW R0, errno+24(FP) // errno
BL runtime·exitsyscall(SB)
RET
ok:
MOVW R0, r1+20(SP) // r1
MOVW R1, r2+24(SP) // r2
MOVW R0, r1+16(FP) // r1
MOVW R1, r2+20(FP) // r2
MOVW $0, R0
MOVW R0, errno+28(SP) // errno
MOVW R0, errno+24(FP) // errno
BL runtime·exitsyscall(SB)
RET
// func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr)
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
MOVW syscall+4(SP), R12 // syscall entry
MOVW a1+8(SP), R0
MOVW a2+12(SP), R1
MOVW a3+16(SP), R2
MOVW syscall+0(FP), R12 // syscall entry
MOVW a1+4(FP), R0
MOVW a2+8(FP), R1
MOVW a3+12(FP), R2
SWI $0x80
BCC ok1
MOVW $-1, R1
MOVW R1, r1+20(SP) // r1
MOVW R1, r1+16(FP) // r1
MOVW $0, R2
MOVW R2, r2+24(SP) // r2
MOVW R0, errno+28(SP) // errno
MOVW R2, r2+20(FP) // r2
MOVW R0, errno+24(FP) // errno
RET
ok1:
MOVW R0, r1+20(SP) // r1
MOVW R1, r2+24(SP) // r2
MOVW R0, r1+16(FP) // r1
MOVW R1, r2+20(FP) // r2
MOVW $0, R0
MOVW R0, errno+28(SP) // errno
MOVW R0, errno+24(FP) // errno
RET
// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
TEXT ·Syscall6(SB),NOSPLIT,$0-40
BL runtime·entersyscall(SB)
MOVW syscall+4(SP), R12 // syscall entry
MOVW a1+8(SP), R0
MOVW a2+12(SP), R1
MOVW a3+16(SP), R2
MOVW a4+20(SP), R3
MOVW a5+24(SP), R4
MOVW a6+28(SP), R5
MOVW syscall+0(FP), R12 // syscall entry
MOVW a1+4(FP), R0
MOVW a2+8(FP), R1
MOVW a3+12(FP), R2
MOVW a4+16(FP), R3
MOVW a5+20(FP), R4
MOVW a6+24(FP), R5
SWI $0x80
BCC ok6
MOVW $-1, R1
MOVW R1, r1+32(SP) // r1
MOVW R1, r1+28(FP) // r1
MOVW $0, R2
MOVW R2, r2+36(SP) // r2
MOVW R0, errno+40(SP) // errno
MOVW R2, r2+32(FP) // r2
MOVW R0, errno+36(FP) // errno
BL runtime·exitsyscall(SB)
RET
ok6:
MOVW R0, r1+32(SP) // r1
MOVW R1, r2+36(SP) // r2
MOVW R0, r1+28(FP) // r1
MOVW R1, r2+32(FP) // r2
MOVW $0, R0
MOVW R0, errno+40(SP) // errno
MOVW R0, errno+36(FP) // errno
BL runtime·exitsyscall(SB)
RET
// func RawSyscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
MOVW trap+4(SP), R12 // syscall entry
MOVW a1+8(SP), R0
MOVW a2+12(SP), R1
MOVW a3+16(SP), R2
MOVW a4+20(SP), R3
MOVW a5+24(SP), R4
MOVW a6+28(SP), R5
MOVW trap+0(FP), R12 // syscall entry
MOVW a1+4(FP), R0
MOVW a2+8(FP), R1
MOVW a3+12(FP), R2
MOVW a4+16(FP), R3
MOVW a5+20(FP), R4
MOVW a6+24(FP), R5
SWI $0x80
BCC ok2
MOVW $-1, R1
MOVW R1, r1+32(SP) // r1
MOVW R1, r1+28(FP) // r1
MOVW $0, R2
MOVW R2, r2+36(SP) // r2
MOVW R0, errno+40(SP) // errno
MOVW R2, r2+32(FP) // r2
MOVW R0, errno+36(FP) // errno
RET
ok2:
MOVW R0, r1+32(SP) // r1
MOVW R1, r2+36(SP) // r2
MOVW R0, r1+28(FP) // r1
MOVW R1, r2+32(FP) // r2
MOVW $0, R0
MOVW R0, errno+40(SP) // errno
MOVW R0, errno+36(FP) // errno
RET
// Actually Syscall7.
TEXT ·Syscall9(SB),NOSPLIT,$0-52
BL runtime·entersyscall(SB)
MOVW syscall+4(SP), R12 // syscall entry
MOVW a1+8(SP), R0
MOVW a2+12(SP), R1
MOVW a3+16(SP), R2
MOVW a4+20(SP), R3
MOVW a5+24(SP), R4
MOVW a6+28(SP), R5
MOVW a7+32(SP), R6
MOVW syscall+0(FP), R12 // syscall entry
MOVW a1+4(FP), R0
MOVW a2+8(FP), R1
MOVW a3+12(FP), R2
MOVW a4+16(FP), R3
MOVW a5+20(FP), R4
MOVW a6+24(FP), R5
MOVW a7+28(FP), R6
SWI $0x80
BCC ok9
MOVW $-1, R1
MOVW R1, r1+44(SP) // r1
MOVW R1, r1+40(FP) // r1
MOVW $0, R2
MOVW R2, r2+48(SP) // r2
MOVW R0, errno+52(SP) // errno
MOVW R2, r2+44(FP) // r2
MOVW R0, errno+48(FP) // errno
BL runtime·exitsyscall(SB)
RET
ok9:
MOVW R0, r1+44(SP) // r1
MOVW R1, r2+48(SP) // r2
MOVW R0, r1+40(FP) // r1
MOVW R1, r2+44(FP) // r2
MOVW $0, R0
MOVW R0, errno+52(SP) // errno
MOVW R0, errno+48(FP) // errno
BL runtime·exitsyscall(SB)
RET

View File

@ -29,8 +29,8 @@ TEXT ·Syscall(SB),NOSPLIT,$0-32
MOVSL
MOVSL
INT $64
MOVL AX, r1+20(SP)
MOVL $0, r2+24(SP)
MOVL AX, r1+16(FP)
MOVL $0, r2+20(FP)
CMPL AX, $-1
JNE ok3
@ -44,7 +44,7 @@ ok3:
LEAL runtime·emptystring(SB), SI
copyresult3:
LEAL err+28(SP), DI
LEAL err+24(FP), DI
CLD
MOVSL
@ -67,8 +67,8 @@ TEXT ·Syscall6(SB),NOSPLIT,$0-44
MOVSL
MOVSL
INT $64
MOVL AX, r1+32(SP)
MOVL $0, r2+36(SP)
MOVL AX, r1+28(FP)
MOVL $0, r2+32(FP)
CMPL AX, $-1
JNE ok4
@ -82,7 +82,7 @@ ok4:
LEAL runtime·emptystring(SB), SI
copyresult4:
LEAL err+40(SP), DI
LEAL err+36(FP), DI
CLD
MOVSL
@ -101,9 +101,9 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-28
MOVSL
MOVSL
INT $64
MOVL AX, r1+20(SP)
MOVL AX, r2+24(SP)
MOVL AX, err+28(SP)
MOVL AX, r1+16(FP)
MOVL AX, r2+20(FP)
MOVL AX, err+24(FP)
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
@ -119,17 +119,17 @@ TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
MOVSL
MOVSL
INT $64
MOVL AX, r1+32(SP)
MOVL AX, r2+36(SP)
MOVL AX, err+40(SP)
MOVL AX, r1+28(FP)
MOVL AX, r2+32(FP)
MOVL AX, err+36(FP)
RET
#define SYS_SEEK 39 /* from zsysnum_plan9_386.go */
//func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
TEXT ·seek(SB),NOSPLIT,$0-36
LEAL newoffset+24(SP), AX
MOVL AX, placeholder+4(SP)
LEAL newoffset+20(FP), AX
MOVL AX, placeholder+0(FP)
MOVL $SYS_SEEK, AX // syscall entry
INT $64
@ -149,7 +149,7 @@ ok6:
LEAL runtime·emptystring(SB), SI
copyresult6:
LEAL err+32(SP), DI
LEAL err+28(FP), DI
CLD
MOVSL

View File

@ -28,8 +28,8 @@ TEXT ·Syscall(SB),NOSPLIT,$0-64
MOVSQ
MOVSQ
SYSCALL
MOVQ AX, r1+40(SP)
MOVQ $0, r2+48(SP)
MOVQ AX, r1+32(FP)
MOVQ $0, r2+40(FP)
CMPL AX, $-1
JNE ok3
@ -43,7 +43,7 @@ ok3:
LEAQ runtime·emptystring(SB), SI
copyresult3:
LEAQ err+56(SP), DI
LEAQ err+48(FP), DI
CLD
MOVSQ
@ -66,8 +66,8 @@ TEXT ·Syscall6(SB),NOSPLIT,$0-88
MOVSQ
MOVSQ
SYSCALL
MOVQ AX, r1+64(SP)
MOVQ $0, r2+72(SP)
MOVQ AX, r1+56(FP)
MOVQ $0, r2+64(FP)
CMPL AX, $-1
JNE ok4
@ -81,7 +81,7 @@ ok4:
LEAQ runtime·emptystring(SB), SI
copyresult4:
LEAQ err+80(SP), DI
LEAQ err+72(FP), DI
CLD
MOVSQ
@ -100,9 +100,9 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-56
MOVSQ
MOVSQ
SYSCALL
MOVQ AX, r1+40(SP)
MOVQ AX, r2+48(SP)
MOVQ AX, err+56(SP)
MOVQ AX, r1+32(FP)
MOVQ AX, r2+40(FP)
MOVQ AX, err+48(FP)
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
@ -118,24 +118,24 @@ TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
MOVSQ
MOVSQ
SYSCALL
MOVQ AX, r1+64(SP)
MOVQ AX, r2+72(SP)
MOVQ AX, err+80(SP)
MOVQ AX, r1+56(FP)
MOVQ AX, r2+64(FP)
MOVQ AX, err+72(FP)
RET
#define SYS_SEEK 39 /* from zsysnum_plan9_amd64.go */
//func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
TEXT ·seek(SB),NOSPLIT,$0-56
LEAQ newoffset+40(SP), AX
MOVQ AX, placeholder+8(SP)
LEAQ newoffset+32(FP), AX
MOVQ AX, placeholder+0(FP)
MOVQ $SYS_SEEK, BP // syscall entry
SYSCALL
CMPL AX, $-1
JNE ok6
MOVQ $-1, newoffset+40(SP)
MOVQ $-1, newoffset+32(FP)
SUBQ $16, SP
CALL syscall·errstr(SB)
@ -147,7 +147,7 @@ ok6:
LEAQ runtime·emptystring(SB), SI
copyresult6:
LEAQ err+48(SP), DI
LEAQ err+40(FP), DI
CLD
MOVSQ