From patchwork Fri Jun 1 07:30:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137493 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp623676lji; Fri, 1 Jun 2018 00:59:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJIaSp3jhJBSD1uX4nfxe3LQpiQygF7sFwD9nLhMzKLUSkNc8EPvm8LMMUhLeN6eib30TyV X-Received: by 2002:a37:8ec4:: with SMTP id q187-v6mr9324407qkd.28.1527839951774; Fri, 01 Jun 2018 00:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839951; cv=none; d=google.com; s=arc-20160816; b=T621GmMaM0AlwzX8YIgr5yh6YYLmNrHcYllRv4lv4Jiasv6nsCDo283V4uiB47KcFV N8h27YbucFPC0Mjnzfee1JW2kw8fCr3xkomp2wqQ+Z36OL/bbZ+j02tY6GClh7DG+sIZ cb6cksEX5LtvF0Lio+mm7s0jdH3yvdRiczp7NeE/U9Z9bmnlX/IthgdGtP4BaTjHggQY 3/0JnP0DWUrkWBEPQKHp7clNhn1Wlxq3epikTje4cEpOCA+9u6G9Y2LZ2+YE6EeHU7Jw +FM0SLUhoMrEmF7iWYllTUAj4g/oeZExI00x5A4nJsT/D0jAuRiUeyoKcqy/Yx7I3mAa bUrQ== 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=cKH6v2qR8mpApdcxMm32cBdeITbb8RHNnTb6w+DTJXY=; b=c2VdxjSptnOMtFd8RJN393TyCbfxKMZ7ScuW4PpgwUI8GP7lcKwIzI50ZBvcarttor DYqz3MYM6fYRxj6MRVkaiycDZcXEDN96z6fYcxPeEhtGDiARdjPixNx048xam3CrOt4N aXM8QdgQGl9rLWDG20sMqldjqfDG0ZiC3/iJ43cC/O5DdYm89rkFcuK2X20vV5HpdRSG 3SJhd0uE8HG0uo9OvS+q/WetvU0ocC1Fm/xoL384PzgSYJUnlbBrHJDfHvq97HmPrIaR /tlwAA95QX/+kuvJ84nQ5lWqB6U7HNOyxF+hPojT1xWo8Sa3+FNbDIcQ6+KCvII7SPuJ pokg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LLE+Did7; 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 l37-v6si2901221qtl.321.2018.06.01.00.59.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:59:11 -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=LLE+Did7; 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]:47972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOexr-0002FP-5L for patch@linaro.org; Fri, 01 Jun 2018 03:59:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXD-0005w5-Ce for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeXB-0000r9-Jm for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:39 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:33007) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeXB-0000qV-BB for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:37 -0400 Received: by mail-pg0-x241.google.com with SMTP id e11-v6so1685190pgq.0 for ; Fri, 01 Jun 2018 00:31: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=cKH6v2qR8mpApdcxMm32cBdeITbb8RHNnTb6w+DTJXY=; b=LLE+Did7PMitLFXCiN/62O+wzR8oFr2vNZRbwrliQYc9QyVa7cxOGTxLRVJdIgiz3h oiC20hshx0Q1ouR3SEIVHtH9R1hXS+CKBirmaVw1DW1WENODaSikhRXqz5aqMlPSZ8rE AJPKLeHl2RRCEZfQir1cfsKswqrRMkZTUAdj0= 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=cKH6v2qR8mpApdcxMm32cBdeITbb8RHNnTb6w+DTJXY=; b=WbVIXhUP2VtHNbQ3VTppxD9uWmIdCHDdUa/YyfeR/no8SWHCzKl+aybJ10lEhMI5Ym ERhQdGGoDk/8dCaAQ2Aa9T85vvi+syYuKH12vHnem8II/1rSTs+rk2IUQ36wl0r3Bh0c n5XsoiM3lc/zuorm4xnnI0TA/EMnJBypf/e9VEK0NjimvXS3uAtum1xqy/axU999vqDc YFbKde/g/BFhnG9wpcaIj0jytLiMnHSu0enfCzIt/EGPudh32g83VOSDd9YLf4b317cX P4pIkWtWM/WLu1Fke08BhtOUkWx5mtT6wsq0qcXBfhgo/I01H3ZzbUfsQqjHc9Dpwrdp OltQ== X-Gm-Message-State: ALKqPweDJdRhtfWlcH26UfddbD9tF0oqh6wesdJLYxteQuVrnGAYxaZi Stxw+JtSSa1YNM5qUuAGDNbmzrEZwvI= X-Received: by 2002:a65:608d:: with SMTP id t13-v6mr7885437pgu.266.1527838296051; Fri, 01 Jun 2018 00:31:36 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:47 -0700 Message-Id: <20180601073050.8054-31-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 30/33] linux-user: Split out rt_sigaction, sigaction 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 | 325 ++++++++++++++++++++++--------------------- 1 file changed, 165 insertions(+), 160 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3dfb77ac11..36e2bb838e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8730,6 +8730,81 @@ IMPL(rmdir) } #endif +IMPL(rt_sigaction) +{ + abi_long ret; +#ifdef TARGET_ALPHA + /* For Alpha and SPARC this is a 5 argument syscall, with + * a 'restorer' parameter which must be copied into the + * sa_restorer field of the sigaction struct. + * For Alpha that 'restorer' is arg5; for SPARC it is arg4, + * and arg5 is the sigsetsize. + * Alpha also has a separate rt_sigaction struct that it uses + * here; SPARC uses the usual sigaction struct. + */ + struct target_rt_sigaction *rt_act; + struct target_sigaction act, oact, *pact = 0; + + if (arg4 != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + if (arg2) { + if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) { + return -TARGET_EFAULT; + } + act._sa_handler = rt_act->_sa_handler; + act.sa_mask = rt_act->sa_mask; + act.sa_flags = rt_act->sa_flags; + act.sa_restorer = arg5; + unlock_user_struct(rt_act, arg2, 0); + pact = &act; + } + ret = get_errno(do_sigaction(arg1, pact, &oact)); + if (!is_error(ret) && arg3) { + if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) { + return -TARGET_EFAULT; + } + rt_act->_sa_handler = oact._sa_handler; + rt_act->sa_mask = oact.sa_mask; + rt_act->sa_flags = oact.sa_flags; + unlock_user_struct(rt_act, arg3, 1); + } +#else +# ifdef TARGET_SPARC + target_ulong restorer = arg4; + target_ulong sigsetsize = arg5; +# else + target_ulong sigsetsize = arg4; +# endif + struct target_sigaction *act = NULL; + struct target_sigaction *oact = NULL; + + if (sigsetsize != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + if (arg2) { + if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) { + return -TARGET_EFAULT; + } +# ifdef TARGET_ARCH_HAS_KA_RESTORER + act->ka_restorer = restorer; +# endif + } + if (arg3 && !lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { + ret = -TARGET_EFAULT; + } else { + ret = get_errno(do_sigaction(arg1, act, oact)); + } + if (act) { + unlock_user_struct(act, arg2, 0); + } + if (oact) { + unlock_user_struct(oact, arg3, 1); + } +#endif + return ret; +} + IMPL(setpgid) { return get_errno(setpgid(arg1, arg2)); @@ -8740,6 +8815,92 @@ IMPL(setsid) return get_errno(setsid()); } +#ifdef TARGET_NR_sigaction +IMPL(sigaction) +{ + abi_long ret; +# if defined(TARGET_ALPHA) + struct target_sigaction act, oact, *pact = NULL; + struct target_old_sigaction *old_act; + if (arg2) { + if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) { + return -TARGET_EFAULT; + } + act._sa_handler = old_act->_sa_handler; + target_siginitset(&act.sa_mask, old_act->sa_mask); + act.sa_flags = old_act->sa_flags; + act.sa_restorer = 0; + unlock_user_struct(old_act, arg2, 0); + pact = &act; + } + ret = get_errno(do_sigaction(arg1, pact, &oact)); + if (!is_error(ret) && arg3) { + if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) { + return -TARGET_EFAULT; + } + old_act->_sa_handler = oact._sa_handler; + old_act->sa_mask = oact.sa_mask.sig[0]; + old_act->sa_flags = oact.sa_flags; + unlock_user_struct(old_act, arg3, 1); + } +# elif defined(TARGET_MIPS) + struct target_sigaction act, oact, *pact = NULL, *old_act; + if (arg2) { + if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) { + return -TARGET_EFAULT; + } + act._sa_handler = old_act->_sa_handler; + target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); + act.sa_flags = old_act->sa_flags; + unlock_user_struct(old_act, arg2, 0); + pact = &act; + } + ret = get_errno(do_sigaction(arg1, pact, &oact)); + if (!is_error(ret) && arg3) { + if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) { + return -TARGET_EFAULT; + } + old_act->_sa_handler = oact._sa_handler; + old_act->sa_flags = oact.sa_flags; + old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; + old_act->sa_mask.sig[1] = 0; + old_act->sa_mask.sig[2] = 0; + old_act->sa_mask.sig[3] = 0; + unlock_user_struct(old_act, arg3, 1); + } +# else + struct target_sigaction act, oact, *pact = NULL; + struct target_old_sigaction *old_act; + if (arg2) { + if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) { + return -TARGET_EFAULT; + } + act._sa_handler = old_act->_sa_handler; + target_siginitset(&act.sa_mask, old_act->sa_mask); + act.sa_flags = old_act->sa_flags; + act.sa_restorer = old_act->sa_restorer; +# ifdef TARGET_ARCH_HAS_KA_RESTORER + act.ka_restorer = 0; +# endif + unlock_user_struct(old_act, arg2, 0); + pact = &act; + } + ret = get_errno(do_sigaction(arg1, pact, &oact)); + if (!is_error(ret) && arg3) { + if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) { + return -TARGET_EFAULT; + } + old_act->_sa_handler = oact._sa_handler; + old_act->sa_mask = oact.sa_mask.sig[0]; + old_act->sa_flags = oact.sa_flags; + old_act->sa_restorer = oact.sa_restorer; + unlock_user_struct(old_act, arg3, 1); + } +# endif + return ret; +} +#endif + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8991,166 +9152,6 @@ IMPL(everything_else) char *fn; switch(num) { -#ifdef TARGET_NR_sigaction - case TARGET_NR_sigaction: - { -#if defined(TARGET_ALPHA) - struct target_sigaction act, oact, *pact = 0; - struct target_old_sigaction *old_act; - if (arg2) { - if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = old_act->_sa_handler; - target_siginitset(&act.sa_mask, old_act->sa_mask); - act.sa_flags = old_act->sa_flags; - act.sa_restorer = 0; - unlock_user_struct(old_act, arg2, 0); - pact = &act; - } - ret = get_errno(do_sigaction(arg1, pact, &oact)); - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - return -TARGET_EFAULT; - old_act->_sa_handler = oact._sa_handler; - old_act->sa_mask = oact.sa_mask.sig[0]; - old_act->sa_flags = oact.sa_flags; - unlock_user_struct(old_act, arg3, 1); - } -#elif defined(TARGET_MIPS) - struct target_sigaction act, oact, *pact, *old_act; - - if (arg2) { - if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = old_act->_sa_handler; - target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); - act.sa_flags = old_act->sa_flags; - unlock_user_struct(old_act, arg2, 0); - pact = &act; - } else { - pact = NULL; - } - - ret = get_errno(do_sigaction(arg1, pact, &oact)); - - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - return -TARGET_EFAULT; - old_act->_sa_handler = oact._sa_handler; - old_act->sa_flags = oact.sa_flags; - old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; - old_act->sa_mask.sig[1] = 0; - old_act->sa_mask.sig[2] = 0; - old_act->sa_mask.sig[3] = 0; - unlock_user_struct(old_act, arg3, 1); - } -#else - struct target_old_sigaction *old_act; - struct target_sigaction act, oact, *pact; - if (arg2) { - if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = old_act->_sa_handler; - target_siginitset(&act.sa_mask, old_act->sa_mask); - act.sa_flags = old_act->sa_flags; - act.sa_restorer = old_act->sa_restorer; -#ifdef TARGET_ARCH_HAS_KA_RESTORER - act.ka_restorer = 0; -#endif - unlock_user_struct(old_act, arg2, 0); - pact = &act; - } else { - pact = NULL; - } - ret = get_errno(do_sigaction(arg1, pact, &oact)); - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - return -TARGET_EFAULT; - old_act->_sa_handler = oact._sa_handler; - old_act->sa_mask = oact.sa_mask.sig[0]; - old_act->sa_flags = oact.sa_flags; - old_act->sa_restorer = oact.sa_restorer; - unlock_user_struct(old_act, arg3, 1); - } -#endif - } - return ret; -#endif - case TARGET_NR_rt_sigaction: - { -#if defined(TARGET_ALPHA) - /* For Alpha and SPARC this is a 5 argument syscall, with - * a 'restorer' parameter which must be copied into the - * sa_restorer field of the sigaction struct. - * For Alpha that 'restorer' is arg5; for SPARC it is arg4, - * and arg5 is the sigsetsize. - * Alpha also has a separate rt_sigaction struct that it uses - * here; SPARC uses the usual sigaction struct. - */ - struct target_rt_sigaction *rt_act; - struct target_sigaction act, oact, *pact = 0; - - if (arg4 != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - if (arg2) { - if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = rt_act->_sa_handler; - act.sa_mask = rt_act->sa_mask; - act.sa_flags = rt_act->sa_flags; - act.sa_restorer = arg5; - unlock_user_struct(rt_act, arg2, 0); - pact = &act; - } - ret = get_errno(do_sigaction(arg1, pact, &oact)); - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) - return -TARGET_EFAULT; - rt_act->_sa_handler = oact._sa_handler; - rt_act->sa_mask = oact.sa_mask; - rt_act->sa_flags = oact.sa_flags; - unlock_user_struct(rt_act, arg3, 1); - } -#else -#ifdef TARGET_SPARC - target_ulong restorer = arg4; - target_ulong sigsetsize = arg5; -#else - target_ulong sigsetsize = arg4; -#endif - struct target_sigaction *act; - struct target_sigaction *oact; - - if (sigsetsize != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - if (arg2) { - if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) { - return -TARGET_EFAULT; - } -#ifdef TARGET_ARCH_HAS_KA_RESTORER - act->ka_restorer = restorer; -#endif - } else { - act = NULL; - } - if (arg3) { - if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { - ret = -TARGET_EFAULT; - goto rt_sigaction_fail; - } - } else - oact = NULL; - ret = get_errno(do_sigaction(arg1, act, oact)); - rt_sigaction_fail: - if (act) - unlock_user_struct(act, arg2, 0); - if (oact) - unlock_user_struct(oact, arg3, 1); -#endif - } - return ret; #ifdef TARGET_NR_sgetmask /* not on alpha */ case TARGET_NR_sgetmask: { @@ -13098,8 +13099,12 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_rmdir [TARGET_NR_rmdir] = impl_rmdir, #endif + [TARGET_NR_rt_sigaction] = impl_rt_sigaction, [TARGET_NR_setpgid] = impl_setpgid, [TARGET_NR_setsid] = impl_setsid, +#ifdef TARGET_NR_sigaction + [TARGET_NR_sigaction] = impl_sigaction, +#endif #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif