aboutsummaryrefslogtreecommitdiff
path: root/common-user/host/i386
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2021-11-23 15:18:49 +0100
committerRichard Henderson <richard.henderson@linaro.org>2021-12-20 10:12:29 -0800
commit5bfd125ec8ba8aab04f3a636dcea39f6c4075ced (patch)
tree2b82a29e6883f6ec6866434f79979d46cfeeb399 /common-user/host/i386
parentbbf15aaf7c7506c88062288b3ae122b882f65e69 (diff)
common-user: Adjust system call return on FreeBSD
FreeBSD system calls return positive errno. On the 4 hosts for which we have support, error is indicated by the C bit set or clear. Reviewed-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'common-user/host/i386')
-rw-r--r--common-user/host/i386/safe-syscall.inc.S11
1 files changed, 11 insertions, 0 deletions
diff --git a/common-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S
index aced8c5141..baf5400a29 100644
--- a/common-user/host/i386/safe-syscall.inc.S
+++ b/common-user/host/i386/safe-syscall.inc.S
@@ -71,9 +71,18 @@ safe_syscall_start:
mov 8+16(%esp), %eax /* syscall number */
int $0x80
safe_syscall_end:
+
/* code path for having successfully executed the syscall */
+#if defined(__linux__)
+ /* Linux kernel returns (small) negative errno. */
cmp $-4095, %eax
jae 0f
+#elif defined(__FreeBSD__)
+ /* FreeBSD kernel returns positive errno and C bit set. */
+ jc 1f
+#else
+#error "unsupported os"
+#endif
pop %ebx
.cfi_remember_state
.cfi_adjust_cfa_offset -4
@@ -90,8 +99,10 @@ safe_syscall_end:
ret
.cfi_restore_state
+#if defined(__linux__)
0: neg %eax
jmp 1f
+#endif
/* code path when we didn't execute the syscall */
2: mov $QEMU_ERESTARTSYS, %eax