From patchwork Sun Jun 10 03:01:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138098 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2583401lji; Sat, 9 Jun 2018 20:20:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKH1Lz5rlcC3djJ/X2DIsmwpwqX2snhDO2/SNWit+B8MFHni85046QqakgQlXFo+7vcYlvH X-Received: by 2002:a37:2085:: with SMTP id g127-v6mr10103986qkg.402.1528600803241; Sat, 09 Jun 2018 20:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600803; cv=none; d=google.com; s=arc-20160816; b=rC/NagXwemGy04F/LbIe8EcN9UkGXArmDhxkQn2cCQpbEiq9+LzPa3teWbIEXVIqMo bpD2LA1cISZ3aHnuWYLm1C0rpWB+vOGvTnibNwtozBDPL1qgf5MNhfWRkdXxQLYg4Ivq YtwO39vqgDQlCHBu2+hB5vq60Cs2FQgDefb2RMBrj2rnO1nRHdUHkplmPXSFr2N3jzqx ua/KaVyN4EwDxPQjCf4gPEOH9sjwSKOk7FebafHSXVgpE2GKULF6OPoPGijOqHaZJvy0 Wm2zlBIh+5TRs6dOc2uYayEQaPqDY4Fa4dtTyyPzxVrdNO/n5+zNzmNb7mZ+RrMQJE4x ZdSw== 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=OU86JjjR2Bfp4cl+I7wJgMy91l6T/+cdMHYvOuVSfQk=; b=khDhMMnhwoKSTRzOc3V2LU5R9W4eNTDLcFb0xthMD3uszzX2EBYkPXe7G5i3ibhcRa xWNgyQP3jo4SRkLj0T6bLr/dqFNKZquxly0A63o5aZokYRyQlykaYN0i8JbBQrWnSwWy H0Z7ZdgeAPja65xueSOjh14OV2/unhCFElZpoaIFH3gkH9cy3V37GXV7B5AnL44pl4ak 0Bo00zwJXWmvfHR1QU7Yif1beKnPfua6hxCZ8TXa8/SLDJruBb6YPbCVQ0fxcNClrI6Z QjFVYiDDElIsTEO/77tWf9LoUjt3/5yRZcuQ88OMbQeiHJzV68wiBd5iN3YnprSNWymz N/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IQbMHcrI; 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 n69-v6si2962328qka.44.2018.06.09.20.20.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:20:03 -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=IQbMHcrI; 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]:42261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqte-00081R-IB for patch@linaro.org; Sat, 09 Jun 2018 23:20:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdh-0002Oh-LY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdg-0003Tl-Ah for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:33 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:44839) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdg-0003TT-2U for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:32 -0400 Received: by mail-pg0-x241.google.com with SMTP id p21-v6so8127599pgd.11 for ; Sat, 09 Jun 2018 20:03:31 -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=OU86JjjR2Bfp4cl+I7wJgMy91l6T/+cdMHYvOuVSfQk=; b=IQbMHcrIspXQ8byh1lA1Znuupy2KksJwbhwJLAA7s6uytXio4GPAdeSdMEFwnjpnLz UUSp9A2Pu9JdbcRb1PZEEMvOGxooURg9MxHyRLx0wPNUiRBspCeNXNX2UiL0Eqi9We7R XhNKsmuHo8IfUjjTDroICPtALvByl5pwmvrpw= 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=OU86JjjR2Bfp4cl+I7wJgMy91l6T/+cdMHYvOuVSfQk=; b=JGtRQx9CC8FBaPFzgzKRbRes+5A92Y4IPdDeABYb5FrJPLR0c+/bm2dxP9aVgTIuGX MIdlqZX/oOsUSYtm82624arL1W2Z3Ix7be4Um9tkemfULcyWx42gTkMHTruN31s89LsN NK0a2c4cvqVZgbvu3fImm3barmr3ceMUwoXmR47TJs2HyF5E1jYpZf9YQJ+59dNmkz2t aBn/yuAJ3vtACJxREiy1DkYj5N//hWbzHdu3WP7wkXGuvFHtqd2r2RT2wVpNOzzPzek9 zIHar49P3DbK8LpgAk7P53xpoG9ue0yct6OwGXXIOV7Ybz9Qb7JqGOSj2Q1TdMEr058k rfhw== X-Gm-Message-State: APt69E1/b1pRClmFDln7JTniwrAGQIytrT1dFncGUI6BTwO3iml3MP/R l7SlQvFfJ4S1NMIVJjzrt62pp+nPHaY= X-Received: by 2002:a63:7206:: with SMTP id n6-v6mr10229729pgc.174.1528599810844; Sat, 09 Jun 2018 20:03:30 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:02 -1000 Message-Id: <20180610030220.3777-31-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:c05::241 Subject: [Qemu-devel] [PATCH v2 030/108] 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.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cdb4dd5bb4..cc818ea65e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8697,6 +8697,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)); @@ -8793,6 +8852,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) { @@ -9034,142 +9182,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; 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: { @@ -12743,11 +12755,21 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(rmdir); #endif SYSCALL(rt_sigaction); + SYSCALL(rt_sigprocmask); +#ifdef TARGET_NR_sgetmask + SYSCALL(sgetmask); +#endif SYSCALL(setpgid); SYSCALL(setsid); #ifdef TARGET_NR_sigaction SYSCALL(sigaction); #endif +#ifdef TARGET_NR_sigprocmask + SYSCALL(sigprocmask); +#endif +#ifdef TARGET_NR_ssetmask + SYSCALL(ssetmask); +#endif #ifdef TARGET_NR_stime SYSCALL(stime); #endif