unix: always zero the higher bits of return value on linux/loong64 syscalls
All loong64 syscalls return values only via R4/A0, and R5/A1 may contain
unrelated content. Always zero the second return value.
Change-Id: Ic889f33158c4e4999bd94bd768d1094e95bc6421
Reviewed-on: https://go-review.googlesource.com/c/sys/+/411634
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
diff --git a/unix/asm_linux_loong64.s b/unix/asm_linux_loong64.s
index 6abd48e..5653572 100644
--- a/unix/asm_linux_loong64.s
+++ b/unix/asm_linux_loong64.s
@@ -30,7 +30,7 @@
MOVV trap+0(FP), R11 // syscall entry
SYSCALL
MOVV R4, r1+32(FP)
- MOVV R5, r2+40(FP)
+ MOVV R0, r2+40(FP) // r2 is not used. Always set to 0
JAL runtime·exitsyscall(SB)
RET
@@ -50,5 +50,5 @@
MOVV trap+0(FP), R11 // syscall entry
SYSCALL
MOVV R4, r1+32(FP)
- MOVV R5, r2+40(FP)
+ MOVV R0, r2+40(FP) // r2 is not used. Always set to 0
RET