From patchwork Wed May 25 10:32:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 68570 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1138380qge; Wed, 25 May 2016 03:53:18 -0700 (PDT) X-Received: by 10.140.91.53 with SMTP id y50mr2594833qgd.104.1464173598539; Wed, 25 May 2016 03:53:18 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h66si7251712qhd.22.2016.05.25.03.53.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 May 2016 03:53:18 -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]:58898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WRC-0002aO-3j for patch@linaro.org; Wed, 25 May 2016 06:53:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7I-0001NP-JY for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W7C-0003LP-7D for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:44 -0400 Received: from mail-lb0-x22e.google.com ([2a00:1450:4010:c04::22e]:35912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7B-0003Kj-UJ for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:38 -0400 Received: by mail-lb0-x22e.google.com with SMTP id h1so14013954lbj.3 for ; Wed, 25 May 2016 03:32:37 -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=IBasftKpQTvKhHeEUC9lV0isSDCyIPLDpp8xJe2Bn2nhW9RJjDdbioOAwifibT8e9M h7SrihXAs59av6NqBqwuNtpsMXjdYo8rg9EvU0fFwPrr3BfQS0WKygvCE7VhM+lEwMHD UUhFQedduEnNRpk0JGv1yVoMnDGutDL9aLz1I= 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=gBA+7wmelHK/jxa0uFzi8ej8LaYorw2mm4BdTtuYT86tatjQ84mO+pnU34bjikqsup B8pb7gWl5El9bBIgtubGcSWp7avJiupBIoYXtugnvBS9gOt9LLU5jK7y5AZRwqxVs9HC XBX+9j5rPu2yichR+wsx64s9JYgiNG9/39ahO6noGwkKhq9xIuX1PBr7gMx55PQyLO2q v3GxexlkSI8rNkjf/CLvo/wm0CAPL4f4E6gRPWdrJPgDBmG3u/exzbrOG4fz3hWktjPq h/rymxwa28NNz0balmryIsENCn9UOVzV870rw/b6Of81xVCo5B5x5MYvwlcf/dvSPmtS HP3g== X-Gm-Message-State: ALyK8tLwJD/4ookucyIFrDy5OGzKb3HsfU+tawHLkuatA9u9zcsDTXOusrU3sSxO/Xc7MYkF X-Received: by 10.112.136.9 with SMTP id pw9mr804037lbb.144.1464172357123; Wed, 25 May 2016 03:32:37 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id o75sm1379610lfi.9.2016.05.25.03.32.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:36 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:32:00 +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::22e Subject: [Qemu-devel] [PULL 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; }