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: 927229 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="IQbMHcrI"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 413Lxh2tcrz9ry1 for ; Sun, 10 Jun 2018 13:20:24 +1000 (AEST) Received: from localhost ([::1]:42261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqtx-00081R-T0 for incoming@patchwork.ozlabs.org; Sat, 09 Jun 2018 23:20:21 -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-Google-Smtp-Source: ADUXVKKa1HTeLRWK7qRZm0bDrDk/tyeCWqCnnil/vjP2MWGG0D8VVhBvE3l6ztmpgM4FaZQDkOzGSw== 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 294 +++++++++++++++++++++++-------------------- 1 file changed, 158 insertions(+), 136 deletions(-) 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