diff --git a/src/syscall/asm_linux_386.s b/src/syscall/asm_linux_386.s index e86a859f4e2..ae0047b6fb6 100644 --- a/src/syscall/asm_linux_386.s +++ b/src/syscall/asm_linux_386.s @@ -13,6 +13,32 @@ // 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 3206a45d5dd..ea939b39f0f 100644 --- a/src/syscall/asm_linux_amd64.s +++ b/src/syscall/asm_linux_amd64.s @@ -11,6 +11,32 @@ #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(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(SB) + RET +ok6: + MOVQ AX, r1+56(FP) + MOVQ DX, r2+64(FP) + MOVQ $0, err+72(FP) + CALL runtime·exitsyscall(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 32522205622..6f9a612fa1b 100644 --- a/src/syscall/asm_linux_arm.s +++ b/src/syscall/asm_linux_arm.s @@ -9,6 +9,37 @@ // 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 be78ac8ac48..c9d28d301a5 100644 --- a/src/syscall/asm_linux_arm64.s +++ b/src/syscall/asm_linux_arm64.s @@ -4,6 +4,32 @@ #include "textflag.h" +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + BL runtime·entersyscall(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(SB) + RET +ok: + MOVD R0, r1+56(FP) // r1 + MOVD R1, r2+64(FP) // r2 + MOVD ZR, err+72(FP) // errno + BL runtime·exitsyscall(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 fadf1939e0b..994d7779fbe 100644 --- a/src/syscall/asm_linux_mips64x.s +++ b/src/syscall/asm_linux_mips64x.s @@ -10,6 +10,30 @@ // 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 b8cae96b1a4..8c45861d641 100644 --- a/src/syscall/asm_linux_mipsx.s +++ b/src/syscall/asm_linux_mipsx.s @@ -11,6 +11,36 @@ // 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 89cc1c2b0bf..d60e4722269 100644 --- a/src/syscall/asm_linux_ppc64x.s +++ b/src/syscall/asm_linux_ppc64x.s @@ -10,6 +10,30 @@ // System calls for ppc64, Linux // +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + BL runtime·entersyscall(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(SB) + RET +ok6: + MOVD R3, r1+56(FP) // r1 + MOVD R0, r2+64(FP) // r2 + MOVD R0, 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 a1+8(FP), R3 diff --git a/src/syscall/asm_linux_riscv64.s b/src/syscall/asm_linux_riscv64.s index 0fc1f73581b..60b5cdbc1ce 100644 --- a/src/syscall/asm_linux_riscv64.s +++ b/src/syscall/asm_linux_riscv64.s @@ -8,6 +8,33 @@ // 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 c3631c12614..14dabd85c23 100644 --- a/src/syscall/asm_linux_s390x.s +++ b/src/syscall/asm_linux_s390x.s @@ -8,6 +8,32 @@ // 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 a796d170666..57e47697316 100644 --- a/src/syscall/syscall_linux.go +++ b/src/syscall/syscall_linux.go @@ -16,6 +16,8 @@ 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 @@ -66,16 +68,6 @@ 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) /*