Skip to content

Commit 808d40d

Browse files
committed
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 534a911 commit 808d40d

10 files changed

+10
-242
lines changed

src/syscall/asm_linux_386.s

-26
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,6 @@
1313
// instead of the glibc-specific "CALL 0x10(GS)".
1414
#define INVOKE_SYSCALL INT $0x80
1515

16-
// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
17-
TEXT ·Syscall6(SB),NOSPLIT,$0-40
18-
CALL runtime·entersyscall(SB)
19-
MOVL trap+0(FP), AX // syscall entry
20-
MOVL a1+4(FP), BX
21-
MOVL a2+8(FP), CX
22-
MOVL a3+12(FP), DX
23-
MOVL a4+16(FP), SI
24-
MOVL a5+20(FP), DI
25-
MOVL a6+24(FP), BP
26-
INVOKE_SYSCALL
27-
CMPL AX, $0xfffff001
28-
JLS ok6
29-
MOVL $-1, r1+28(FP)
30-
MOVL $0, r2+32(FP)
31-
NEGL AX
32-
MOVL AX, err+36(FP)
33-
CALL runtime·exitsyscall(SB)
34-
RET
35-
ok6:
36-
MOVL AX, r1+28(FP)
37-
MOVL DX, r2+32(FP)
38-
MOVL $0, err+36(FP)
39-
CALL runtime·exitsyscall(SB)
40-
RET
41-
4216
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
4317
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-16
4418
MOVL trap+0(FP), AX // syscall entry

src/syscall/asm_linux_amd64.s

-26
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,6 @@
1111

1212
#define SYS_gettimeofday 96
1313

14-
// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
15-
TEXT ·Syscall6(SB),NOSPLIT,$0-80
16-
CALL runtime·entersyscall<ABIInternal>(SB)
17-
MOVQ a1+8(FP), DI
18-
MOVQ a2+16(FP), SI
19-
MOVQ a3+24(FP), DX
20-
MOVQ a4+32(FP), R10
21-
MOVQ a5+40(FP), R8
22-
MOVQ a6+48(FP), R9
23-
MOVQ trap+0(FP), AX // syscall entry
24-
SYSCALL
25-
CMPQ AX, $0xfffffffffffff001
26-
JLS ok6
27-
MOVQ $-1, r1+56(FP)
28-
MOVQ $0, r2+64(FP)
29-
NEGQ AX
30-
MOVQ AX, err+72(FP)
31-
CALL runtime·exitsyscall<ABIInternal>(SB)
32-
RET
33-
ok6:
34-
MOVQ AX, r1+56(FP)
35-
MOVQ DX, r2+64(FP)
36-
MOVQ $0, err+72(FP)
37-
CALL runtime·exitsyscall<ABIInternal>(SB)
38-
RET
39-
4014
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
4115
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
4216
MOVQ a1+8(FP), DI

src/syscall/asm_linux_arm.s

-31
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,6 @@
99
// System calls for arm, Linux
1010
//
1111

12-
// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
13-
// Actually Syscall5 but the rest of the code expects it to be named Syscall6.
14-
TEXT ·Syscall6(SB),NOSPLIT,$0-40
15-
BL runtime·entersyscall(SB)
16-
MOVW trap+0(FP), R7 // syscall entry
17-
MOVW a1+4(FP), R0
18-
MOVW a2+8(FP), R1
19-
MOVW a3+12(FP), R2
20-
MOVW a4+16(FP), R3
21-
MOVW a5+20(FP), R4
22-
MOVW a6+24(FP), R5
23-
SWI $0
24-
MOVW $0xfffff001, R6
25-
CMP R6, R0
26-
BLS ok6
27-
MOVW $-1, R1
28-
MOVW R1, r1+28(FP)
29-
MOVW $0, R2
30-
MOVW R2, r2+32(FP)
31-
RSB $0, R0, R0
32-
MOVW R0, err+36(FP)
33-
BL runtime·exitsyscall(SB)
34-
RET
35-
ok6:
36-
MOVW R0, r1+28(FP)
37-
MOVW R1, r2+32(FP)
38-
MOVW $0, R0
39-
MOVW R0, err+36(FP)
40-
BL runtime·exitsyscall(SB)
41-
RET
42-
4312
#define SYS__LLSEEK 140 /* from zsysnum_linux_arm.go */
4413
// func seek(fd int, offset int64, whence int) (newoffset int64, errno int)
4514
// Implemented in assembly to avoid allocation when

