From patchwork Fri Jun 1 07:30:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137488 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp620047lji; Fri, 1 Jun 2018 00:53:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJV7keDYiMVFp0gcmLqca7VwKMgsz8plI9rWngCVHBgdUNvm+oJ7H+oG64q4De3WF1MXeTh X-Received: by 2002:a0c:e50b:: with SMTP id l11-v6mr4383064qvm.21.1527839639870; Fri, 01 Jun 2018 00:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839639; cv=none; d=google.com; s=arc-20160816; b=zQ8Voy15X39DVNfAgZrdI6AlQsiADbrE8t/lcykJLg/804+9w36yYYcpbr3I1st8OJ dFiETblLQTAAhIwTroRnVlZSvNLxIQ3CzroSFyfSoIE/JrmeAsNYc+rFJO4TgiALvKg4 EzNepVH7xQi0twV4zZRfV85wYiK0o+JMgn/43vzYKnbyBUePcP7uMLRXSOSBg2RaeQP4 lCOHmgsSOXxspiC4S7ozogzX+nJgn0jnZx284uVH0C1lm2p9m2jyOaTK6+qteCVsJdA0 zEBMxSxa3NMAy5EvJ8xaGnizr3M3Aj1S9tmilm+yjKOEJDELDCxJDNo5rxjA9BP6lcUm MkmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=SWhn66moQqqde5/jyrtCgCwzTTXSKJJJph8rxnnlIYw=; b=ACquv8yvC0LQi2y77vE3F20MuawrlTlvGOYHrdF/YhjNVXVK50IDKCvUKjyW8Pe/gr AeklT6/14l7CYA3wh/+5ZrDaCiPMETKjR1ZsSrkhKMARf7d0SIxqrPq698gLUEzCTzfu bF8aInH/VL6EBeb44sdQ+65Om2sF0xCnPRN8h87i3xHxoIhBCoijCITFVFp91rlw0mRB yPVeugPlYTKMc0TxiUKuxeXQM+K23lUm1on861t4cvquLPTK1JK9I9cqM3dzFF8qFEO3 qk0i3lYu/UC4awkdi7WC2hY3dqMCApBKS4TnpcjaaT1nzVsO6cGDu+jXlQ+fUAtD5lRh SAJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Jm771PR+; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d8-v6si1808388qkj.250.2018.06.01.00.53.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:53: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 header.s=google header.b=Jm771PR+; 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 sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOesp-0005HN-8S for patch@linaro.org; Fri, 01 Jun 2018 03:53:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXF-0005y5-L1 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeXE-0000td-CP for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:41 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:34040) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeXE-0000t2-4l for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:40 -0400 Received: by mail-pg0-x241.google.com with SMTP id k2-v6so10883082pgc.1 for ; Fri, 01 Jun 2018 00:31:40 -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=SWhn66moQqqde5/jyrtCgCwzTTXSKJJJph8rxnnlIYw=; b=Jm771PR+DQZVExiaOLimz/nfqJb7rFQWGLgF59tult7BBkIkKuymo8CSnJ0vyOGBC9 KgaRNhKCHC3oV+GmyGOySU7d09CbPaoVwfFU7NsGDARpkn5svGdM6Hj9phcslmwLYwK0 n61TKrl9VXR2HiIEvCsfEtcxmJjMBwXgDH3pU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SWhn66moQqqde5/jyrtCgCwzTTXSKJJJph8rxnnlIYw=; b=AT5fzXFsiJYj+wYVy3/2I6Xlq66l0v1u8nemB/Qi56k8k3V37MgQRBMNpuiS9QQM+l EuVVCk525Mpl7EHkqcuBOkb9cwWOkq5VdbM6e76NiOvajeMzEvKsPCTIAz6u+7+MRTZ5 YGaeWTS28HBojxKYdeQWbooqdvcxJoIS5i5F3F+qgQxMfLyxldwQ2jXjyYjtOQPgoUI0 iRgeHZ9qBZ8D0uY2K8SPpgEwJUNsaljrIJ0dzyvYXROi92sQqIDqzKRI3E2F0SO07eav KIn40DGk/dIDUWS44mvSzF/6CrS9trwvfFDKF+7nPV5dpHP/RB/BytgIuHIKPZCfHFX5 JPIQ== X-Gm-Message-State: ALKqPwdrLrS1GpK0yRBIUWveyf7f5D/dWD0peTCPaKUDsEJDqpU1oA06 i89BFWwfLa+DxwOuqsGbGJE8zQH7k40= X-Received: by 2002:a63:7255:: with SMTP id c21-v6mr7717709pgn.99.1527838298845; Fri, 01 Jun 2018 00:31:38 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:49 -0700 Message-Id: <20180601073050.8054-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH 32/33] linux-user: Split out rt_sigpending, rt_sigsuspend, sigpending, sigsuspend 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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 176 +++++++++++++++++++++++++------------------ 1 file changed, 101 insertions(+), 75 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e37a3ab643..c3bd625965 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8805,6 +8805,32 @@ IMPL(rt_sigaction) return ret; } +IMPL(rt_sigpending) +{ + sigset_t set; + abi_long ret; + + /* Yes, this check is >, not != like most. We follow the kernel's + * logic and it does it like this because it implements + * NR_sigpending through the same code path, and in that case + * the old_sigset_t is smaller in size. + */ + if (arg2 > sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + ret = get_errno(sigpending(&set)); + if (!is_error(ret)) { + target_sigset_t *p; + p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_sigset(p, &set); + unlock_user(p, arg1, sizeof(target_sigset_t)); + } + return ret; +} + IMPL(rt_sigprocmask) { int how = 0; @@ -8850,6 +8876,29 @@ IMPL(rt_sigprocmask) return ret; } +IMPL(rt_sigsuspend) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + target_sigset_t *p; + abi_long ret; + + if (arg2 != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&ts->sigsuspend_mask, p); + unlock_user(p, arg1, 0); + ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, SIGSET_T_SIZE)); + if (ret != -TARGET_ERESTARTSYS) { + ts->in_sigsuspend = 1; + } + return ret; +} + #ifdef TARGET_NR_sgetmask IMPL(sgetmask) { @@ -8960,6 +9009,24 @@ IMPL(sigaction) } #endif +#ifdef TARGET_NR_sigpending +IMPL(sigpending) +{ + sigset_t set; + abi_long ret = get_errno(sigpending(&set)); + if (!is_error(ret)) { + abi_ulong *p; + p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_old_sigset(p, &set); + unlock_user(p, arg1, sizeof(target_sigset_t)); + } + return ret; +} +#endif + #ifdef TARGET_NR_sigprocmask IMPL(sigprocmask) { @@ -9032,6 +9099,32 @@ IMPL(sigprocmask) } #endif +#ifdef TARGET_NR_sigsuspend +IMPL(sigsuspend) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + abi_long ret; + +# ifdef TARGET_ALPHA + abi_ulong mask = arg1; + target_to_host_old_sigset(&ts->sigsuspend_mask, &mask); +# else + abi_ulong *p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_old_sigset(&ts->sigsuspend_mask, p); + unlock_user(p, arg1, 0); +# endif + ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, SIGSET_T_SIZE)); + if (ret != -TARGET_ERESTARTSYS) { + ts->in_sigsuspend = 1; + } + return ret; +} +#endif + #ifdef TARGET_NR_ssetmask IMPL(ssetmask) { @@ -9300,81 +9393,6 @@ IMPL(everything_else) char *fn; switch(num) { -#ifdef TARGET_NR_sigpending - case TARGET_NR_sigpending: - { - sigset_t set; - ret = get_errno(sigpending(&set)); - if (!is_error(ret)) { - if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) - return -TARGET_EFAULT; - host_to_target_old_sigset(p, &set); - unlock_user(p, arg1, sizeof(target_sigset_t)); - } - } - return ret; -#endif - case TARGET_NR_rt_sigpending: - { - sigset_t set; - - /* Yes, this check is >, not != like most. We follow the kernel's - * logic and it does it like this because it implements - * NR_sigpending through the same code path, and in that case - * the old_sigset_t is smaller in size. - */ - if (arg2 > sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - - ret = get_errno(sigpending(&set)); - if (!is_error(ret)) { - if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) - return -TARGET_EFAULT; - host_to_target_sigset(p, &set); - unlock_user(p, arg1, sizeof(target_sigset_t)); - } - } - return ret; -#ifdef TARGET_NR_sigsuspend - case TARGET_NR_sigsuspend: - { - TaskState *ts = cpu->opaque; -#if defined(TARGET_ALPHA) - abi_ulong mask = arg1; - target_to_host_old_sigset(&ts->sigsuspend_mask, &mask); -#else - if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_old_sigset(&ts->sigsuspend_mask, p); - unlock_user(p, arg1, 0); -#endif - ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, - SIGSET_T_SIZE)); - if (ret != -TARGET_ERESTARTSYS) { - ts->in_sigsuspend = 1; - } - } - return ret; -#endif - case TARGET_NR_rt_sigsuspend: - { - TaskState *ts = cpu->opaque; - - if (arg2 != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_sigset(&ts->sigsuspend_mask, p); - unlock_user(p, arg1, 0); - ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, - SIGSET_T_SIZE)); - if (ret != -TARGET_ERESTARTSYS) { - ts->in_sigsuspend = 1; - } - } - return ret; case TARGET_NR_rt_sigtimedwait: { sigset_t set; @@ -13112,7 +13130,9 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_rmdir] = impl_rmdir, #endif [TARGET_NR_rt_sigaction] = impl_rt_sigaction, + [TARGET_NR_rt_sigpending] = impl_rt_sigpending, [TARGET_NR_rt_sigprocmask] = impl_rt_sigprocmask, + [TARGET_NR_rt_sigsuspend] = impl_rt_sigsuspend, #ifdef TARGET_NR_sgetmask [TARGET_NR_sgetmask] = impl_sgetmask, #endif @@ -13121,9 +13141,15 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_sigaction [TARGET_NR_sigaction] = impl_sigaction, #endif +#ifdef TARGET_NR_sigpending + [TARGET_NR_sigpending] = impl_sigpending, +#endif #ifdef TARGET_NR_sigprocmask [TARGET_NR_sigprocmask] = impl_sigprocmask, #endif +#ifdef TARGET_NR_sigsuspend + [TARGET_NR_sigsuspend] = impl_sigsuspend, +#endif #ifdef TARGET_NR_ssetmask [TARGET_NR_ssetmask] = impl_ssetmask, #endif