From: riku.voipio@linaro.org
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PULL v2 28/38] linux-user: Use safe_syscall for futex syscall
Date: Fri, 27 May 2016 16:00:19 +0300 [thread overview]
Message-ID: <d509eeb13c9c6fef4a29ca43c64f591d8c61d201.1464353863.git.riku.voipio@linaro.org> (raw)
In-Reply-To: <cover.1464353863.git.riku.voipio@linaro.org>
From: Peter Maydell <peter.maydell@linaro.org>
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: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c9c2ae9..4e419fb 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, \
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)
{
@@ -5381,12 +5383,12 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
} else {
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));
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:
- 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_CMP_REQUEUE:
case FUTEX_WAKE_OP:
@@ -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
since it's not compared to guest memory. */
pts = (struct timespec *)(uintptr_t) timeout;
- return get_errno(sys_futex(g2h(uaddr), op, val, pts,
- g2h(uaddr2),
- (base_op == FUTEX_CMP_REQUEUE
- ? tswap32(val3)
- : val3)));
+ return get_errno(safe_futex(g2h(uaddr), op, val, pts,
+ g2h(uaddr2),
+ (base_op == FUTEX_CMP_REQUEUE
+ ? tswap32(val3)
+ : val3)));
default:
return -TARGET_ENOSYS;
}
--
2.1.4
next prev parent reply other threads:[~2016-05-27 13:01 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-27 12:59 [Qemu-devel] [PULL v2 00/38] linux-user pull request riku.voipio
2016-05-27 12:59 ` [Qemu-devel] [PULL v2 01/38] linux-user: Check array bounds in errno conversion riku.voipio
2016-05-27 12:59 ` [Qemu-devel] [PULL v2 02/38] linux-user: Consistently return host errnos from do_openat() riku.voipio
2016-05-27 12:59 ` [Qemu-devel] [PULL v2 03/38] linux-user: Reindent signal handling riku.voipio
2016-05-27 12:59 ` [Qemu-devel] [PULL v2 04/38] linux-user: Define TARGET_ERESTART* errno values riku.voipio
2016-05-27 12:59 ` [Qemu-devel] [PULL v2 05/38] linux-user: Renumber TARGET_QEMU_ESIGRETURN, make it not arch-specific riku.voipio
2016-05-27 12:59 ` [Qemu-devel] [PULL v2 06/38] linux-user: Support for restarting system calls for x86 targets riku.voipio
2016-05-27 12:59 ` [Qemu-devel] [PULL v2 07/38] linux-user: Support for restarting system calls for ARM targets riku.voipio
2016-05-27 12:59 ` [Qemu-devel] [PULL v2 08/38] linux-user: Support for restarting system calls for MIPS targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 09/38] linux-user: Support for restarting system calls for PPC targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 10/38] linux-user: Support for restarting system calls for SPARC targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 11/38] linux-user: Support for restarting system calls for SH4 targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 12/38] linux-user: Support for restarting system calls for Alpha targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 13/38] linux-user: Support for restarting system calls for UniCore32 targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 14/38] linux-user: Support for restarting system calls for OpenRISC targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 15/38] linux-user: Support for restarting system calls for M68K targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 16/38] linux-user: Support for restarting system calls for S390 targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 17/38] linux-user: Support for restarting system calls for CRIS targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 18/38] linux-user: Support for restarting system calls for tilegx targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 19/38] linux-user: Set r14 on exit from microblaze syscall riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 20/38] linux-user: Support for restarting system calls for Microblaze targets riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 21/38] linux-user: Add debug code to exercise restarting system calls riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 22/38] linux-user: Provide safe_syscall for fixing races between signals and syscalls riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 23/38] linux-user: Use safe_syscall for read and write system calls riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 24/38] linux-user: Use safe_syscall for open and openat " riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 25/38] linux-user: Use safe_syscall for wait " riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 26/38] linux-user: Use safe_syscall for execve syscall riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 27/38] linux-user: Use safe_syscall for pselect, select syscalls riku.voipio
2016-05-27 13:00 ` riku.voipio [this message]
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 29/38] linux-user: Handle negative values in timespec conversion riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 30/38] linux-user: Handle msgrcv error case correctly riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 31/38] linux-user: Use g_try_malloc() in do_msgrcv() riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 32/38] linux-user: x86_64: Don't use 16-bit UIDs riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 33/38] linux-user: Use direct syscalls for setuid(), etc riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 34/38] linux-user: arm: Remove ARM_cpsr and similar #defines riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 35/38] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 36/38] linux-user/signal.c: Use target address instead of host address for microblaze restorer riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 37/38] linux-user/signal.c: Use s390 target space address instead of host space riku.voipio
2016-05-27 13:00 ` [Qemu-devel] [PULL v2 38/38] linux-user, target-ppc: fix use of MSR_LE riku.voipio
2016-05-27 14:03 ` [Qemu-devel] [PULL v2 00/38] linux-user pull request Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d509eeb13c9c6fef4a29ca43c64f591d8c61d201.1464353863.git.riku.voipio@linaro.org \
--to=riku.voipio@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).