summaryrefslogtreecommitdiffstats
path: root/linux-user/host/arm
diff options
context:
space:
mode:
authorRichard Henderson2021-11-15 14:08:52 +0100
committerRichard Henderson2021-12-20 05:47:33 +0100
commita3310c0397e21df8f47cde3e55736104b9584d2d (patch)
tree2e550417028aea39886ba22f4b60fb9c88404630 /linux-user/host/arm
parentlinux-user: Untabify all safe-syscall.inc.S (diff)
downloadqemu-a3310c0397e21df8f47cde3e55736104b9584d2d.tar.gz
qemu-a3310c0397e21df8f47cde3e55736104b9584d2d.tar.xz
qemu-a3310c0397e21df8f47cde3e55736104b9584d2d.zip
linux-user: Move syscall error detection into safe_syscall_base
The current api from safe_syscall_base() is to return -errno, which is the interface provided by *some* linux kernel abis. The wrapper macro, safe_syscall(), detects error, stores into errno, and returns -1, to match the api of the system syscall(). For those kernel abis that do not return -errno natively, this leads to double syscall error detection. E.g. Linux ppc64, which sets the SO flag for error. Simplify the usage from C by moving the error detection into assembly, and usage from assembly by providing a C helper with which to set errno. Reviewed-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'linux-user/host/arm')
-rw-r--r--linux-user/host/arm/safe-syscall.inc.S27
1 files changed, 18 insertions, 9 deletions
diff --git a/linux-user/host/arm/safe-syscall.inc.S b/linux-user/host/arm/safe-syscall.inc.S
index 1f1ee8327b..618112c6bf 100644
--- a/linux-user/host/arm/safe-syscall.inc.S
+++ b/linux-user/host/arm/safe-syscall.inc.S
@@ -27,9 +27,6 @@
* first argument an 'int *' to the signal_pending flag, the
* second one the system call number (as a 'long'), and all further
* arguments being syscall arguments (also 'long').
- * We return a long which is the syscall's return value, which
- * may be negative-errno on failure. Conversion to the
- * -1-and-errno-set convention is done by the calling wrapper.
*/
safe_syscall_base:
.fnstart
@@ -46,7 +43,7 @@ safe_syscall_base:
.cfi_rel_offset lr, 20
/* The syscall calling convention isn't the same as the C one:
- * we enter with r0 == *signal_pending
+ * we enter with r0 == &signal_pending
* r1 == syscall number
* r2, r3, [sp+0] ... [sp+12] == syscall arguments
* and return the result in r0
@@ -74,17 +71,29 @@ safe_syscall_start:
/* if signal_pending is non-zero, don't do the call */
ldr r12, [r8] /* signal_pending */
tst r12, r12
- bne 1f
+ bne 2f
swi 0
safe_syscall_end:
/* code path for having successfully executed the syscall */
+ cmp r0, #-4096
+ neghi r0, r0
+ bhi 1f
pop { r4, r5, r6, r7, r8, pc }
-1:
/* code path when we didn't execute the syscall */
- ldr r0, =-TARGET_ERESTARTSYS
- pop { r4, r5, r6, r7, r8, pc }
+2: mov r0, #TARGET_ERESTARTSYS
+
+ /* code path setting errno */
+1: pop { r4, r5, r6, r7, r8, lr }
+ .cfi_adjust_cfa_offset -24
+ .cfi_restore r4
+ .cfi_restore r5
+ .cfi_restore r6
+ .cfi_restore r7
+ .cfi_restore r8
+ .cfi_restore lr
+ b safe_syscall_set_errno_tail
+
.fnend
.cfi_endproc
-
.size safe_syscall_base, .-safe_syscall_base