提交 d509eeb1 编写于 作者: P Peter Maydell 提交者: Riku Voipio

linux-user: Use safe_syscall for futex syscall

Use the safe_syscall wrapper for the futex syscall.

In particular, this fixes hangs when using programs that link
against the Boehm garbage collector, including the Mono runtime.

(We don't change the sys_futex() call in the implementation of
the exit syscall, because as the FIXME comment there notes
that should be handled by disabling signals, since we can't
easily back out if the futex were to return ERESTARTSYS.)
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
上级 6df9d38d
...@@ -697,6 +697,8 @@ safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \ ...@@ -697,6 +697,8 @@ safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \
safe_syscall3(int, execve, const char *, filename, char **, argv, char **, envp) safe_syscall3(int, execve, const char *, filename, char **, argv, char **, envp)
safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, \ safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, \
fd_set *, exceptfds, struct timespec *, timeout, void *, sig) fd_set *, exceptfds, struct timespec *, timeout, void *, sig)
safe_syscall6(int,futex,int *,uaddr,int,op,int,val, \
const struct timespec *,timeout,int *,uaddr2,int,val3)
static inline int host_to_target_sock_type(int host_type) static inline int host_to_target_sock_type(int host_type)
{ {
...@@ -5381,12 +5383,12 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, ...@@ -5381,12 +5383,12 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
} else { } else {
pts = NULL; pts = NULL;
} }
return get_errno(sys_futex(g2h(uaddr), op, tswap32(val), return get_errno(safe_futex(g2h(uaddr), op, tswap32(val),
pts, NULL, val3)); pts, NULL, val3));
case FUTEX_WAKE: case FUTEX_WAKE:
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0)); return get_errno(safe_futex(g2h(uaddr), op, val, NULL, NULL, 0));
case FUTEX_FD: case FUTEX_FD:
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0)); return get_errno(safe_futex(g2h(uaddr), op, val, NULL, NULL, 0));
case FUTEX_REQUEUE: case FUTEX_REQUEUE:
case FUTEX_CMP_REQUEUE: case FUTEX_CMP_REQUEUE:
case FUTEX_WAKE_OP: case FUTEX_WAKE_OP:
...@@ -5396,11 +5398,11 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, ...@@ -5396,11 +5398,11 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
to satisfy the compiler. We do not need to tswap TIMEOUT to satisfy the compiler. We do not need to tswap TIMEOUT
since it's not compared to guest memory. */ since it's not compared to guest memory. */
pts = (struct timespec *)(uintptr_t) timeout; pts = (struct timespec *)(uintptr_t) timeout;
return get_errno(sys_futex(g2h(uaddr), op, val, pts, return get_errno(safe_futex(g2h(uaddr), op, val, pts,
g2h(uaddr2), g2h(uaddr2),
(base_op == FUTEX_CMP_REQUEUE (base_op == FUTEX_CMP_REQUEUE
? tswap32(val3) ? tswap32(val3)
: val3))); : val3)));
default: default:
return -TARGET_ENOSYS; return -TARGET_ENOSYS;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册