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>
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
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
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
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
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