From patchwork Sun Jun 10 03:01:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138117 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2591304lji; Sat, 9 Jun 2018 20:34:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLdzqiOc+uQl9oAHbS4MUOQwyVytsRVCdY0E1/ANyHjq8uf95zAX4mXAKtt3riefkCykj7A X-Received: by 2002:a37:7044:: with SMTP id l65-v6mr10203671qkc.187.1528601657483; Sat, 09 Jun 2018 20:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601657; cv=none; d=google.com; s=arc-20160816; b=h1lwxnuUSynozLL80dhf9ZX58TVo0Dhw8td6oJIfgYnsqgKLmDyLfnAnBkahXgiNSh GdVpCSkwVBoL0iLOBAv3hldDUTgQCtDxfY8fCen2+z8yUg1hfn3xAHj1x5dfVD+2x7iw GYAhc7Rb3v6dNLu2fQ1MWCw6m+M0wO+phsWBdWN03V/RrS2yJOvEYqAejzhF9wcjFLgW 6xGlnlrlEf+l5IpFnj0AjTIvxOqUAPNW/YP8aI+qWHAc/1dj8vIbAleoGG1o0b+OM68K LxTVKN40DJWlNG7tZuF4X1U+1g3efzKSWvvOcAM+fh6xztowr+TQBgywrchX+X3ZTUVH mRKA== 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=RTUhwpTSkRz2YVJuO/N9YNNRZ/CAdKqRUxKILp8C9os=; b=RcLqJIv8MVqzxj/ekLuIfoqG4fM4pGtXC0kPloSlz2d52J6Z+5i71JK4u+6oclwceP csoPeIDyINotpKn+kXm84n9X6qemxOBeA+QR2xJjOYZuqHFnlyK+rlTZGrO2bPCtmCyw 2BDKpCFtxkH19zi93F2zCdFM0kZh4xHJbBirA0gj9Zd1B3nUQJoW4TxXUsK52ZdEjfzl bO/bZjvIgEJY4Hb6rPuz6amnF6/kUl2Xu2/RRVkVmBIVVG+nnrl6rM4tFLe7JL/wyxf8 YZeTxYyp+uxR/kmz2aBlyT+MpCGGHKXAwl4e6zhTYWMCejoqe+EQtDtYoIJq0L8Rd5NV 0P5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gPpbxgfV; 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 t48-v6si415678qte.236.2018.06.09.20.34.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:34:17 -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=gPpbxgfV; 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]:42345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr7Q-0003lo-U8 for patch@linaro.org; Sat, 09 Jun 2018 23:34:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdk-0002S6-Si for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdi-0003W6-Vg for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:36 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:37246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdi-0003Vk-Kn for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:34 -0400 Received: by mail-pf0-x243.google.com with SMTP id y5-v6so7583407pfn.4 for ; Sat, 09 Jun 2018 20:03:34 -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=RTUhwpTSkRz2YVJuO/N9YNNRZ/CAdKqRUxKILp8C9os=; b=gPpbxgfVk6SPJ97CdZOlNByuCKWj3xYuVsvwPpErcnYdH0OmGwDaCHdB750AYx0a2t 2klb2vyR6jZbC9Q1IgCGh+VIqqbyd8erI1a/ZJ6kFv+DmhBO4ptjyBJ15NGuc5+8Eb2f igzS3ZkNA7YiPoSFaJOGyf+ON8xCZh0JhZtus= 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=RTUhwpTSkRz2YVJuO/N9YNNRZ/CAdKqRUxKILp8C9os=; b=p4Sitvm8pJ4rHHCU0aBQ2ySN2Nh+3m71KlxSIDn0qVYnFxHAldww23fODGZkhuPDv0 LdsOanPedEFN+G1InT9lXFCC5ni9Dm8v2O8KNmnW2OMA5E+2rN2uVTEFTnVxm9Alceh/ fyyT5RB8Kjg/kMu+yB6oomr2ssu2OsCmqoRu1EdkxMosCgMYOvjxbprXi4RXtA06rO/3 i1SrYNsrMvPS7u5wQmVjZ1DUVmRvBfJg4kMcXyZsixw/QLxNKSFpRIqbA5kfuLu/tEDg 4Tu7rj8KgoJu3c7qF2O7n5pj8jyuyFrjua49WQ3/9z6IX30URZLoP2MOsQFh5iWnDOPx DC4Q== X-Gm-Message-State: APt69E3+kwMS73IklezRw6u7mEjWHxDWhsligCRHI5vSShcjQqCFZ24J CIx3PpW+izbiY7csOKK994DLriuO5vU= X-Received: by 2002:a63:7906:: with SMTP id u6-v6mr10295632pgc.284.1528599813115; Sat, 09 Jun 2018 20:03:33 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:03 -1000 Message-Id: <20180610030220.3777-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-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:c00::243 Subject: [Qemu-devel] [PATCH v2 031/108] 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.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cc818ea65e..6869a0db47 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8697,6 +8697,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; @@ -8742,6 +8768,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) { @@ -8852,6 +8901,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) { @@ -8924,6 +8991,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) { @@ -9182,81 +9275,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; 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; @@ -12755,7 +12773,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(rmdir); #endif SYSCALL(rt_sigaction); + SYSCALL(rt_sigpending); SYSCALL(rt_sigprocmask); + SYSCALL(rt_sigsuspend); #ifdef TARGET_NR_sgetmask SYSCALL(sgetmask); #endif @@ -12764,9 +12784,15 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sigaction SYSCALL(sigaction); #endif +#ifdef TARGET_NR_sigpending + SYSCALL(sigpending); +#endif #ifdef TARGET_NR_sigprocmask SYSCALL(sigprocmask); #endif +#ifdef TARGET_NR_sigsuspend + SYSCALL(sigsuspend); +#endif #ifdef TARGET_NR_ssetmask SYSCALL(ssetmask); #endif