Skip to content

Commit 5b32a6f

Browse files
committed
runtime/internal/syscall: use ABIInternal for Syscall6 on amd64
For #51087. Change-Id: I25971760b63ec0d23d0f011521dd197d81a38976 Reviewed-on: https://go-review.googlesource.com/c/go/+/401096 Run-TryBot: Michael Pratt <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent a56e2f6 commit 5b32a6f

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

src/runtime/internal/syscall/asm_linux_amd64.s

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,42 @@
66

77
// func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
88
//
9-
// Syscall # in AX, args in DI SI DX R10 R8 R9, return in AX DX.
9+
// We need to convert to the syscall ABI.
10+
//
11+
// arg | ABIInternal | Syscall
12+
// ---------------------------
13+
// num | AX | AX
14+
// a1 | BX | DI
15+
// a2 | CX | SI
16+
// a3 | DI | DX
17+
// a4 | SI | R10
18+
// a5 | R8 | R8
19+
// a6 | R9 | R9
20+
//
21+
// r1 | AX | AX
22+
// r2 | BX | DX
23+
// err | CX | part of AX
1024
//
1125
// Note that this differs from "standard" ABI convention, which would pass 4th
1226
// arg in CX, not R10.
13-
TEXT ·Syscall6(SB),NOSPLIT,$0-80
14-
MOVQ num+0(FP), AX // syscall entry
15-
MOVQ a1+8(FP), DI
16-
MOVQ a2+16(FP), SI
17-
MOVQ a3+24(FP), DX
18-
MOVQ a4+32(FP), R10
19-
MOVQ a5+40(FP), R8
20-
MOVQ a6+48(FP), R9
27+
TEXT ·Syscall6<ABIInternal>(SB),NOSPLIT,$0
28+
// a6 already in R9.
29+
// a5 already in R8.
30+
MOVQ SI, R10 // a4
31+
MOVQ DI, DX // a3
32+
MOVQ CX, SI // a2
33+
MOVQ BX, DI // a1
34+
// num already in AX.
2135
SYSCALL
2236
CMPQ AX, $0xfffffffffffff001
2337
JLS ok
24-
MOVQ $-1, r1+56(FP)
25-
MOVQ $0, r2+64(FP)
2638
NEGQ AX
27-
MOVQ AX, errno+72(FP)
39+
MOVQ AX, CX // errno
40+
MOVQ $-1, AX // r1
41+
MOVQ $0, BX // r2
2842
RET
2943
ok:
30-
MOVQ AX, r1+56(FP)
31-
MOVQ DX, r2+64(FP)
32-
MOVQ $0, errno+72(FP)
44+
// r1 already in AX.
45+
MOVQ DX, BX // r2
46+
MOVQ $0, CX // errno
3347
RET

0 commit comments

Comments
 (0)