1
0
mirror of https://github.com/golang/go synced 2024-11-19 21:14:43 -07:00

syscall: make func Syscall use pointer maps from Go prototypes

Before, Syscall and friends were having their arguments
treated conservatively. Now they will use the Go prototype,
which will mean the arguments are not considered pointers
at all.

This is safe because of CL 139360044.

The fact that all these non-Solaris systems were using
conservative scanning of the Syscall arguments is why
the failure that prompted CL 139360044 was only
observed on Solaris, which does something completely different.
If we'd done this earlier, we'd have seen the Solaris
failure in more places.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/144730043
This commit is contained in:
Russ Cox 2014-09-12 00:23:03 -04:00
parent 99f7df0598
commit 4179439de8
20 changed files with 83 additions and 0 deletions

View File

@ -16,6 +16,7 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -40,6 +41,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -67,6 +69,7 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -97,6 +100,7 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@ -118,6 +122,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI

View File

@ -6,6 +6,7 @@
// so that go vet can check that they are correct.
#include "textflag.h"
#include "funcdata.h"
//
// System call support for AMD64, Darwin
@ -16,6 +17,7 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-56
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@ -40,6 +42,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@ -64,6 +67,7 @@ ok6:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@ -85,6 +89,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX

View File

@ -13,6 +13,7 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-32
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -37,6 +38,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-44
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -64,6 +66,7 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-56
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -94,6 +97,7 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-32
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@ -115,6 +119,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-44
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI

View File

@ -14,6 +14,7 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-64
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@ -37,6 +38,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-88
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@ -60,6 +62,7 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-112
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX
MOVQ 16(SP), DI
@ -93,6 +96,7 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-64
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@ -113,6 +117,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-88
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX

View File

@ -16,6 +16,7 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -40,6 +41,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -67,6 +69,7 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -97,6 +100,7 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@ -118,6 +122,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI

View File

@ -22,6 +22,7 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-56
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@ -45,6 +46,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@ -68,6 +70,7 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-104
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX
MOVQ 16(SP), DI
@ -101,6 +104,7 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@ -121,6 +125,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX

View File

@ -13,6 +13,7 @@
// func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, errno uintptr)
TEXT ·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
@ -35,6 +36,7 @@ error:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
@ -61,6 +63,7 @@ error6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
@ -87,6 +90,7 @@ error9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
GO_ARGS
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
MOVW 8(FP), R1 // a2
@ -106,6 +110,7 @@ errorr:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
GO_ARGS
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
MOVW 8(FP), R1 // a2

View File

@ -15,6 +15,7 @@
// Trap # in AX, args in BX CX DX SI DI, return in AX
TEXT ·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
MOVL 8(SP), BX
@ -40,6 +41,7 @@ ok:
// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
TEXT ·Syscall6(SB),NOSPLIT,$0-40
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
MOVL 8(SP), BX
@ -66,6 +68,7 @@ ok6:
// func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
GO_ARGS
MOVL 4(SP), AX // syscall entry
MOVL 8(SP), BX
MOVL 12(SP), CX
@ -88,6 +91,7 @@ ok1:
// func RawSyscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
GO_ARGS
MOVL 4(SP), AX // syscall entry
MOVL 8(SP), BX
MOVL 12(SP), CX

View File

@ -17,6 +17,7 @@
// would pass 4th arg in CX, not R10.
TEXT ·Syscall(SB),NOSPLIT,$0-56
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@ -42,6 +43,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@ -67,6 +69,7 @@ ok6:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@ -89,6 +92,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX

View File

@ -13,6 +13,7 @@
// func Syscall(syscall uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
TEXT ·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
BL runtime·entersyscall(SB)
MOVW 4(SP), R7
MOVW 8(SP), R0
@ -44,6 +45,7 @@ ok:
// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
// Actually Syscall5 but the rest of the code expects it to be named Syscall6.
TEXT ·Syscall6(SB),NOSPLIT,$0-40
GO_ARGS
BL runtime·entersyscall(SB)
MOVW 4(SP), R7 // syscall entry
MOVW 8(SP), R0
@ -75,6 +77,7 @@ ok6:
// func RawSyscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
// Actually RawSyscall5 but the rest of the code expects it to be named RawSyscall6.
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
GO_ARGS
MOVW 4(SP), R7 // syscall entry
MOVW 8(SP), R0
MOVW 12(SP), R1
@ -134,6 +137,7 @@ okseek:
// func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
GO_ARGS
MOVW 4(SP), R7 // syscall entry
MOVW 8(SP), R0
MOVW 12(SP), R1

View File

@ -16,6 +16,7 @@
MOVL $(0x10000 + ((code)<<5)), AX; JMP AX
TEXT syscall·Syscall(SB),NOSPLIT,$12-28
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL trap+0(FP), AX
MOVL a1+4(FP), BX

View File

@ -16,6 +16,7 @@
MOVL $(0x10000 + ((code)<<5)), AX; JMP AX
TEXT syscall·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL trap+0(FP), AX
MOVL a1+4(FP), DI

View File

@ -16,6 +16,7 @@
MOVW $(0x10000 + ((code)<<5)), R8; B (R8)
TEXT syscall·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
BL runtime·entersyscall(SB)
MOVW trap+0(FP), R8
MOVW a1+4(FP), R0

View File

@ -16,6 +16,7 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -40,6 +41,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -67,6 +69,7 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -97,6 +100,7 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@ -118,6 +122,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI

View File

@ -17,6 +17,7 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-56
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@ -40,6 +41,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@ -63,6 +65,7 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-104
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@ -95,6 +98,7 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@ -115,6 +119,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX

View File

@ -13,6 +13,7 @@
// func Syscall9(trap int32, a1, a2, a3, a4, a5, a6, a7, a8, a9 int64) (r1, r2, err int32)
TEXT ·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
@ -35,6 +36,7 @@ error:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
@ -60,6 +62,7 @@ error6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
@ -85,6 +88,7 @@ error9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
GO_ARGS
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
MOVW 8(FP), R2 // a2
@ -104,6 +108,7 @@ errorr:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
GO_ARGS
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
MOVW 8(FP), R2 // a2

View File

@ -16,6 +16,7 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-28
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -40,6 +41,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -67,6 +69,7 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -97,6 +100,7 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@ -118,6 +122,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI

View File

@ -17,6 +17,7 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-56
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@ -40,6 +41,7 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@ -63,6 +65,7 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-104
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@ -95,6 +98,7 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@ -115,6 +119,7 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX

View File

@ -18,6 +18,7 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-32
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -53,6 +54,7 @@ copyresult3:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-44
GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@ -91,6 +93,7 @@ copyresult4:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@ -106,6 +109,7 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-28
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI

View File

@ -17,6 +17,7 @@
//func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
TEXT ·Syscall(SB),NOSPLIT,$0-64
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
@ -52,6 +53,7 @@ copyresult3:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-88
GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
@ -90,6 +92,7 @@ copyresult4:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
GO_ARGS
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
LEAQ 16(SP), SI
@ -105,6 +108,7 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-56
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
GO_ARGS
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
LEAQ 16(SP), SI