aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2022-02-24 17:00:12 -0500
committerMichael Pratt <mpratt@google.com>2022-04-22 19:02:29 +0000
commit808d40d7809a46703f43fc2d6911957135f4563c (patch)
tree353c044af0a8a44b03a78521420abe9fd3f51755
parent534a911338a05b74b5c419080d563c6ae06d6dc8 (diff)
downloadgo-808d40d7809a46703f43fc2d6911957135f4563c.tar.gz
go-808d40d7809a46703f43fc2d6911957135f4563c.zip
syscall: define Syscall6 in terms of RawSyscall6 on linux
This is an exact copy of CL 388478 after fixing #52472 in CL 401654. For #51087 For #52472 Change-Id: I6c6bd7ddcab1512c682e6b44f61c7bcde97f5c58 Reviewed-on: https://go-review.googlesource.com/c/go/+/401655 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
-rw-r--r--src/syscall/asm_linux_386.s26
-rw-r--r--src/syscall/asm_linux_amd64.s26
-rw-r--r--src/syscall/asm_linux_arm.s31
-rw-r--r--src/syscall/asm_linux_arm64.s26
-rw-r--r--src/syscall/asm_linux_mips64x.s24
-rw-r--r--src/syscall/asm_linux_mipsx.s30
-rw-r--r--src/syscall/asm_linux_ppc64x.s24
-rw-r--r--src/syscall/asm_linux_riscv64.s27
-rw-r--r--src/syscall/asm_linux_s390x.s26
-rw-r--r--src/syscall/syscall_linux.go12
10 files changed, 10 insertions, 242 deletions
diff --git a/src/syscall/asm_linux_386.s b/src/syscall/asm_linux_386.s
index ae0047b6fb..e86a859f4e 100644
--- a/src/syscall/asm_linux_386.s
+++ b/src/syscall/asm_linux_386.s
@@ -13,32 +13,6 @@
// instead of the glibc-specific "CALL 0x10(GS)".
#define INVOKE_SYSCALL INT $0x80
-// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- CALL runtime·entersyscall(SB)
- MOVL trap+0(FP), AX // syscall entry
- MOVL a1+4(FP), BX
- MOVL a2+8(FP), CX
- MOVL a3+12(FP), DX
- MOVL a4+16(FP), SI
- MOVL a5+20(FP), DI
- MOVL a6+24(FP), BP
- INVOKE_SYSCALL
- CMPL AX, $0xfffff001
- JLS ok6
- MOVL $-1, r1+28(FP)
- MOVL $0, r2+32(FP)
- NEGL AX
- MOVL AX, err+36(FP)
- CALL runtime·exitsyscall(SB)
- RET
-ok6:
- MOVL AX, r1+28(FP)
- MOVL DX, r2+32(FP)
- MOVL $0, err+36(FP)
- CALL runtime·exitsyscall(SB)
- RET
-
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-16
MOVL trap+0(FP), AX // syscall entry
diff --git a/src/syscall/asm_linux_amd64.s b/src/syscall/asm_linux_amd64.s
index ea939b39f0..3206a45d5d 100644
--- a/src/syscall/asm_linux_amd64.s
+++ b/src/syscall/asm_linux_amd64.s
@@ -11,32 +11,6 @@
#define SYS_gettimeofday 96
-// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- CALL runtime·entersyscall<ABIInternal>(SB)
- MOVQ a1+8(FP), DI
- MOVQ a2+16(FP), SI
- MOVQ a3+24(FP), DX
- MOVQ a4+32(FP), R10
- MOVQ a5+40(FP), R8
- MOVQ a6+48(FP), R9
- MOVQ trap+0(FP), AX // syscall entry
- SYSCALL
- CMPQ AX, $0xfffffffffffff001
- JLS ok6
- MOVQ $-1, r1+56(FP)
- MOVQ $0, r2+64(FP)
- NEGQ AX
- MOVQ AX, err+72(FP)
- CALL runtime·exitsyscall<ABIInternal>(SB)
- RET
-ok6:
- MOVQ AX, r1+56(FP)
- MOVQ DX, r2+64(FP)
- MOVQ $0, err+72(FP)
- CALL runtime·exitsyscall<ABIInternal>(SB)
- RET
-
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
MOVQ a1+8(FP), DI
diff --git a/src/syscall/asm_linux_arm.s b/src/syscall/asm_linux_arm.s
index 6f9a612fa1..3252220562 100644
--- a/src/syscall/asm_linux_arm.s
+++ b/src/syscall/asm_linux_arm.s
@@ -9,37 +9,6 @@
// System calls for arm, Linux
//
-// 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
- BL runtime·entersyscall(SB)
- MOVW trap+0(FP), R7 // 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 $0
- MOVW $0xfffff001, R6
- CMP R6, R0
- BLS ok6
- MOVW $-1, R1
- MOVW R1, r1+28(FP)
- MOVW $0, R2
- MOVW R2, r2+32(FP)
- RSB $0, R0, R0
- MOVW R0, err+36(FP)
- BL runtime·exitsyscall(SB)
- RET
-ok6:
- MOVW R0, r1+28(FP)
- MOVW R1, r2+32(FP)
- MOVW $0, R0
- MOVW R0, err+36(FP)
- BL runtime·exitsyscall(SB)
- RET
-
#define SYS__LLSEEK 140 /* from zsysnum_linux_arm.go */
// func seek(fd int, offset int64, whence int) (newoffset int64, errno int)
// Implemented in assembly to avoid allocation when
diff --git a/src/syscall/asm_linux_arm64.s b/src/syscall/asm_linux_arm64.s
index c9d28d301a..be78ac8ac4 100644
--- a/src/syscall/asm_linux_arm64.s
+++ b/src/syscall/asm_linux_arm64.s
@@ -4,32 +4,6 @@
#include "textflag.h"
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- BL runtime·entersyscall<ABIInternal>(SB)
- MOVD a1+8(FP), R0
- MOVD a2+16(FP), R1
- MOVD a3+24(FP), R2
- MOVD a4+32(FP), R3
- MOVD a5+40(FP), R4
- MOVD a6+48(FP), R5
- MOVD trap+0(FP), R8 // syscall entry
- SVC
- CMN $4095, R0
- BCC ok
- MOVD $-1, R4
- MOVD R4, r1+56(FP) // r1
- MOVD ZR, r2+64(FP) // r2
- NEG R0, R0
- MOVD R0, err+72(FP) // errno
- BL runtime·exitsyscall<ABIInternal>(SB)
- RET
-ok:
- MOVD R0, r1+56(FP) // r1
- MOVD R1, r2+64(FP) // r2
- MOVD ZR, err+72(FP) // errno
- BL runtime·exitsyscall<ABIInternal>(SB)
- RET
-
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
TEXT ·rawVforkSyscall(SB),NOSPLIT,$0-32
MOVD a1+8(FP), R0
diff --git a/src/syscall/asm_linux_mips64x.s b/src/syscall/asm_linux_mips64x.s
index 994d7779fb..fadf1939e0 100644
--- a/src/syscall/asm_linux_mips64x.s
+++ b/src/syscall/asm_linux_mips64x.s
@@ -10,30 +10,6 @@
// System calls for mips64, Linux
//
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JAL runtime·entersyscall(SB)
- MOVV a1+8(FP), R4
- MOVV a2+16(FP), R5
- MOVV a3+24(FP), R6
- MOVV a4+32(FP), R7
- MOVV a5+40(FP), R8
- MOVV a6+48(FP), R9
- MOVV trap+0(FP), R2 // syscall entry
- SYSCALL
- BEQ R7, ok6
- MOVV $-1, R1
- MOVV R1, r1+56(FP) // r1
- MOVV R0, r2+64(FP) // r2
- MOVV R2, err+72(FP) // errno
- JAL runtime·exitsyscall(SB)
- RET
-ok6:
- MOVV R2, r1+56(FP) // r1
- MOVV R3, r2+64(FP) // r2
- MOVV R0, err+72(FP) // errno
- JAL runtime·exitsyscall(SB)
- RET
-
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
MOVV a1+8(FP), R4
diff --git a/src/syscall/asm_linux_mipsx.s b/src/syscall/asm_linux_mipsx.s
index 8c45861d64..b8cae96b1a 100644
--- a/src/syscall/asm_linux_mipsx.s
+++ b/src/syscall/asm_linux_mipsx.s
@@ -11,36 +11,6 @@
// System calls for mips, Linux
//
-// func Syscall6(trap trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
-// 5th and 6th arg go at sp+16, sp+20.
-// Note that frame size of 20 means that 24 bytes gets reserved on stack.
-TEXT ·Syscall6(SB),NOSPLIT,$20-40
- NO_LOCAL_POINTERS
- JAL runtime·entersyscall(SB)
- MOVW a1+4(FP), R4
- MOVW a2+8(FP), R5
- MOVW a3+12(FP), R6
- MOVW a4+16(FP), R7
- MOVW a5+20(FP), R8
- MOVW a6+24(FP), R9
- MOVW R8, 16(R29)
- MOVW R9, 20(R29)
- MOVW trap+0(FP), R2 // syscall entry
- SYSCALL
- BEQ R7, ok6
- MOVW $-1, R1
- MOVW R1, r1+28(FP) // r1
- MOVW R0, r2+32(FP) // r2
- MOVW R2, err+36(FP) // errno
- JAL runtime·exitsyscall(SB)
- RET
-ok6:
- MOVW R2, r1+28(FP) // r1
- MOVW R3, r2+32(FP) // r2
- MOVW R0, err+36(FP) // errno
- JAL runtime·exitsyscall(SB)
- RET
-
// func Syscall9(trap trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, err uintptr);
// Actually Syscall8 but the rest of the code expects it to be named Syscall9.
TEXT ·Syscall9(SB),NOSPLIT,$28-52
diff --git a/src/syscall/asm_linux_ppc64x.s b/src/syscall/asm_linux_ppc64x.s
index d60e472226..89cc1c2b0b 100644
--- a/src/syscall/asm_linux_ppc64x.s
+++ b/src/syscall/asm_linux_ppc64x.s
@@ -10,30 +10,6 @@
// System calls for ppc64, Linux
//
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- BL runtime·entersyscall<ABIInternal>(SB)
- MOVD a1+8(FP), R3
- MOVD a2+16(FP), R4
- MOVD a3+24(FP), R5
- MOVD a4+32(FP), R6
- MOVD a5+40(FP), R7
- MOVD a6+48(FP), R8
- MOVD trap+0(FP), R9 // syscall entry
- SYSCALL R9
- BVC ok6
- MOVD $-1, R4
- MOVD R4, r1+56(FP) // r1
- MOVD R0, r2+64(FP) // r2
- MOVD R3, err+72(FP) // errno
- BL runtime·exitsyscall<ABIInternal>(SB)
- RET
-ok6:
- MOVD R3, r1+56(FP) // r1
- MOVD R0, r2+64(FP) // r2
- MOVD R0, err+72(FP) // errno
- BL runtime·exitsyscall<ABIInternal>(SB)
- RET
-
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
MOVD a1+8(FP), R3
diff --git a/src/syscall/asm_linux_riscv64.s b/src/syscall/asm_linux_riscv64.s
index 60b5cdbc1c..0fc1f73581 100644
--- a/src/syscall/asm_linux_riscv64.s
+++ b/src/syscall/asm_linux_riscv64.s
@@ -8,33 +8,6 @@
// System calls for riscv64, Linux
//
-// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- CALL runtime·entersyscall(SB)
- MOV a1+8(FP), A0
- MOV a2+16(FP), A1
- MOV a3+24(FP), A2
- MOV a4+32(FP), A3
- MOV a5+40(FP), A4
- MOV a6+48(FP), A5
- MOV trap+0(FP), A7 // syscall entry
- ECALL
- MOV $-4096, T0
- BLTU T0, A0, err
- MOV A0, r1+56(FP) // r1
- MOV A1, r2+64(FP) // r2
- MOV ZERO, err+72(FP) // errno
- CALL runtime·exitsyscall(SB)
- RET
-err:
- MOV $-1, T0
- MOV T0, r1+56(FP) // r1
- MOV ZERO, r2+64(FP) // r2
- SUB A0, ZERO, A0
- MOV A0, err+72(FP) // errno
- CALL runtime·exitsyscall(SB)
- RET
-
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
MOV a1+8(FP), A0
diff --git a/src/syscall/asm_linux_s390x.s b/src/syscall/asm_linux_s390x.s
index 14dabd85c2..c3631c1261 100644
--- a/src/syscall/asm_linux_s390x.s
+++ b/src/syscall/asm_linux_s390x.s
@@ -8,32 +8,6 @@
// System calls for s390x, Linux
//
-// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R2
- MOVD a2+16(FP), R3
- MOVD a3+24(FP), R4
- MOVD a4+32(FP), R5
- MOVD a5+40(FP), R6
- MOVD a6+48(FP), R7
- MOVD trap+0(FP), R1 // syscall entry
- SYSCALL
- MOVD $0xfffffffffffff001, R8
- CMPUBLT R2, R8, ok6
- MOVD $-1, r1+56(FP)
- MOVD $0, r2+64(FP)
- NEG R2, R2
- MOVD R2, err+72(FP) // errno
- BL runtime·exitsyscall(SB)
- RET
-ok6:
- MOVD R2, r1+56(FP)
- MOVD R3, r2+64(FP)
- MOVD $0, err+72(FP) // errno
- BL runtime·exitsyscall(SB)
- RET
-
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
MOVD $0, R2
diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go
index 999ca5bb7f..f9adecdd5e 100644
--- a/src/syscall/syscall_linux.go
+++ b/src/syscall/syscall_linux.go
@@ -16,8 +16,6 @@ import (
"unsafe"
)
-func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
-
// N.B. RawSyscall6 is provided via linkname by runtime/internal/syscall.
//
// Errno is uintptr and thus compatible with the runtime/internal/syscall
@@ -80,6 +78,16 @@ func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
return
}
+//go:uintptrkeepalive
+//go:nosplit
+//go:linkname Syscall6
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
+ runtime_entersyscall()
+ r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6)
+ runtime_exitsyscall()
+ return
+}
+
func rawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr)
/*