]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: define Syscall6 in terms of RawSyscall6 on linux
authorMichael Pratt <mpratt@google.com>
Thu, 24 Feb 2022 22:00:12 +0000 (17:00 -0500)
committerMichael Pratt <mpratt@google.com>
Fri, 22 Apr 2022 19:02:29 +0000 (19:02 +0000)
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>
src/syscall/asm_linux_386.s
src/syscall/asm_linux_amd64.s
src/syscall/asm_linux_arm.s
src/syscall/asm_linux_arm64.s
src/syscall/asm_linux_mips64x.s
src/syscall/asm_linux_mipsx.s
src/syscall/asm_linux_ppc64x.s
src/syscall/asm_linux_riscv64.s
src/syscall/asm_linux_s390x.s
src/syscall/syscall_linux.go

index ae0047b6fb6ed24ae04f37bebc4b3c362ea9c1d0..e86a859f4e294857375c51827203f5ef76753184 100644 (file)
 // 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
index ea939b39f0f77a79f0831cd5c223e95ffbbfb5b7..3206a45d5dd8b74e9f6d2fca1806b7faa52e8225 100644 (file)
 
 #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
index 6f9a612fa1bbeeba5ced7867121151818bf7edd1..3252220562206784e97ee392570b0e5079524006 100644 (file)
@@ -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
index c9d28d301a573ecf1da810c4e0e1911b526235cd..be78ac8ac48cb7780c3717fb56e63dab4b5b684f 100644 (file)
@@ -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
index 994d7779fbede17f84cea417813904d5caeea6d0..fadf1939e0b794600bfbf3c4fd6fcaf1ee82fcc4 100644 (file)
 // 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
index 8c45861d6411a4f6f843d18ec0cb5b12d450ddd8..b8cae96b1a414ff230d0bcd7fd011cd989f96a54 100644 (file)
 // 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
index d60e4722269e5bc7a5373cbebfbee931b5ae448f..89cc1c2b0bf8e6d795e9f8e58857e9c658bf4d81 100644 (file)
 // 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
index 60b5cdbc1ceae99140f7e8e592e4ce1fa5133123..0fc1f73581bb199a9ced9f439da17cdbcf077ec6 100644 (file)
@@ -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
index 14dabd85c23baaf7f4d9879aa0206e21a2e38664..c3631c12614f119012ee9115018651b23542abfd 100644 (file)
@@ -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
index 999ca5bb7f511bb6517e4d5fd26f9f6ad9cb021b..f9adecdd5e84799c9e331cb1dc8432d386a927d0 100644 (file)
@@ -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)
 
 /*