From patchwork Sun Jun 10 03:01:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138113 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2589650lji; Sat, 9 Jun 2018 20:31:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKVp7gFyGnGIq2JZjOAv3a/bP2itY5pcjZHkJTfDSTmcZ3sNA/v0qU43S3Ofuj1mJAol2Dq X-Received: by 2002:a37:f50a:: with SMTP id l10-v6mr10227284qkk.109.1528601488095; Sat, 09 Jun 2018 20:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601488; cv=none; d=google.com; s=arc-20160816; b=G+BnMmxCk1MWlW5nY5xedjy3mvmye7ph4NDf9VQiFl49/UhioF+/DdhJnngbYpxYB+ LwPfIT1WX7P6mXonrL7TshEgSXNAR6P3SwPa+jD1vpAbMlbCb7TggrGXNDEs0ubLYKgB ZeAg4DARh/yE76fwXUgQYLNZdIXw5ap0rU5tVyLWTHJ7D76Mac5ZfUfkA4vPeQusf76N hQqkocePIbvqEclsPIHkuEgfoPn+l16ughWdXcq3e8iOFkFvyyYOCX3G2IVHKndFrlv2 GV/al21z7GR4AzgdqGs49OsalNy6LlHpFWr5HpY+5CJJKX3Kfx36Wm0W8qh5dhvTrbt4 iddg== 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=muVcap5oOTZx3qnIUkiQYwVwHlmYJy472O02cLaCR1c=; b=rKu2Dhge6G9yrkT1FgyMdJcaC1huPyim0ljk2jKaTGmxraz9Phux9I0kPt3d2FTydC kepg9g0EMDaR8XgOz5YZklh1AogN/e9L2lGIo6//J5eWeGI5OV8tEWoU7YDw4l+UZuo3 26RTvyRZ/xtqaAzCJU0fBTj4UXjLwu/at9mz7F34ApDCvMld7cHwACS+nCYqDUy0TUBF XDrA9cftDYX4GnyN4+Dh6Ao3djP1dNjs7i32FFbIbgEZv+KpKnoYJvWL0lTiqpWwIRxb tiYCJlOjyfpZ+UXlwIcJfR5ZDclffI2vvSRBrcGbFSQTs+BitJqDAYgwFPCjyrFoFszc /tig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cxiFje7w; 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 a22-v6si13580144qkj.109.2018.06.09.20.31.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:31:28 -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=cxiFje7w; 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]:42331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr4h-00019M-E9 for patch@linaro.org; Sat, 09 Jun 2018 23:31:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdg-0002Mu-2S for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqde-0003T5-Fj for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:32 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:45642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqde-0003Sj-7G for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:30 -0400 Received: by mail-pf0-x243.google.com with SMTP id a22-v6so8479543pfo.12 for ; Sat, 09 Jun 2018 20:03:30 -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=muVcap5oOTZx3qnIUkiQYwVwHlmYJy472O02cLaCR1c=; b=cxiFje7wWReosg3f7twE2YJ+ZhoWRbAioz73ddiofMcbpdH5GJkCSW2F2PEuPB7z8L s8uylKOnQGrs38ZNpsVuBrMB3M7aGQ+ERa9Zl8Y5++f8ptWfz7QvLCu77YGoaMoWiryi 8svid2Db4qXvQZtSe+rWnoYQ6KphucYxTd31c= 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=muVcap5oOTZx3qnIUkiQYwVwHlmYJy472O02cLaCR1c=; b=dO80j/XuIIj7iL18/KNLfJsyfUw8s8cKgr1qRIZmH+mGDPa9cNV7wyl3cBwV0hgihN D70dRKGsziPwx4F5mUwNPtXQEpppfsVdZbwHy9OQXu6/DZPAsnKsgucWS0reGOcmgVNA TWPbMypn1d5QVHEjoJR4arohlveRW1wDAoYaAPMzI24F+2Ar8x8RKYVU8e3fpJUiTKhm slzYL5izMNOma6mxXZKj7WY8bKSqRrMv1H6kLUUr44yzSuG9H9/DvIB3LQ6qx/J1o5rh Yvyaz1hQrOM3pnsFMbeNzZDbn9vGzGyAmgor+TgBgYxkl4Mclclex8tLBHhQbmLX06hO MH7A== X-Gm-Message-State: APt69E00UJURWD+2dDAc0r6t01eskzUJd+Yvcs3pC53pHk7OU0ubHDGk gAYyn729iVIrDUNJkYi68/yGr6RUXhc= X-Received: by 2002:a65:660c:: with SMTP id w12-v6mr1723741pgv.404.1528599808948; Sat, 09 Jun 2018 20:03:28 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:01 -1000 Message-Id: <20180610030220.3777-30-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 029/108] 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.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d78288258a..cdb4dd5bb4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8622,6 +8622,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)); @@ -8632,6 +8707,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) { @@ -8873,166 +9034,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; 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: { @@ -12741,8 +12742,12 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_rmdir SYSCALL(rmdir); #endif + SYSCALL(rt_sigaction); SYSCALL(setpgid); SYSCALL(setsid); +#ifdef TARGET_NR_sigaction + SYSCALL(sigaction); +#endif #ifdef TARGET_NR_stime SYSCALL(stime); #endif