src/syscall/asm_linux_arm64.s

-26
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,6 @@
44

55
#include "textflag.h"
66

7-
TEXT ·Syscall6(SB),NOSPLIT,$0-80
8-
BL runtime·entersyscall<ABIInternal>(SB)
9-
MOVD a1+8(FP), R0
10-
MOVD a2+16(FP), R1
11-
MOVD a3+24(FP), R2
12-
MOVD a4+32(FP), R3
13-
MOVD a5+40(FP), R4
14-
MOVD a6+48(FP), R5
15-
MOVD trap+0(FP), R8 // syscall entry
16-
SVC
17-
CMN $4095, R0
18-
BCC ok
19-
MOVD $-1, R4
20-
MOVD R4, r1+56(FP) // r1
21-
MOVD ZR, r2+64(FP) // r2
22-
NEG R0, R0
23-
MOVD R0, err+72(FP) // errno
24-
BL runtime·exitsyscall<ABIInternal>(SB)
25-
RET
26-
ok:
27-
MOVD R0, r1+56(FP) // r1
28-
MOVD R1, r2+64(FP) // r2
29-
MOVD ZR, err+72(FP) // errno
30-
BL runtime·exitsyscall<ABIInternal>(SB)
31-
RET
32-
337
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
348
TEXT ·rawVforkSyscall(SB),NOSPLIT,$0-32
359
MOVD a1+8(FP), R0

src/syscall/asm_linux_mips64x.s

-24
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,6 @@
1010
// System calls for mips64, Linux
1111
//
1212

13-
TEXT ·Syscall6(SB),NOSPLIT,$0-80
14-
JAL runtime·entersyscall(SB)
15-
MOVV a1+8(FP), R4
16-
MOVV a2+16(FP), R5
17-
MOVV a3+24(FP), R6
18-
MOVV a4+32(FP), R7
19-
MOVV a5+40(FP), R8
20-
MOVV a6+48(FP), R9
21-
MOVV trap+0(FP), R2 // syscall entry
22-
SYSCALL
23-
BEQ R7, ok6
24-
MOVV $-1, R1
25-
MOVV R1, r1+56(FP) // r1
26-
MOVV R0, r2+64(FP) // r2
27-
MOVV R2, err+72(FP) // errno
28-
JAL runtime·exitsyscall(SB)
29-
RET
30-
ok6:
31-
MOVV R2, r1+56(FP) // r1
32-
MOVV R3, r2+64(FP) // r2
33-
MOVV R0, err+72(FP) // errno
34-
JAL runtime·exitsyscall(SB)
35-
RET
36-
3713
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
3814
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
3915
MOVV a1+8(FP), R4

src/syscall/asm_linux_mipsx.s

-30
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,6 @@
1111
// System calls for mips, Linux
1212
//
1313

14-
// func Syscall6(trap trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
15-
// 5th and 6th arg go at sp+16, sp+20.
16-
// Note that frame size of 20 means that 24 bytes gets reserved on stack.
17-
TEXT ·Syscall6(SB),NOSPLIT,$20-40
18-
NO_LOCAL_POINTERS
19-
JAL runtime·entersyscall(SB)
20-
MOVW a1+4(FP), R4
21-
MOVW a2+8(FP), R5
22-
MOVW a3+12(FP), R6
23-
MOVW a4+16(FP), R7
24-
MOVW a5+20(FP), R8
25-
MOVW a6+24(FP), R9
26-
MOVW R8, 16(R29)
27-
MOVW R9, 20(R29)
28-
MOVW trap+0(FP), R2 // syscall entry
29-
SYSCALL
30-
BEQ R7, ok6
31-
MOVW $-1, R1
32-
MOVW R1, r1+28(FP) // r1
33-
MOVW R0, r2+32(FP) // r2
34-
MOVW R2, err+36(FP) // errno
35-
JAL runtime·exitsyscall(SB)
36-
RET
37-
ok6:
38-
MOVW R2, r1+28(FP) // r1
39-
MOVW R3, r2+32(FP) // r2
40-
MOVW R0, err+36(FP) // errno
41-
JAL runtime·exitsyscall(SB)
42-
RET
43-
4414
// func Syscall9(trap trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, err uintptr);
4515
// Actually Syscall8 but the rest of the code expects it to be named Syscall9.
4616
TEXT ·Syscall9(SB),NOSPLIT,$28-52

src/syscall/asm_linux_ppc64x.s

