mirror of
https://github.com/golang/go
synced 2024-10-02 22:25:08 +00:00
syscall, runtime/internal/syscall: zero r2 before mips linux syscalls
All mips variant perform syscalls similarly. R2 (v0) holds r1 and R3 (v1) holds r2 of a syscall. The latter is only used by 2-ret syscalls. A 1-ret syscall would not touch R3 but keeps it as is, making r2 be a random value. Always reset it to 0 before SYSCALL to fix the issue. Fixes #56426 Change-Id: Ie49965c0c3c224c4a895703ac659205cd040ff56 Reviewed-on: https://go-review.googlesource.com/c/go/+/452975 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Meng Zhuo <mzh@golangcn.org>
This commit is contained in:
parent
7a9ce74655
commit
2c7c98c3ad
|
@ -15,6 +15,7 @@ TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|||
MOVV a4+32(FP), R7
|
||||
MOVV a5+40(FP), R8
|
||||
MOVV a6+48(FP), R9
|
||||
MOVV R0, R3 // reset R3 to 0 as 1-ret SYSCALL keeps it
|
||||
SYSCALL
|
||||
BEQ R7, ok
|
||||
MOVV $-1, R1
|
||||
|
|
|
@ -20,6 +20,7 @@ TEXT ·Syscall6(SB),NOSPLIT,$20-40
|
|||
MOVW a6+24(FP), R9
|
||||
MOVW R8, 16(R29)
|
||||
MOVW R9, 20(R29)
|
||||
MOVW R0, R3 // reset R3 to 0 as 1-ret SYSCALL keeps it
|
||||
SYSCALL
|
||||
BEQ R7, ok
|
||||
MOVW $-1, R1
|
||||
|
|
|
@ -38,7 +38,8 @@ TEXT ·rawSyscallNoError(SB),NOSPLIT,$0-48
|
|||
MOVV R0, R8
|
||||
MOVV R0, R9
|
||||
MOVV trap+0(FP), R2 // syscall entry
|
||||
MOVV R0, R3 // reset R3 to zero as 1-ret SYSCALL keeps it
|
||||
SYSCALL
|
||||
MOVV R2, r1+32(FP)
|
||||
MOVV R3, r2+40(FP)
|
||||
MOVV R2, r1+32(FP) // r1
|
||||
MOVV R3, r2+40(FP) // r2
|
||||
RET
|
||||
|
|
|
@ -29,6 +29,7 @@ TEXT ·Syscall9(SB),NOSPLIT,$28-52
|
|||
MOVW R10, 24(R29)
|
||||
MOVW R11, 28(R29)
|
||||
MOVW trap+0(FP), R2 // syscall entry
|
||||
MOVW R0, R3 // reset R3 to zero as 1-ret SYSCALL keeps it
|
||||
SYSCALL
|
||||
BEQ R7, ok9
|
||||
MOVW $-1, R1
|
||||
|
@ -66,6 +67,7 @@ TEXT ·rawSyscallNoError(SB),NOSPLIT,$20-24
|
|||
MOVW a2+8(FP), R5
|
||||
MOVW a3+12(FP), R6
|
||||
MOVW trap+0(FP), R2 // syscall entry
|
||||
MOVW R0, R3 // reset R3 to zero as 1-ret SYSCALL keeps it
|
||||
SYSCALL
|
||||
MOVW R2, r1+16(FP) // r1
|
||||
MOVW R3, r2+20(FP) // r2
|
||||
|
|
Loading…
Reference in a new issue