From patchwork Fri Jun 1 07:30:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137481 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp615970lji; Fri, 1 Jun 2018 00:48:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLcwKHRwAg2j/kWccQzICHDtPH1nsuk6n0+cQ1OYChhafgji2wFToPYu04NtIRCTfDiGjXC X-Received: by 2002:a37:270b:: with SMTP id n11-v6mr8963176qkn.91.1527839286615; Fri, 01 Jun 2018 00:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839286; cv=none; d=google.com; s=arc-20160816; b=Y2QaeaYlR4+9/bCas3TpnzbA3b8NZvb5HiKZgpMf4rq1pQ9n33WBn4e0ZIT0T67BM/ gM6kg1m2yqXhyzlohF27Lmfw/C/LqeVOOTCtMoosnXllrKPBTeL77uWACTBcan9g130P 0jXLUR0MiD6fGcWdpuwufDFAy3tlghzBLqcqytZMUz53TBuLtrA9uEILWsdFIR2kY24u LtaZ1xrKEcLTtIF6PhlZAdFVBFbWt0RloHsTF1LeM1B5HhiGFxselKtZdi1eilOYEnZt 6fSLq7FhZc29AVe0ylYe6WXLfRR0JpplPLqxhBKg/1DHczvo4T0jWFVADegWlzBG60aU 4+vA== 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=hiJLD4p4JwSr5Y/m/dr4NhaF5UBKnU9K5eAUw6O8Xpg=; b=RcEEk7szAteayfSbAsRE5wJCOMQmeGp39VkEdo9xkTY3Yz8jDoSJFACCRwghniNrSG 3hwLp2HqeUraITXmf9A6JrGWA/BuPZUdqvuRIF8cNsthSebCG1JjPhUo6otutsefYJD3 RvtW55pxXmZjESLaqz9OkSl1XLVR/um3KmXN/zAwje2uLiBxqoDtNhr6nnFle4oLa0JC MWenOkkInhfwkdZ0eYxEo88ScUim4hGWKeAru8opi1HxEVHHXUzWIp3J6jJiUh7HcIMu DnB+OzuJHcQmYYQVpVSLMkkezT83iW1dSgUNcYT9E/MZCedR9O1yb14qxSV9VIyOzzK0 KrnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kNGo5tn8; 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 e75-v6si1695627qka.183.2018.06.01.00.48.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:48:06 -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=kNGo5tn8; 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]:47901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOen7-0001cf-RH for patch@linaro.org; Fri, 01 Jun 2018 03:48:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXE-0005x0-Ai for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeXD-0000sR-01 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:40 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:43585) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeXC-0000ro-P1 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:38 -0400 Received: by mail-pg0-x241.google.com with SMTP id p8-v6so10867837pgq.10 for ; Fri, 01 Jun 2018 00:31:38 -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=hiJLD4p4JwSr5Y/m/dr4NhaF5UBKnU9K5eAUw6O8Xpg=; b=kNGo5tn8Q0gUiJdQDku5aNfd2fWAuS7ZFmKfqiugLWUYW3hSuCCdmLUxAqhiezEGGw c28YGFAXY8stm32bq62INmWk/VB9uO2cQIJGiLv9azucIBSnVpPtLCUPHPregQKFwrkT YHiC2HX/o6+YYnzNBE2C34pIukoM7xnnhpQYE= 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=hiJLD4p4JwSr5Y/m/dr4NhaF5UBKnU9K5eAUw6O8Xpg=; b=Dd5jIebgWyvzf6BXxudN7PyKkSVM4/GQ1eOLbVdBKCONmz1ZgrBWKCmMe7Au9Rqwld S70SnsrHrhkWD7f0h7GI+p1D0GX4NfuDQQId3sk+G7hiFlhvx7nXvA5CxvJfY55vRJzh L3Rci56uwxNcoE2/LHo2Lu9EE/mGDLPDlrcYBFjScE4OioJASN/9ZM19svjy0dnFFb5Q DiU84AjRjqhaVAQQZW+Pmsg7kLnvYgxVr6BtYo6cjCq3N/Cp6KFTOVxtSfKtrSxT/l39 NyKxA/sstr3igmhmFx7KZ3q/jFbrhbI3BvKTLzWg1QMgiV7KRLQtYNIirx4SxfBPukIC 5cTQ== X-Gm-Message-State: ALKqPwfTRQ78zq6EVSV9PHB2fETEmAXTJAg+Vf4xPQRh36/NU8Qc2P8u cQ3gn8hlukGe60+IyoKJK0W+KIqN7Ao= X-Received: by 2002:a63:7b07:: with SMTP id w7-v6mr7694237pgc.199.1527838297544; Fri, 01 Jun 2018 00:31:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:48 -0700 Message-Id: <20180601073050.8054-32-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 31/33] linux-user: Split out rt_sigprocmask, sgetmask, sigprocmask, ssetmask 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 | 294 +++++++++++++++++++++++-------------------- 1 file changed, 158 insertions(+), 136 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 36e2bb838e..e37a3ab643 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8805,6 +8805,65 @@ IMPL(rt_sigaction) return ret; } +IMPL(rt_sigprocmask) +{ + int how = 0; + sigset_t set, oldset, *set_ptr = NULL; + abi_long ret; + target_sigset_t *p; + + if (arg4 != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + + if (arg2) { + switch (arg1) { + case TARGET_SIG_BLOCK: + how = SIG_BLOCK; + break; + case TARGET_SIG_UNBLOCK: + how = SIG_UNBLOCK; + break; + case TARGET_SIG_SETMASK: + how = SIG_SETMASK; + break; + default: + return -TARGET_EINVAL; + } + p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&set, p); + unlock_user(p, arg2, 0); + set_ptr = &set; + } + ret = do_sigprocmask(how, set_ptr, &oldset); + if (!is_error(ret) && arg3) { + p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_sigset(p, &oldset); + unlock_user(p, arg3, sizeof(target_sigset_t)); + } + return ret; +} + +#ifdef TARGET_NR_sgetmask +IMPL(sgetmask) +{ + sigset_t cur_set; + abi_ulong target_set; + abi_long ret = do_sigprocmask(0, NULL, &cur_set); + if (!ret) { + host_to_target_old_sigset(&target_set, &cur_set); + ret = target_set; + } + return ret; +} +#endif + IMPL(setpgid) { return get_errno(setpgid(arg1, arg2)); @@ -8901,6 +8960,95 @@ IMPL(sigaction) } #endif +#ifdef TARGET_NR_sigprocmask +IMPL(sigprocmask) +{ + abi_long ret; +# ifdef TARGET_ALPHA + sigset_t set, oldset; + abi_ulong mask; + int how; + + switch (arg1) { + case TARGET_SIG_BLOCK: + how = SIG_BLOCK; + break; + case TARGET_SIG_UNBLOCK: + how = SIG_UNBLOCK; + break; + case TARGET_SIG_SETMASK: + how = SIG_SETMASK; + break; + default: + return -TARGET_EINVAL; + } + mask = arg2; + target_to_host_old_sigset(&set, &mask); + + ret = do_sigprocmask(how, &set, &oldset); + if (!is_error(ret)) { + host_to_target_old_sigset(&mask, &oldset); + ret = mask; + ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; /* force no error */ + } +# else + sigset_t set, oldset, *set_ptr = NULL; + int how = 0; + abi_ulong *p; + + if (arg2) { + switch (arg1) { + case TARGET_SIG_BLOCK: + how = SIG_BLOCK; + break; + case TARGET_SIG_UNBLOCK: + how = SIG_UNBLOCK; + break; + case TARGET_SIG_SETMASK: + how = SIG_SETMASK; + break; + default: + return -TARGET_EINVAL; + } + p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_old_sigset(&set, p); + unlock_user(p, arg2, 0); + set_ptr = &set; + } + ret = do_sigprocmask(how, set_ptr, &oldset); + if (!is_error(ret) && arg3) { + p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_old_sigset(p, &oldset); + unlock_user(p, arg3, sizeof(target_sigset_t)); + } +# endif + return ret; +} +#endif + +#ifdef TARGET_NR_ssetmask +IMPL(ssetmask) +{ + sigset_t set, oset; + abi_ulong target_set = arg1; + abi_long ret; + + target_to_host_old_sigset(&set, &target_set); + ret = do_sigprocmask(SIG_SETMASK, &set, &oset); + if (!ret) { + host_to_target_old_sigset(&target_set, &oset); + ret = target_set; + } + return ret; +} +#endif + #ifdef TARGET_NR_stime IMPL(stime) { @@ -9152,142 +9300,6 @@ IMPL(everything_else) char *fn; switch(num) { -#ifdef TARGET_NR_sgetmask /* not on alpha */ - case TARGET_NR_sgetmask: - { - sigset_t cur_set; - abi_ulong target_set; - ret = do_sigprocmask(0, NULL, &cur_set); - if (!ret) { - host_to_target_old_sigset(&target_set, &cur_set); - ret = target_set; - } - } - return ret; -#endif -#ifdef TARGET_NR_ssetmask /* not on alpha */ - case TARGET_NR_ssetmask: - { - sigset_t set, oset; - abi_ulong target_set = arg1; - target_to_host_old_sigset(&set, &target_set); - ret = do_sigprocmask(SIG_SETMASK, &set, &oset); - if (!ret) { - host_to_target_old_sigset(&target_set, &oset); - ret = target_set; - } - } - return ret; -#endif -#ifdef TARGET_NR_sigprocmask - case TARGET_NR_sigprocmask: - { -#if defined(TARGET_ALPHA) - sigset_t set, oldset; - abi_ulong mask; - int how; - - switch (arg1) { - case TARGET_SIG_BLOCK: - how = SIG_BLOCK; - break; - case TARGET_SIG_UNBLOCK: - how = SIG_UNBLOCK; - break; - case TARGET_SIG_SETMASK: - how = SIG_SETMASK; - break; - default: - return -TARGET_EINVAL; - } - mask = arg2; - target_to_host_old_sigset(&set, &mask); - - ret = do_sigprocmask(how, &set, &oldset); - if (!is_error(ret)) { - host_to_target_old_sigset(&mask, &oldset); - ret = mask; - ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; /* force no error */ - } -#else - sigset_t set, oldset, *set_ptr; - int how; - - if (arg2) { - switch (arg1) { - case TARGET_SIG_BLOCK: - how = SIG_BLOCK; - break; - case TARGET_SIG_UNBLOCK: - how = SIG_UNBLOCK; - break; - case TARGET_SIG_SETMASK: - how = SIG_SETMASK; - break; - default: - return -TARGET_EINVAL; - } - if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_old_sigset(&set, p); - unlock_user(p, arg2, 0); - set_ptr = &set; - } else { - how = 0; - set_ptr = NULL; - } - ret = do_sigprocmask(how, set_ptr, &oldset); - if (!is_error(ret) && arg3) { - if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) - return -TARGET_EFAULT; - host_to_target_old_sigset(p, &oldset); - unlock_user(p, arg3, sizeof(target_sigset_t)); - } -#endif - } - return ret; -#endif - case TARGET_NR_rt_sigprocmask: - { - int how = arg1; - sigset_t set, oldset, *set_ptr; - - if (arg4 != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - - if (arg2) { - switch(how) { - case TARGET_SIG_BLOCK: - how = SIG_BLOCK; - break; - case TARGET_SIG_UNBLOCK: - how = SIG_UNBLOCK; - break; - case TARGET_SIG_SETMASK: - how = SIG_SETMASK; - break; - default: - return -TARGET_EINVAL; - } - if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_sigset(&set, p); - unlock_user(p, arg2, 0); - set_ptr = &set; - } else { - how = 0; - set_ptr = NULL; - } - ret = do_sigprocmask(how, set_ptr, &oldset); - if (!is_error(ret) && arg3) { - if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) - return -TARGET_EFAULT; - host_to_target_sigset(p, &oldset); - unlock_user(p, arg3, sizeof(target_sigset_t)); - } - } - return ret; #ifdef TARGET_NR_sigpending case TARGET_NR_sigpending: { @@ -13100,11 +13112,21 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_rmdir] = impl_rmdir, #endif [TARGET_NR_rt_sigaction] = impl_rt_sigaction, + [TARGET_NR_rt_sigprocmask] = impl_rt_sigprocmask, +#ifdef TARGET_NR_sgetmask + [TARGET_NR_sgetmask] = impl_sgetmask, +#endif [TARGET_NR_setpgid] = impl_setpgid, [TARGET_NR_setsid] = impl_setsid, #ifdef TARGET_NR_sigaction [TARGET_NR_sigaction] = impl_sigaction, #endif +#ifdef TARGET_NR_sigprocmask + [TARGET_NR_sigprocmask] = impl_sigprocmask, +#endif +#ifdef TARGET_NR_ssetmask + [TARGET_NR_ssetmask] = impl_ssetmask, +#endif #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif