From 6c1b26c55098eae66ce95ab7c3712ab6cbfff2b7 Mon Sep 17 00:00:00 2001 From: Guoqi Chen Date: Fri, 10 Jun 2022 20:06:09 +0800 Subject: [PATCH] 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 Reviewed-by: Austin Clements Reviewed-by: David Chase --- unix/asm_linux_loong64.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/asm_linux_loong64.s b/unix/asm_linux_loong64.s index 6abd48ee..56535728 100644 --- a/unix/asm_linux_loong64.s +++ b/unix/asm_linux_loong64.s @@ -30,7 +30,7 @@ TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 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 @@ TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 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