-24
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,6 @@
1010
// System calls for ppc64, Linux
1111
//
1212

13-
TEXT ·Syscall6(SB),NOSPLIT,$0-80
14-
BL runtime·entersyscall<ABIInternal>(SB)
15-
MOVD a1+8(FP), R3
16-
MOVD a2+16(FP), R4
17-
MOVD a3+24(FP), R5
18-
MOVD a4+32(FP), R6
19-
MOVD a5+40(FP), R7
20-
MOVD a6+48(FP), R8
21-
MOVD trap+0(FP), R9 // syscall entry
22-
SYSCALL R9
23-
BVC ok6
24-
MOVD $-1, R4
25-
MOVD R4, r1+56(FP) // r1
26-
MOVD R0, r2+64(FP) // r2
27-
MOVD R3, err+72(FP) // errno
28-
BL runtime·exitsyscall<ABIInternal>(SB)
29-
RET
30-
ok6:
31-
MOVD R3, r1+56(FP) // r1
32-
MOVD R0, r2+64(FP) // r2
33-
MOVD R0, err+72(FP) // errno
34-
BL runtime·exitsyscall<ABIInternal>(SB)
35-
RET
36-
3713
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
3814
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
3915
MOVD a1+8(FP), R3

src/syscall/asm_linux_riscv64.s

-27
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,6 @@
88
// System calls for riscv64, Linux
99
//
1010

11-
// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
12-
TEXT ·Syscall6(SB),NOSPLIT,$0-80
13-
CALL runtime·entersyscall(SB)
14-
MOV a1+8(FP), A0
15-
MOV a2+16(FP), A1
16-
MOV a3+24(FP), A2
17-
MOV a4+32(FP), A3
18-
MOV a5+40(FP), A4
19-
MOV a6+48(FP), A5
20-
MOV trap+0(FP), A7 // syscall entry
21-
ECALL
22-
MOV $-4096, T0
23-
BLTU T0, A0, err
24-
MOV A0, r1+56(FP) // r1
25-
MOV A1, r2+64(FP) // r2
26-
MOV ZERO, err+72(FP) // errno
27-
CALL runtime·exitsyscall(SB)
28-
RET
29-
err:
30-
MOV $-1, T0
31-
MOV T0, r1+56(FP) // r1
32-
MOV ZERO, r2+64(FP) // r2
33-
SUB A0, ZERO, A0
34-
MOV A0, err+72(FP) // errno
35-
CALL runtime·exitsyscall(SB)
36-
RET
37-
3811
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
3912
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
4013
MOV a1+8(FP), A0

src/syscall/asm_linux_s390x.s

-26
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,6 @@
88
// System calls for s390x, Linux
99
//
1010

11-
// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
12-
TEXT ·Syscall6(SB),NOSPLIT,$0-80
13-
BL runtime·entersyscall(SB)
14-
MOVD a1+8(FP), R2
15-
MOVD a2+16(FP), R3
16-
MOVD a3+24(FP), R4
17-
MOVD a4+32(FP), R5
18-
MOVD a5+40(FP), R6
19-
MOVD a6+48(FP), R7
20-
MOVD trap+0(FP), R1 // syscall entry
21-
SYSCALL
22-
MOVD $0xfffffffffffff001, R8
23-
CMPUBLT R2, R8, ok6
24-
MOVD $-1, r1+56(FP)
25-
MOVD $0, r2+64(FP)
26-
NEG R2, R2
27-
MOVD R2, err+72(FP) // errno
28-
BL runtime·exitsyscall(SB)
29-
RET
30-
ok6:
31-
MOVD R2, r1+56(FP)
32-
MOVD R3, r2+64(FP)
33-
MOVD $0, err+72(FP) // errno
34-
BL runtime·exitsyscall(SB)
35-
RET
36-
3711
// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
3812
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
3913
MOVD $0, R2

src/syscall/syscall_linux.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import (
1616
"unsafe"
1717
)
1818

19-
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
20-
2119
// N.B. RawSyscall6 is provided via linkname by runtime/internal/syscall.
2220
//
2321
// 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) {
8078
return
8179
}
8280

81+
//go:uintptrkeepalive
82+
//go:nosplit
83+
//go:linkname Syscall6
84+
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
85+
runtime_entersyscall()
86+
r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6)
87+
runtime_exitsyscall()
88+
return
89+
}
90+
8391
func rawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr)
8492

8593
/*

0 commit comments

Comments
 (0)