OSDN Git Service

common-user: Fix tail calls to safe_syscall_set_errno_tail
authorRichard Henderson <richard.henderson@linaro.org>
Tue, 4 Jan 2022 19:00:35 +0000 (11:00 -0800)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 4 Jan 2022 23:41:03 +0000 (15:41 -0800)
For the ABIs in which the syscall return register is not
also the first function argument register, move the errno
value into the correct place.

Fixes: a3310c0397e2 ("linux-user: Move syscall error detection into safe_syscall_base")
Reported-by: Laurent Vivier <laurent@vivier.eu>
Tested-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220104190454.542225-1-richard.henderson@linaro.org>

common-user/host/i386/safe-syscall.inc.S
common-user/host/mips/safe-syscall.inc.S
common-user/host/x86_64/safe-syscall.inc.S

index baf5400..9c45e56 100644 (file)
@@ -120,6 +120,7 @@ safe_syscall_end:
         pop     %ebp
         .cfi_adjust_cfa_offset -4
         .cfi_restore ebp
+        mov     %eax, (%esp)
         jmp     safe_syscall_set_errno_tail
 
         .cfi_endproc
index fc75a33..6a44614 100644 (file)
@@ -141,6 +141,7 @@ safe_syscall_end:
 1:      USE_ALT_CP(t0)
         SETUP_GPX(t1)
         SETUP_GPX64(t0, t1)
+        move    a0, v0
         PTR_LA  t9, safe_syscall_set_errno_tail
         jr      t9
 
index a20927a..d1a67a3 100644 (file)
@@ -99,6 +99,7 @@ safe_syscall_end:
 1:      pop     %rbp
         .cfi_def_cfa_offset 8
         .cfi_restore rbp
+        mov     %eax, %edi
         jmp     safe_syscall_set_errno_tail
         .cfi_endproc