From patchwork Fri May 27 13:00:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 68743 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp92470qge; Fri, 27 May 2016 06:33:59 -0700 (PDT) X-Received: by 10.200.56.53 with SMTP id q50mr13315232qtb.22.1464356039109; Fri, 27 May 2016 06:33:59 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e82si16299612qhd.123.2016.05.27.06.33.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 27 May 2016 06:33:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Htm-0005Ll-Hc for patch@linaro.org; Fri, 27 May 2016 09:33:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HO7-0007qL-8Q for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HO1-0001Jh-Sf for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:15 -0400 Received: from mail-lb0-x230.google.com ([2a00:1450:4010:c04::230]:34819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HO0-0001JH-Ts for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:09 -0400 Received: by mail-lb0-x230.google.com with SMTP id ww9so31536148lbc.2 for ; Fri, 27 May 2016 06:01:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HBxyu80sMLPnVcZPM4q3s5F+yVplgHWX7a1UDiz4ciQ=; b=BtOyPGLFiJ/JIzTdprVO7ypTUv9ymNQ2RTicTZhwva+X1YtW8WD04ojlHkQsOiI7aN pLAOP3X7DIrPmuMih/PmF+aqrJZC3oA6NbPzJyhZJav1bYAFEL28hFvRnchCWY6w/vUD dHXBMdSONsp2QzBYd709DILV7O/VVPGEIpzVA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HBxyu80sMLPnVcZPM4q3s5F+yVplgHWX7a1UDiz4ciQ=; b=E62uYvEL6S9eX/IRkldYzeKIU39FekosDcgGICzhRH/Iz0C0kpwj1M9Gnx70f3igga a17xxHlSwLHY9O/Zt9CuiSJhDXNsQVGjv41csS5IRe9NNNixrJKb4X7Jq6SFjqLZ4KXg sx46gxgksfGar4lj30oocIBNehq+xPO5lWO1bqME6P1y5Ex8xMZmeTqZCqvtQyqCckt6 X8jY8tOmgpnMG/KFjed72fruRFItlNFfPr08JkDNIheCVkeZQcNPArOJpEzzaTolWu2W aFbi/MKd0gUNF0AY033p9Q3p0hJxx1S9j17Owg42Ui/59rEIMaB9Di43gDb0tMyUlIw3 OJHA== X-Gm-Message-State: ALyK8tJxhcW/XMWz2JwE3FF0kO+aw+ix9cUka2H1Sd812I7FV5Jcp2n9UlPejpCD0Olg8MOU X-Received: by 10.112.189.73 with SMTP id gg9mr3845311lbc.109.1464354068083; Fri, 27 May 2016 06:01:08 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id n16sm2281066lfg.31.2016.05.27.06.01.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:01:07 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:19 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::230 Subject: [Qemu-devel] [PULL v2 28/38] linux-user: Use safe_syscall for futex syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell 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 Signed-off-by: Riku Voipio --- linux-user/syscall.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.1.4 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; }