From patchwork Thu Apr 22 18:08:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 425878 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp597166jao; Thu, 22 Apr 2021 11:14:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw3/cmf6HPByMIrQNU1XwO5mS+ImGbtnRLqtGoXLWjk0IBdYro6+TXLD+9EeCTqxU2vnT5 X-Received: by 2002:a05:6e02:1063:: with SMTP id q3mr3912213ilj.52.1619115264297; Thu, 22 Apr 2021 11:14:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619115264; cv=none; d=google.com; s=arc-20160816; b=vEH7zs2ejj+LfpRJZqZZsL6h9N26trC4Vws0iTrIr2jMXYvm3kzuh+VSDYaKoupWos T4yKpNzOHTYjy42EhHC1DUdC8a92GHKKAEWcyBLBIibFyoR7n7uuFHvDQQfHIuB7dRLE 4rSlyYTrEfyPSOuMuW4S2J+3KgzwOOc2/JB96q0cNtIkakzGP7AqkylorVvNVpQjIMEq Bato3UumXaCuYEsTNLNLDMHIhNFzb2nbVh+moJvxclAC1B+B2qE4V6WKI+00KcTA35l2 BkBeZ8WIHZEo7D2FIsCjqkpmlxNYKac7XbXUP31XVdWXFN7Q9bAAAagTUmiLEwppFRxn z6bg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=bJ5I9s7dg9qHK409QJoe2gt4MUYWY6bp4k2kmR2aZJw=; b=TNxUPrkKEsJH2fq+/EfxTYY8Kk9hsU8BG5hvxt7JJG3KiLNjUCfJ+w8fLg7i/IY/NQ 3f1JGEHBykouesX8P6oyp9b5pUT5H6L9yM4kI9+fLfWrvhfM0eKh4ypgwKr2RLbQm94h w0Hpas2SOh8W0ipukmYoFHszTzUEDQdA3wX3ZTiujuuu2SKPG3j6k8MijNryMb6Vu1JN STxYeCL5LZbuYTf4clNDGgYMX279qa5Z1XFwBONfc1lpinDljdRxN+G1kPlUJc6YzMvm HWfzyMiuCDpvsjrfR2eUTnSkHRL89ZOngxZBRD+BWI5NLvnvnKLnNcPH0HNEw8cZE4i0 4h9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vWJIpnZE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q13si4146793ilg.122.2021.04.22.11.14.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Apr 2021 11:14:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vWJIpnZE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZdqJ-00021v-Pc for patch@linaro.org; Thu, 22 Apr 2021 14:14:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZdkc-0008NQ-1E for qemu-devel@nongnu.org; Thu, 22 Apr 2021 14:08:30 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:43899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZdkU-00043v-O8 for qemu-devel@nongnu.org; Thu, 22 Apr 2021 14:08:29 -0400 Received: by mail-pj1-x102e.google.com with SMTP id f6-20020a17090a6546b029015088cf4a1eso1419411pjs.2 for ; Thu, 22 Apr 2021 11:08:22 -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 :mime-version:content-transfer-encoding; bh=bJ5I9s7dg9qHK409QJoe2gt4MUYWY6bp4k2kmR2aZJw=; b=vWJIpnZE4OqA5Q00aBnKbQrGNq4BC+6iZzDdhR8a+2h04d/sslbUJ2AJDjbU21pErQ ahnYBac/r0SrdEfQwgiAhBURS/h9u/0MJXL7eA47Qp/fUVkEtcgDp7C24psPN8f7K3km tdWWLu67AV7tPmMAr2311nVxiO3uIbKsWMesQyYiC6kQi379G6QuMhUr1QWp5D7fTmL7 5oJtTYSS07ULyaET0IqgRoOsJYpCTW9cg/cgUwH5Nd8MpUs4f9i4nukdyYBiqzEX6emd 7D2RWOw5Hvm9FmrPNtVDbb1us2Yg+8qvgt4ovOr3eDDknyFVCLn8YUz2+fr7XB6calCh ftmg== 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:mime-version:content-transfer-encoding; bh=bJ5I9s7dg9qHK409QJoe2gt4MUYWY6bp4k2kmR2aZJw=; b=AWy89YOp86I5pbe0Q9QowNBEl74fZ8jTg5pMnuwewxW80gl56mb0kgSo/NB9jFdFln kMd2iFQcD+gozCiXBiFFRwh35FkZNVBlZoZ3P8Gsy2cGjfrY+/EGF2ABMJYB/OKYeP/0 NSeqonFcFBQgcPeoVHSOIoxwCngpvBc1k+3B4e4WHQeyBe5kMh9o54+bj8slKGM3DINs +iR4EpNqnSJsfz80p+wFs5aYxFHhIV2SUNey5NQFDcHhcoYpA0koaCG1Zvp1clL9DtY0 tccJsXbuBoNuYiNNGVr1zw30xG+ZJ48e9XDfZUl2PEPsKCyVQnloXjrNkRMSxSiPJe3O APhA== X-Gm-Message-State: AOAM533Vgu8Ib/OJD7gM197a8GzN2J2Nv4+36rWAwEOOauCG7FeJ07YG ldOe/as9TxGeidDmX4tOP45O9kkI3irxkw== X-Received: by 2002:a17:90a:d48a:: with SMTP id s10mr6491pju.184.1619114901097; Thu, 22 Apr 2021 11:08:21 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id q6sm2606508pfs.33.2021.04.22.11.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 11:08:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/2] linux-user/alpha: Fix rt sigframe return Date: Thu, 22 Apr 2021 11:08:18 -0700 Message-Id: <20210422180819.252121-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422180819.252121-1-richard.henderson@linaro.org> References: <20210422180819.252121-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We incorrectly used the offset of the non-rt sigframe. Signed-off-by: Richard Henderson --- linux-user/alpha/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c index c5c27ce084..86f5d2276d 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -200,7 +200,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, &frame->retcode[1]); __put_user(INSN_CALLSYS, &frame->retcode[2]); /* imb(); */ - r26 = frame_addr + offsetof(struct target_sigframe, retcode); + r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode); } if (err) { From patchwork Thu Apr 22 18:08:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 425877 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp594262jao; Thu, 22 Apr 2021 11:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5Zi/0I+Gml7l/L0kGu/nk+2G8XoSJlLAf8vqHWW8SYjKv/Ydu+uClYZ9BydgJV5Woh0Rg X-Received: by 2002:a5d:9959:: with SMTP id v25mr68576ios.85.1619115029160; Thu, 22 Apr 2021 11:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619115029; cv=none; d=google.com; s=arc-20160816; b=Ww9IMDbgyMwjoM7GyOiqSNLcE78yH7DI5fkFFG5rpFQ9kmEtSPGb4P56q0xXOXfrCd CQdCZ3dTEpemDK2ld5MPFgUWrmsonILo6jGJtBXD5GhMHKMfMwT0FtiyX81lQegk9u9O 0krVooMY+qh9EqCXaPmha03oXlVuWzbNpMWDruxYqqc7yyrxiVP0Jqw6e7lQA4wlLJdy tPS8yC8IIUwSlLRg+IVCSP+Lwf7AMRCjlEM6NBziumQq2qM2ybtFkpe78k3vMJO/ev/V rjIrmlggHwc0KXQII1Cswc718tvq+dw7fxtupDXio7+DQ+dUPD6GvilWNHUKj1tyMJwo AxcQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=N0a7DmIM2LUgyZJG75mINEJOa0kwDbiMG8yxiWS7sPg=; b=jovWv7Tlzz6vzyDU9ZrD5VCIX8bw9gZujq1mcTD5keazavsbN1AD7qFSya2FK9de/p 0drv7fH1rp1yACAKSN27yrPtlfsFd1NiNPx2jnV37pgMd8IgHOKzjX9KizuTNZYHLxaN 41dTXrei6Cei/4ojqufBHrv1OGATBNdb2nS6fPga/11dUnW209DT/LeHb9ETPEV/Q+AQ mcHENKau+yFxYH7pEQiS/zcMRHkJXbwwI9X9J4ebHJIF3yOMRr3rkMPrSp/liFB8gpJ7 L0pa2X8HboOLXe537zHyeqhUlV6j1YoDzrgpZdRp5bALXKP2rpbs5A3vi5H/V3WwN/VL f2NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bwF/nE4L"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j13si3530274ila.48.2021.04.22.11.10.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Apr 2021 11:10:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bwF/nE4L"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZdmW-0008PR-Fh for patch@linaro.org; Thu, 22 Apr 2021 14:10:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZdkc-0008O0-Lx for qemu-devel@nongnu.org; Thu, 22 Apr 2021 14:08:31 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:35565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZdkV-000440-1D for qemu-devel@nongnu.org; Thu, 22 Apr 2021 14:08:30 -0400 Received: by mail-pj1-x102c.google.com with SMTP id j14-20020a17090a694eb0290152d92c205dso1433426pjm.0 for ; Thu, 22 Apr 2021 11:08:22 -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 :mime-version:content-transfer-encoding; bh=N0a7DmIM2LUgyZJG75mINEJOa0kwDbiMG8yxiWS7sPg=; b=bwF/nE4Lnzian+xTv8ImMAMmQnKWy8HVbBhCS6pkPiAM/gRLf2zwohUag6QKiCMuU+ gGfVI0PaARJz7N0ePkYrGinETuretwwCt/k1ByjwUs8Nak71ThT4ffoger94yog9hKha Q9gnk6s6Dgsl2klNCoEgBoCbBzuzhYC0cycHN9RZHx4q9xm/xvWZIBn+g4haqRdAkbiL YmNDyIYKILGw3fechxnFKQgrPMvd9VneWWW59GLZIxqy+d2OqSi5OzFt+derKypfNOwW 34KNTQImK9tSsb1W93ILxmaMfpGG/oLq9O7+TBP3ra32x9GUYjYHP3nCz2tPIN4+z+ln baTA== 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:mime-version:content-transfer-encoding; bh=N0a7DmIM2LUgyZJG75mINEJOa0kwDbiMG8yxiWS7sPg=; b=Kdrv7kh0kpspcSlggCr1UsmbqdfgnH/qHeDfT0mzyVS5dsAg4vR6SGThEpsN7W3QJP O104LU4ZvJ6IyNefgFdvfxaf+j8oFwd7Fs30evZcfqe1Mx6ou+qIcj8bf1icJfPfNvjz n9cD247cR8hexOoDmGeVg79HBv/6EeswAgLAbGcNVhKYD1pnUebx6aTQ/VwSlgq/oTTK O5ZbjRJkTdlWXYa/sPKJukOmv9UqTbWqgaXZT9Y7qziGMGxPjzyxu04nao/9Q0zB++ec L8Z3i91qJ65G2+78mGn6XjmNbEsQzbABblb0GqJypizSmj4uEKIbzMFG1sPr7hUXNU1R zIkQ== X-Gm-Message-State: AOAM533yq0wPj9qw0FLmrfyqDOPyvNPmi0cboF6NG/fMYqMY6TxdZw2+ RdS1NRhpQg/+BZnImmyv4J6SoXm4wSyADA== X-Received: by 2002:a17:90a:fd83:: with SMTP id cx3mr5077542pjb.41.1619114901718; Thu, 22 Apr 2021 11:08:21 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id q6sm2606508pfs.33.2021.04.22.11.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 11:08:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/2] linux-user: Clean up sigaction ka_restorer Date: Thu, 22 Apr 2021 11:08:19 -0700 Message-Id: <20210422180819.252121-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422180819.252121-1-richard.henderson@linaro.org> References: <20210422180819.252121-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Pass the ka_restorer value as an argument to do_sigaction, and put it into the sigaction table. Drop the separate TARGET_ALPHA struct target_rt_sigaction and define TARGET_ARCH_HAS_KA_RESTORER. Tidy up TARGET_NR_rt_sigaction, merging TARGET_ALPHA, and TARGET_SPARC into common code. Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 17 +++----- linux-user/alpha/signal.c | 8 ++-- linux-user/signal.c | 4 +- linux-user/syscall.c | 90 ++++++++++++--------------------------- 4 files changed, 41 insertions(+), 78 deletions(-) -- 2.25.1 diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 25be414727..226379fc9b 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -492,7 +492,7 @@ void target_to_host_old_sigset(sigset_t *sigset, const abi_ulong *old_sigset); struct target_sigaction; int do_sigaction(int sig, const struct target_sigaction *act, - struct target_sigaction *oact); + struct target_sigaction *oact, abi_ulong ka_restorer); #include "target_signal.h" @@ -507,19 +507,16 @@ struct target_old_sigaction { int32_t sa_flags; }; -struct target_rt_sigaction { - abi_ulong _sa_handler; - abi_ulong sa_flags; - target_sigset_t sa_mask; -}; - -/* This is the struct used inside the kernel. The ka_restorer - field comes from the 5th argument to sys_rt_sigaction. */ +#define TARGET_ARCH_HAS_KA_RESTORER 1 struct target_sigaction { abi_ulong _sa_handler; abi_ulong sa_flags; target_sigset_t sa_mask; - abi_ulong sa_restorer; + /* + * This is used inside the kernel. The ka_restorer field comes + * from the 5th argument to sys_rt_sigaction. + */ + abi_ulong ka_restorer; }; #elif defined(TARGET_MIPS) struct target_sigaction { diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c index 86f5d2276d..3aa4b339a4 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -138,8 +138,8 @@ void setup_frame(int sig, struct target_sigaction *ka, setup_sigcontext(&frame->sc, env, frame_addr, set); - if (ka->sa_restorer) { - r26 = ka->sa_restorer; + if (ka->ka_restorer) { + r26 = ka->ka_restorer; } else { __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, @@ -192,8 +192,8 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } - if (ka->sa_restorer) { - r26 = ka->sa_restorer; + if (ka->ka_restorer) { + r26 = ka->ka_restorer; } else { __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, diff --git a/linux-user/signal.c b/linux-user/signal.c index 7eecec46c4..de97cb8829 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -830,7 +830,7 @@ out: /* do_sigaction() return target values and host errnos */ int do_sigaction(int sig, const struct target_sigaction *act, - struct target_sigaction *oact) + struct target_sigaction *oact, abi_ulong ka_restorer) { struct target_sigaction *k; struct sigaction act1; @@ -863,6 +863,8 @@ int do_sigaction(int sig, const struct target_sigaction *act, __get_user(k->sa_flags, &act->sa_flags); #ifdef TARGET_ARCH_HAS_SA_RESTORER __get_user(k->sa_restorer, &act->sa_restorer); +#elif defined(TARGET_ARCH_HAS_KA_RESTORER) + k->ka_restorer = ka_restorer; #endif /* To be swapped in target_to_host_sigset. */ k->sa_mask = act->sa_mask; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 95d79ddc43..7c36650cbc 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8984,19 +8984,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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)) + 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)); + ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) + 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; @@ -9017,7 +9018,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, pact = NULL; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) @@ -9040,15 +9041,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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)); + ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) return -TARGET_EFAULT; @@ -9064,77 +9062,43 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_rt_sigaction: { -#if defined(TARGET_ALPHA) - /* For Alpha and SPARC this is a 5 argument syscall, with + /* + * 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 +#if defined(TARGET_ALPHA) + target_ulong sigsetsize = arg4; + target_ulong restorer = arg5; +#elif defined (TARGET_SPARC) target_ulong restorer = arg4; target_ulong sigsetsize = arg5; #else target_ulong sigsetsize = arg4; + target_ulong restorer = 0; #endif - struct target_sigaction *act; - struct target_sigaction *oact; + 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 - } else { - act = NULL; + if (arg2 && !lock_user_struct(VERIFY_READ, act, arg2, 1)) { + return -TARGET_EFAULT; } - if (arg3) { - if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { - ret = -TARGET_EFAULT; - goto rt_sigaction_fail; + if (arg3 && !lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { + ret = -TARGET_EFAULT; + } else { + ret = get_errno(do_sigaction(arg1, act, oact, restorer)); + if (oact) { + unlock_user_struct(oact, arg3, 1); } - } else - oact = NULL; - ret = get_errno(do_sigaction(arg1, act, oact)); - rt_sigaction_fail: - if (act) + } + 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 */