Skip to contentSkip to conversation

common-user: Fix tail calls to safe_syscall_set_errno_tail

PATCH Applied Richard Henderson 3 participants 4 messages Jan 4, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common-user: Fix tail calls to safe_syscall_set_errno_tail

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.

---
 common-user/host/i386/safe-syscall.inc.S   | 1 +
 common-user/host/mips/safe-syscall.inc.S   | 1 +
 common-user/host/x86_64/safe-syscall.inc.S | 1 +
 3 files changed, 3 insertions(+)
common-user/host/i386/safe-syscall.inc.S +1 -0
index baf5400a29..9c45e56e48 100644
@@ -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
common-user/host/mips/safe-syscall.inc.S +1 -0
index fc75a337d1..6a44614970 100644
@@ -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
 
common-user/host/x86_64/safe-syscall.inc.S +1 -0
index a20927a783..d1a67a303a 100644
@@ -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
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Richard Henderson

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

Using Laurent alias [*]:

Fixes a3310c0397e ("linux-user: Move syscall error detection into

safe_syscall_base")

[*] https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 7 lines
---
 common-user/host/i386/safe-syscall.inc.S   | 1 +
 common-user/host/mips/safe-syscall.inc.S   | 1 +
 common-user/host/x86_64/safe-syscall.inc.S | 1 +
 3 files changed, 3 insertions(+)
Tested-by on v1 1/1
#2 lore raw
In reply to Richard Henderson

Le 04/01/2022 à 20:04, Richard Henderson a écrit :

Quoted 4 lines

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.

Quoted 9 lines
---
  common-user/host/i386/safe-syscall.inc.S   | 1 +
  common-user/host/mips/safe-syscall.inc.S   | 1 +
  common-user/host/x86_64/safe-syscall.inc.S | 1 +
  3 files changed, 3 insertions(+)
author Applied
#3 lore raw
In reply to Richard Henderson
Quoted 4 lines · Richard Henderson

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.

Quoted 8 lines
---
  common-user/host/i386/safe-syscall.inc.S   | 1 +
  common-user/host/mips/safe-syscall.inc.S   | 1 +
  common-user/host/x86_64/safe-syscall.inc.S | 1 +
  3 files changed, 3 insertions(+)

Queued to tcg-next.

r~