From patchwork Thu Apr 22 23:02:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 425881 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp784930jao; Thu, 22 Apr 2021 16:02:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNwt/TIvdSenK+waGJpz3/DzE+Gasst5hYEgadZB71zm5C5bVrWbvsNlb75iK1Nct4C1kE X-Received: by 2002:a05:6e02:190b:: with SMTP id w11mr685039ilu.197.1619132567728; Thu, 22 Apr 2021 16:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619132567; cv=none; d=google.com; s=arc-20160816; b=jBgU8LGlybVDV3WCLgAnAgp0LJRCkpHlaz1BQwIjLd+CZ2zkFntCtSgehgKjncsgfJ NPsZeYsRQjkBaLBdyuhhrq77GcGiy3HdLGnc9qCRFGE22FsLj7iGVce9mB06JgCJPx0s JT0+l/3HJBNlm7Ge4o+QsM/6FZITYsN2dLbF2F9rJWWKCvIxgotP8VuLq3xnzYK5rSCK Uu2UUZYORr3IdSbo6NkoxlAocoUKD8nHOKWR1wvvHACF4I6xkvqPIGsTbf6zDX4BabBn JMv9LXC5mLyZb7R45V/A3F1IKKg8w3SdUJ74DGoH/NJ0mTXKHc0UOiy8VBjfG3MPxPkP QLnw== 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=i2qHlCiJ2ypvQTREB0mNHsQoQ+IiJSRCvrbrqzPax/E=; b=eGD83sNNL9MSJtyo+NhIeNueLJwLHkZT4iV69rGksdtfK9BngCST1JOAcxf5rahS2r EfYVnxrN9Dlopijy+OXYjvjYA89x0zouP5o55UXoc1tOTLdJZjJSbpo/uIXbgWh72O0W Vbbu4CcUB6LVGNM5qce4eZX3LK9/o1cJUoCHM+HU1uqLwt3LW8yWsTadpfy9LYVZO3DB 6JUrDM3FZC6fF2ExINK0wdRpgBgps0jUCVSKIRhXpx0EaTmxmDHNMHs1bLwtK+3EHW6a TUqI48tJltt3NGzxu4Vw00Uqh9c9/UiYazW5pGR7WYIqUgDwDh0yGiNO6IfnTg16dVfY AWPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Dic/n7O6"; 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 w4si3682320iod.26.2021.04.22.16.02.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Apr 2021 16:02:47 -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="Dic/n7O6"; 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]:54324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiLP-0005AU-5n for patch@linaro.org; Thu, 22 Apr 2021 19:02:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLC-0005A8-4X for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:34 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:44831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiL9-0007ov-VW for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:33 -0400 Received: by mail-pg1-x529.google.com with SMTP id y32so33906663pga.11 for ; Thu, 22 Apr 2021 16:02: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 :mime-version:content-transfer-encoding; bh=i2qHlCiJ2ypvQTREB0mNHsQoQ+IiJSRCvrbrqzPax/E=; b=Dic/n7O6ICQOz1iGkTB5aoOiLwB53NZ1EwzjoR3OW+9JkKZ4MhYorNDWx4wpOqANae 0jyQ1LDF7QU2zCg1rmU4rwVmQCF3zdpHIalgpSJQ2eXlBmnvJadvy2WQNOUnyP9vFfPk FuLyj0MxSLmIcTx1PmCSaNyjCuMhlhBIJST2031JSnjePD/xAiblbWzU2FU42aGjVc71 CaL8UVFreGQzktIFRdXJgtiEg1F2GU/2f+Q+GZYAXHMt2/TcTnULY1V/GJLLpcDl8J57 eRVza+8RR5r7K8StrHuyCjPXSJ6u//rHat+jyUNJ6VVHcuiSckx5wMUYVe+CO68udEbS KCYA== 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=i2qHlCiJ2ypvQTREB0mNHsQoQ+IiJSRCvrbrqzPax/E=; b=p6bhkNBEJcI/KigyQM8Q1GclQip/lRvDwWykRcu0KLAN1FWkSV6f8mtsm6gaq04NSD nMPYuQX0kiAH8AZSQpX/nPX6DarhS4k9ObvTqYUmPpE5eVLmbZWHdQV/OehJV2xf++oc JFRzpObn5C5kx1DNPQGhV309ApBV42zeDKFCEZEkjsXAkxnqANQdK4l4e54OLX5l7Bi6 Fy5TAtt0RVnXfatJv/6YOL69R7nigP5PKIYlSvWmLHPSWn42EneK9I5IRExDWzrovOVa lBkWjptQQuDXtvCJnSZdfj/G5wOoegWCyKk9atm7UlGFa7AVY6R1P4LPX6oi3KnM/7e0 JwAw== X-Gm-Message-State: AOAM531r5mLpXgc17vva3Z9qG3xE+E/eQUxzKClL8eTVdIgBX+JRu0n5 Qsv2WQ9bGsD8bRtXRKcLYJYQRa/KTopwgg== X-Received: by 2002:a63:3c59:: with SMTP id i25mr943724pgn.366.1619132550121; Thu, 22 Apr 2021 16:02:30 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 1/7] linux-user/alpha: Fix rt sigframe return Date: Thu, 22 Apr 2021 16:02:21 -0700 Message-Id: <20210422230227.314751-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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, =?utf-8?q?Philippe_Mathieu-?= =?utf-8?b?RGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We incorrectly used the offset of the non-rt sigframe. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/alpha/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 Reviewed-by: Alex Bennée 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 23:02:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 425885 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp787249jao; Thu, 22 Apr 2021 16:06:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx7cvEfs0tqrvTK/Ve4ibTEMMeqCTItTgGb8mVLzRccbm8X+ItUpVkptjz87gORlo06w4I X-Received: by 2002:aa7:cb89:: with SMTP id r9mr939215edt.245.1619132772330; Thu, 22 Apr 2021 16:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619132772; cv=none; d=google.com; s=arc-20160816; b=bg9lGZjgmzN/B2jBCCsRJcoHEiXf+Gp+xSZ9Vrq0o2+HnigLs8Slj+TWnOxYkF/CwD B9eyauioXe6EILSAWIRm3gfEWyVuUk+xoCFnJjVU9I9J0lHUeRcTbOCLoRmwcxfbWx4j KgcYME1yNVUST9PBK7Ph1+oR6oRQlLPOE/4QKct3rSV0IqWtUhgF/x+Z7rMgmBKitUQO POA+FDO/6MMxhNQs+UWtFCxMtZ9hdfiTO7X1XeY7jznuv7uXzFJaZRuVzFVFKHzIdm2d nlUX1M6W5ARa2OschbzK+Od5WMt64PJAa+pl58IZT9+HtltPdQQf4bvORfvuao6zcPAg fAsQ== 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=E3bcQGoF5tL2SwrZa81gd5wA84VGUXSBs7q30g13W7s=; b=0gdGndfXQh/rsm9WnR4kO3AlLYicHJzgWoe0IeSq08Um6/t+6sL333+wfrBt/CfmJA dP3BXpktFXy3FPkXXnAwBy7U0JWB7McBqcyP8PO5dzyLMytZSBQC/PNfNA4Vhx9P6wt2 cCP2ICbPIp5GEulyPZJNaIIA+iFSUgc8tQByHNiv3RXpHFQGyHAr1pGURjCnAnX+1gSO v1/nGDm5s1gdAB+1VQTERWiZRJY4nUI/qhmxLq/fLLXTqe3noRon2Qr0ILr/nop6SO+5 RgkKTCg1r7397KqvN3zux8JmhzvV25iamAmgbc/SPN5QvwYZf+pOXDUnKifD/2gPcwA+ eqNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z8uoVgCB; 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 w5si3429223ejz.607.2021.04.22.16.06.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Apr 2021 16:06:12 -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=Z8uoVgCB; 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]:34372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiOh-0008UZ-Bl for patch@linaro.org; Thu, 22 Apr 2021 19:06:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLD-0005AQ-OC for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:35 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:43549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLA-0007p2-UH for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:35 -0400 Received: by mail-pl1-x62e.google.com with SMTP id u15so15754627plf.10 for ; Thu, 22 Apr 2021 16:02:32 -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=E3bcQGoF5tL2SwrZa81gd5wA84VGUXSBs7q30g13W7s=; b=Z8uoVgCBCKRqwEyyy1CXT+mgEXTiPQK5aDHiBM7TftnnuVidzhBNCWd5KknmnKCQ0G X1DBKTZ06hoX/atHKDcyFQSIpAEu+NcouEWH6xIDMEvLXS/dMZDDrpTLHZsmWaFUHPGY Fnrf6y1hWrIw0ZgWkVk/JCZgsI9ZCCKYynVgAMtgW18rIKYIZN/9j7TdL6jpqiaT9YqX pjr3FhMUpNwMsMa0aKa+eUJeKeNz1mRd1ewn4N8ZPBEZJs/PSwlyuZnlQxGQzdq4ZJWb c7WOO3Iqq+xpF+kGFLDqe7Ds9kG6jyo3Cllxf0nkyLvDrmHfPUa9evFn4fAA9vEtfxEW axDg== 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=E3bcQGoF5tL2SwrZa81gd5wA84VGUXSBs7q30g13W7s=; b=lsCPdh+/LgFQAAvl8Qsqc3/jValaiCtQJV1uQVZnPPxwxyEYSthQ47DOYfFB2n9xiC WHyrl6CD2Vr71/76M+jq75RVbOsf+ZQB8c7rA6kY/pqZHw4bDKRs5tE+YzbmFwehpY1A ZJzdumMfKwTbhMfUfm4TZ2eNHCI+3LV7MvC7ZU3OGkm8zDL1ZfZkrGYNTfTKlkclsV11 3eXpPDArSaLP9U0YyaqewU7wgTMFP2scVf9f3sWIyOmmfNpEJ5zHuXgNXhDr2dJ1e8Cg MK1RoKdDWs7xKPF5SZiBxC8wGcI7a+cU3quZg+IFFIOVi7cImGXqBMhJ901qivE8wjkF KMQg== X-Gm-Message-State: AOAM533xIrY46ig7m6B+sc4s6bld1JuOP4LiVqyVlsSqZyx5WjIH5B5X 0yS6D1Zab3KJPSjHTxXAjF5vybdA1NULxQ== X-Received: by 2002:a17:90a:4a8f:: with SMTP id f15mr1136828pjh.19.1619132550891; Thu, 22 Apr 2021 16:02:30 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 2/7] linux-user/alpha: Rename the sigaction restorer field Date: Thu, 22 Apr 2021 16:02:22 -0700 Message-Id: <20210422230227.314751-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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" Use ka_restorer, in line with TARGET_ARCH_HAS_KA_RESTORER vs TARGET_ARCH_HAS_SA_RESTORER, since Alpha passes this field as a syscall argument. Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 2 +- linux-user/alpha/signal.c | 8 ++++---- linux-user/syscall.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) -- 2.25.1 Reviewed-by: Alex Bennée diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 25be414727..693d4f3788 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -519,7 +519,7 @@ struct target_sigaction { abi_ulong _sa_handler; abi_ulong sa_flags; target_sigset_t sa_mask; - abi_ulong sa_restorer; + 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/syscall.c b/linux-user/syscall.c index 95d79ddc43..ee21eb5e6f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8989,7 +8989,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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; + act.ka_restorer = 0; unlock_user_struct(old_act, arg2, 0); pact = &act; } @@ -9085,7 +9085,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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; + act.ka_restorer = arg5; unlock_user_struct(rt_act, arg2, 0); pact = &act; } From patchwork Thu Apr 22 23:02:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 425886 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp787291jao; Thu, 22 Apr 2021 16:06:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB8dZWGDo0Zs8l9G/hqVNNW/ASZEsDP9btLoYJfCwwlFIwu8ug+gCWY0FGkQKcaYzW4x8a X-Received: by 2002:a17:906:168f:: with SMTP id s15mr1061269ejd.144.1619132775740; Thu, 22 Apr 2021 16:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619132775; cv=none; d=google.com; s=arc-20160816; b=PTZD8FqVx+Bdgk77DeTVtxcix7xqOd2VJ/goxmvJ3btttyOWJchQPbSt/KwKIKUD1k uVXKNOgZVKgijXVl9MYIH/H/oG/e2uUSFq4/mFtIxxQApmwBCPOJdqxkPNAoupuzTpMS pWqQCnDKV0RsPhldjZyFJmqeUgHJwAU3QJjp0Du7awDU2NsDy2knSaBhi29EqE8+IETx WWfDMABSchshpw3tKGeqwntSjGbUZcotmEOnm7AJH38lmUyPvy2ShC8ZImMJ5nf5WN/E pgxwc4jzr6yqGrSGfMYO3sQBH4rNSDjjUI0DoJAVgVb/i4YDelZgDPFBU+ISuUsiICPj ON6A== 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=OcPohUJWUFK5d9fBWTi1civihLvFybtJees054KN698=; b=JN9wdGJmdFGBq15U+eK6b3vXnG7k+owIAOJqd0yu1QHOFYXpqF6Yv0+CUCbA59ux5r U8SamXTu7wyECPqG6fd7qfAEREZ7XR2ETUOUmk1jLLsGURFVgLeGV1ikHNtrve+988YD yVnOKQFbgvZxU8uaD64+Ta2Y+uQa2pnt5wM7soxpG7JWg/Rs7AFljPA04ZgmfEvXk2wr G3GSijvip6xEz9f0nOPzf9ZX6jOqj4UYb1sPqxH9/Bz9TGTslET/xIe3L6cQ1Y1pAgNj zUqGkwjyD9EMOhyPwQbhPFE50tHow49+RzDCBWYjexD7ht+HmRLx37bbPC/VyDKIYXrD GVCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nK+8iNGg; 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 dn3si4100160ejc.198.2021.04.22.16.06.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Apr 2021 16:06:15 -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=nK+8iNGg; 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]:34678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiOk-0000CC-NT for patch@linaro.org; Thu, 22 Apr 2021 19:06:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLG-0005Ee-0t for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:38 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:37722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLB-0007p6-4f for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:37 -0400 Received: by mail-pl1-x635.google.com with SMTP id h20so24313504plr.4 for ; Thu, 22 Apr 2021 16:02:32 -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=OcPohUJWUFK5d9fBWTi1civihLvFybtJees054KN698=; b=nK+8iNGgiElRkLPhvH2RntlROcVQ0UaIVOTu5rAW+MEVw6hMb8bKJzhyMD15Tq1Wxy hq08ZcBuEpAfNujI5yFJ11mA5BK3TdO0Gprx6R8hVq6Plb19krvuF+dkTaA2ZqdKICLR sY/4/vsOFg/XilXqx3Ef/ii2VBqg5sqfQ4YQ4nMlQ7SiJePNz5ii/rXof+U9F4swOh8C zcwIIQjvS+xiaBqzaVvR8KfhnssKcBXG5K1Qqu0cBT7dYE64yVaZ+SUP/4TMp6BYWdsN ag7envE1QPNxln8hEJXdZyJyk/Kq9L27iAfiL5tW9W5YcUW6/9YtfexxZgHNYIBTXsQB 6eHA== 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=OcPohUJWUFK5d9fBWTi1civihLvFybtJees054KN698=; b=P1SkwIPeBLTkHu1GuCPmIa48H0FKdL91/s5/7sVY0eeGZynLtwC7j1z3RDnVxmenFj elCc90ms5t64oJq6KmcXg3/APeo4Thcby6D6lqZIzBAeuQEUaEHV5twgnjEGLRy3TKtp 9uH1Gx6eIcDII4iwNdz3d09MpMXdqIknJtf+kBQw8I9mDTgcMkf3XGvvmJ4YHKQmPCX3 RCGERH5iNPJyZKR2HJo5Gk0jOgcvkA0dpI6wO/HwnbVMb/nQA5HZf4Fio+/62vJ9xbwB AR9QFMxqgRZ0yRKslsDVB4UMVyDQ2DbQigDie9ZC36tdTDC95YYwwt6+QxZB7pMK4SGm 8Kdw== X-Gm-Message-State: AOAM532Jsv9XI+dULAcsUtp322t4UeNpsmS4XrF9sZ8YUZyyj6dy7stQ MIzUbqDjjPPSNkxI3TQC9cC5ybELFbj9KQ== X-Received: by 2002:a17:90a:fb89:: with SMTP id cp9mr1089993pjb.47.1619132551466; Thu, 22 Apr 2021 16:02:31 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 3/7] linux-user: Pass ka_restorer to do_sigaction Date: Thu, 22 Apr 2021 16:02:23 -0700 Message-Id: <20210422230227.314751-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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" The value of ka_restorer needs to be saved in sigact_table. At the moment, the attempt to save it in do_syscall is improperly clobbering user memory. Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 2 +- linux-user/signal.c | 5 ++++- linux-user/syscall.c | 19 ++++++------------- 3 files changed, 11 insertions(+), 15 deletions(-) -- 2.25.1 Reviewed-by: Alex Bennée diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 693d4f3788..e4aaf8412f 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" diff --git a/linux-user/signal.c b/linux-user/signal.c index 7eecec46c4..44a5012930 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,9 @@ 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); +#endif +#ifdef 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 ee21eb5e6f..36169a0ded 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8989,11 +8989,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; - act.ka_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)) return -TARGET_EFAULT; @@ -9017,7 +9016,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 +9039,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; @@ -9085,11 +9081,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = rt_act->_sa_handler; act.sa_mask = rt_act->sa_mask; act.sa_flags = rt_act->sa_flags; - act.ka_restorer = arg5; unlock_user_struct(rt_act, arg2, 0); pact = &act; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, arg5)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) return -TARGET_EFAULT; @@ -9104,6 +9099,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_ulong sigsetsize = arg5; #else target_ulong sigsetsize = arg4; + target_ulong restorer = 0; #endif struct target_sigaction *act; struct target_sigaction *oact; @@ -9115,9 +9111,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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; } @@ -9128,7 +9121,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } else oact = NULL; - ret = get_errno(do_sigaction(arg1, act, oact)); + ret = get_errno(do_sigaction(arg1, act, oact, restorer)); rt_sigaction_fail: if (act) unlock_user_struct(act, arg2, 0); From patchwork Thu Apr 22 23:02:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 425887 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp787984jao; Thu, 22 Apr 2021 16:07:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyduN30D9zorLkMhl7SaeHmyy9DIOhA/zfgl67Rt+jSeSIZVTDb0sbRu7K/5VX6W9O3iCiT X-Received: by 2002:a17:906:584b:: with SMTP id h11mr1002771ejs.463.1619132838131; Thu, 22 Apr 2021 16:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619132838; cv=none; d=google.com; s=arc-20160816; b=iUrIkNDMaCsMndL+FoYPBeE9F50bPd1+IA+7UD6/Qgh6ezhy3zDCGGHuV0C4FFc9p6 oeP3DWLqMNEQv2tpkRUaDYY8P4Gwo36WQuJ7G26iRVx/tvj3MWMmXisJacrtOeZnaCH9 /JujrESYW3U7pXUoJgf3Zj+WYQbgV9SLXmnnUHJfw2Ka1NryFC7EaBbjzreZ/215Bn2e E6VUsr88pSePAlsUsxYHK5ekqiS0Nux3o0w1Pt7H/tWr0EPH799nFzgTW+FACoDOzsuE Jajr8enHaaMsFQnalS8lk8AuLfPWfPqIKI6wn3E5W/qOX/scR86bfahnBmjq+5JcFopo Km0w== 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=lssDGPyfuni9CuU6IOfi+DPva4cgyenF8vOgPbXMLPk=; b=Fo/YvFFrcChzSvHGUBpLY/xeS+7SPSF3LT5Tb7tc5rwlFpXu3qUrzxSQQ2syN1INvz mCeiW01aQi92TJNDm08yNDsCegweHT8LTgM0CpewPXdrNzmQUj4VhTn/QR1O+WAwt4hj VpjoZSecEATySAoUBQ8SaWoigmEG2RFbDZmemYP9Q3WYTGLpGoimVUQY8AgPWncneez8 Cy/AgNZqf6+vmvfqdSwU46kRDxcw8oeV6Hn4svzucqY9ERHhWSC0KpcQXOS83NSvhSBc Y7gx8xDihBqz8xAFGXROZIYiShdeXQ8acDOGWueIPEhPPPFKiQqgWK1oH0s8JApzz+DE 00Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MXesaNbF; 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 mb19si3674963ejb.553.2021.04.22.16.07.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Apr 2021 16:07:18 -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=MXesaNbF; 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]:38842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiPl-0001yy-3a for patch@linaro.org; Thu, 22 Apr 2021 19:07:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLE-0005Ak-2A for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:45730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLC-0007p9-5F for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:35 -0400 Received: by mail-pl1-x62f.google.com with SMTP id p16so20353559plf.12 for ; Thu, 22 Apr 2021 16:02:33 -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=lssDGPyfuni9CuU6IOfi+DPva4cgyenF8vOgPbXMLPk=; b=MXesaNbFzhW2/ZKO+ltPv8YM0ZD4L5WpCZBG94oPSWNzcZvxw2f42Q5xannurG2ZLg xCe27Xo7OWDg5Gkj5h3ylt9uhl7AzzFMal7JE6gq1l+cKzjFNZuHT1MSwe6unFWKDX3a DvlreW+WLHZq9ojN//Xl/GcXHpn5dJ0t/qZRKMns81VWoxp/pcY10lns6yudzU4vhdj5 fOsgzJJCVebeBLGgkUOCuJUpuMng9+eCqT4gINgHL2o3w4jkVgJFQ+I0/ALW3d6+eASQ 03pGgbeLy0mTEWg1ffhMD3CDW+ZKXy0a+Xy3zuJHzrP5HWwJw1ZpkajMzwHjuYhdytPD KSCQ== 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=lssDGPyfuni9CuU6IOfi+DPva4cgyenF8vOgPbXMLPk=; b=Sj6uWqshXRJbuHgsD5h3aVZ8wMvQqeZi+CEvQYDiNuBzi6bVkGfT8Yf2bgDVBNUiOL ty/HL8nxYuLNPXPVHMqsQ7RNxTQUR+N0aXB4xoWWWWnwp2MGamPXCm0BHRZH3Ukkfesw k31nul0EAZkA0OvnfEdK3GyuF9pJ8x6+/Fkk5YCw0mxZIdB5mTQNOfG9DrEHdnj36Lnt nizrgEn6pnMAGKDQ/F3v4I4/C7YP6tTm+DAhcnz6tZMcps5Q3WKIiRVojflQjOwuSQak v/7E0dIu99b7kJ1QcwWln/CTq3bpx0O4zTXl0E5/GcH85OV8FL8V3FIRGTgYiF1LAleP jzDA== X-Gm-Message-State: AOAM531IZGjWa2RIgW0ai0Br4lBVqiPH4cjpyPKgWPMLBnVUeGi7nSP5 qPxIiIqj0N8OIqhGjWEVvD6xH+bq9SyvIg== X-Received: by 2002:a17:902:d706:b029:e6:90aa:24e0 with SMTP id w6-20020a170902d706b02900e690aa24e0mr851040ply.42.1619132552090; Thu, 22 Apr 2021 16:02:32 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 4/7] linux-user: Honor TARGET_ARCH_HAS_SA_RESTORER in do_syscall Date: Thu, 22 Apr 2021 16:02:24 -0700 Message-Id: <20210422230227.314751-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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" Do not access a field that may not be present. This will become an issue when sharing more code in the next patch. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 36169a0ded..89d641856c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9038,7 +9038,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; +#ifdef TARGET_ARCH_HAS_SA_RESTORER act.sa_restorer = old_act->sa_restorer; +#endif unlock_user_struct(old_act, arg2, 0); pact = &act; } else { @@ -9051,7 +9053,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0]; old_act->sa_flags = oact.sa_flags; +#ifdef TARGET_ARCH_HAS_SA_RESTORER old_act->sa_restorer = oact.sa_restorer; +#endif unlock_user_struct(old_act, arg3, 1); } #endif From patchwork Thu Apr 22 23:02:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 425884 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp785899jao; Thu, 22 Apr 2021 16:04:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymf8/XPfrTPpk+gyGJUmRX4juYLIfNMdNUQHfOURU/8iJq4IvpxR2EpFG+oXrUktETiX0z X-Received: by 2002:a17:907:2d12:: with SMTP id gs18mr981268ejc.133.1619132650543; Thu, 22 Apr 2021 16:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619132650; cv=none; d=google.com; s=arc-20160816; b=CIlkIueJpIwXCvQwAuc4mZYQAQ543ckINDZMx0AXVMiLK/vBpatg5DjJC8KC+THiOZ 1soEN8gXdIehSm5GSPre1QRFH7RSPGe8AHJko4gXkFkLmzTFQwdEyEVGujFZzT2nGlPJ eQy1wVuCfwhThuds3k2dsYAyEaDNxEsv/zF4zECmZ6so8vBprRUYY0V7KIx1Rtke4yHD Howc77GtDY8kueExxEDIk7i0wgxLY6PrvqzxxLjCSXEIqVcl3tcuLlWJFJDg5JPJ2sJ0 nTkW/0Fk2NxSjFUHO4YciOsJ6vFhtEhsQTlGLxQhuhfTS501Av2Z25xKauqxHHCOmnwG i13Q== 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=Pq63tIitSEl/3DIHxaCuKkI+VTWbKxsaVUJWQ8jB2y0=; b=R0PbGG5BJaII7w8/nOMqSz3ebid8ngNqnwFyzyhH3/vwRUbBG0hS4PaUbslRj+TbK0 659ppDUo3f7Wv75oICY3eBOy25GvGLFvr7r09kpjmSowSxNoDIIDbN+nWeNr4qGCRzVl lwG6/K6RoGmabNvYv0prHrEdPOwesU6Je5YkwkiFzreqv0YmQl5T815/6T7hSGrmlIeJ gV5uDA5Q1LmOfQcmZ7KMqKyTgz7sEEptkaqe6Hzx8ccuPvL2UMYkj7O4Yxevatq5GtWP eDngoJUUl1JUtEGrwPzd5pfIkEtMDX9Qupy53bH3Blp34Ognc3Q9EoMjz3eJkU7jchEc rSFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MZVtRtGh; 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 t8si3669525ejy.77.2021.04.22.16.04.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Apr 2021 16:04:10 -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=MZVtRtGh; 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]:54610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiMj-0005Ia-Cu for patch@linaro.org; Thu, 22 Apr 2021 19:04:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLE-0005C2-Om for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:42777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLC-0007pG-Kz for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: by mail-pj1-x102d.google.com with SMTP id j6-20020a17090adc86b02900cbfe6f2c96so225273pjv.1 for ; Thu, 22 Apr 2021 16:02:33 -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=Pq63tIitSEl/3DIHxaCuKkI+VTWbKxsaVUJWQ8jB2y0=; b=MZVtRtGh6eepo5poAaJrndcIXlcBUIMHSdqOE55GuNbzB+IjnkXv2DN88FoFWIvFWK rX8heO1anc2b4+lNYp3ikXUicBbt6mPb20I3K72A4HRjnb2jdwX8dTxU5TiQAjk3n+aY vUB2uH1rUgGsqHK6J3owYEOrPjGG50fekU8wp52vqNbmi03qSjvtr0rO1gKGPpvpv4A+ mP2PtOJyQqlTqR7uuXztejjNSFnzIFxMMQTN0VbS3GeR7Lz42DeYKnNSD/I7Mz3C4fAP X5dXDm6QxlSAGXvrXdeEAtG7PBMPAoYrzIpeBSMM2MAexjxvxD29FrzzfjxYx9NFnDE6 MhTg== 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=Pq63tIitSEl/3DIHxaCuKkI+VTWbKxsaVUJWQ8jB2y0=; b=GrXFEjB/WqqBD+D1WqKYNRFqS1PA9ETHvVR528DM5XPdrEowF/iyiC8TKbivtoB8Tm bvMB49mmh+/b2d4FVRxbd86dzrXtnn4MSYsHLmV7w768UvP89fz7ZbOm3CpOCFtgWN/5 91X1b1v+RCEWNF9nNNj9nwPqDRzywkrKUCE8UugGE5AcC/oJ78Ze8MzyOPp2J7Rvix/W dwE7mmRAnmdPghoRZx2Y7G8cbgJiBLFuoOxlvacNbI7bD56uzWfj//Qfnw+qObXiPkm/ sp4lvGFBb9xlhF3CCh389zrJju4/fCRB8mOcbXRWdlgKJW5aTIqCC28zTpQYaQa58W48 V4nw== X-Gm-Message-State: AOAM533UHnoh5HoWATfvnssk88WPzvVd2eV/Xkk5twxpiVzPCJFc97Jz FNmt1JcJXe0X489llEsYs0yrKpbaYhL+BQ== X-Received: by 2002:a17:902:b210:b029:eb:535f:852 with SMTP id t16-20020a170902b210b02900eb535f0852mr845384plr.80.1619132552721; Thu, 22 Apr 2021 16:02:32 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 5/7] linux-user/alpha: Define TARGET_ARCH_HAS_KA_RESTORER Date: Thu, 22 Apr 2021 16:02:25 -0700 Message-Id: <20210422230227.314751-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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" This means that we can share the TARGET_NR_rt_sigaction code, and the target_rt_sigaction structure is unused. Untangling the ifdefs so that target_sigaction can be shared will wait until the next patch. Signed-off-by: Richard Henderson --- linux-user/alpha/target_signal.h | 1 + linux-user/syscall_defs.h | 6 ------ linux-user/syscall.c | 37 ++++++-------------------------- 3 files changed, 7 insertions(+), 37 deletions(-) -- 2.25.1 Reviewed-by: Alex Bennée diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_signal.h index 0b90d3a897..250642913e 100644 --- a/linux-user/alpha/target_signal.h +++ b/linux-user/alpha/target_signal.h @@ -92,6 +92,7 @@ typedef struct target_sigaltstack { #define TARGET_GEN_SUBRNG7 -25 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_KA_RESTORER /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index e4aaf8412f..7a1d3b239c 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -507,12 +507,6 @@ 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. */ struct target_sigaction { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 89d641856c..216ee4ca47 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9064,41 +9064,17 @@ 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; - unlock_user_struct(rt_act, arg2, 0); - pact = &act; - } - ret = get_errno(do_sigaction(arg1, pact, &oact, arg5)); - 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 @@ -9131,7 +9107,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user_struct(act, arg2, 0); if (oact) unlock_user_struct(oact, arg3, 1); -#endif } return ret; #ifdef TARGET_NR_sgetmask /* not on alpha */ From patchwork Thu Apr 22 23:02:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 425882 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp785048jao; Thu, 22 Apr 2021 16:02:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJya1ZQfjhiYPfS0swPTiBNXQHGPLU3ASyrNrC16dyM8vjJ7nDS8myf3UezUDYlgWkV1ydK0 X-Received: by 2002:a92:de05:: with SMTP id x5mr666487ilm.156.1619132576285; Thu, 22 Apr 2021 16:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619132576; cv=none; d=google.com; s=arc-20160816; b=oYy7laRv7YVIAJoXfa1xjYj7E5ZnXusXLkAWRFB/VY58+22z0jfvRO3hJ/NMr5nQrL p5BZI0kQSMxF0wNy8bBthNybQ24101rvNhVZvDikPcBxVL6wuU9l6KPIcDVz2m04lwco 6VHtE44PBHEFACrspwWguA161QX9C775k19R6zYeDlLfZCFDst2/zcl31Zpl4fAbhheX 9NwTj/+vZ4CvWUswM46l/FgomFdoYoWlqsUui97Jvn9sY3rDtMi7kpbtjAlHpSgSCBlS 2goxTQpyrNmc9mi01PidvCEv5vP8D/9/NzJgd1XfHZDqRV09mqWxV8ZuWk5L0aRMvzoZ 2QPw== 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=9IBgpRlXRDcwQhpg7EYQ7Dn5EzD7vaEg5bq7L4WY5HM=; b=Ly6PlEPkiO/KC/fOevFHYyDNTxfECCZHe3S3X1nV1qCqcDMhR41xqsi/hR4bsNQYRO H/aXadDqMnpxe/nCc8PY13lqLhl9p4KpwuKsANtNyxXH6uRTQbUO4qKU7wOeWmnhwmIm 7yhu84ZeqAfUAaU2LNRxi6elKRnjCwz3E/lZwLcfxgy3jOrUKouqy/kRZcwDvxzlBsyv ZgHSGDQDuv0Ius+NQgBXX5O8CL6S+W3vxzZSAPdLk7uydOWgJemSATri/9j3iv0eyiWH qGpYIxdeqeN5YE+bHVvowrQev/QTUWNyNhFK+cnTK04SOx9xEW4tFoDwp0oBo8HFwZJK QbTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=avWb8ynR; 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 m22si5782031jat.1.2021.04.22.16.02.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Apr 2021 16:02:56 -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=avWb8ynR; 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]:54504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiLX-0005G2-PD for patch@linaro.org; Thu, 22 Apr 2021 19:02:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLE-0005CN-W4 for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:37 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:40485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLD-0007pT-2g for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: by mail-pl1-x633.google.com with SMTP id 20so20356068pll.7 for ; Thu, 22 Apr 2021 16:02:34 -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=9IBgpRlXRDcwQhpg7EYQ7Dn5EzD7vaEg5bq7L4WY5HM=; b=avWb8ynRA7J49Tc/sUJZVMIW1LAdjHBf/5vjzQRzWX7xOKc08cIafzUFQtskoiV3B0 IScMgUuQhJaROSWth3xdwKMPX7O3L4d7sMESOi1j5tx0EtnT7Vk10UOIMmIuanaLMYNl d42DVyqFyj0wd6z8QmteiBpXOTE4olQm6hFYJdT99XkBFlLONCN/dybefuUM4DBhdUrw NwSB9TpgIQLN8aiIEjecvoGDqGW6KBw3VkhXUI6UcWF+i8/xpawayEKW5mC+OUVeG4sk BDBwluwNAiBcESviTIa0AbcXFGSnuWXpZRcnEbxV/4VhGa3dklaW3HIJAWZ9SSSdCRqY VzRg== 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=9IBgpRlXRDcwQhpg7EYQ7Dn5EzD7vaEg5bq7L4WY5HM=; b=FLjGcUIc4AIhSIZMmjTlROJblYshNC8JownBZpZFiFo8YO057LwHUNhpWnic+84WRV livBDsoXBfL8/bWn/rZ1J18kRBQCyUtsKGkxo8CBcT7N9tHk5IovCg8DrVCZ7P78XSr5 Gb2KXRF2tfDQg9I8yrUDzGoAYeRli29XT0D1crHa4jl6f8Z3ziw9B+COYSR1DTUBmXnE 14UOKLBPFGFI86VHuGpyPewKf4RNQ//1gqUfQB3WzGyG4hHy/C1we+VxY+5fDhaRmuZY /fM2LsF5z2wVDEAHeYLosZP1k92rDvo8rvA0PtO9S6R8llNHLKQYF5/1K1FINPQQCkoA fs4Q== X-Gm-Message-State: AOAM533dyc1QBCArvxW8vV5IbHjX1owz5wy3RYvptC4WSQnJ8IaEdalf 7Yux8qgOrhHg2PI/Kwl/RoeGvf/X8ABPPQ== X-Received: by 2002:a17:902:a38e:b029:eb:3963:5aee with SMTP id x14-20020a170902a38eb02900eb39635aeemr1142615pla.78.1619132553313; Thu, 22 Apr 2021 16:02:33 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 6/7] linux-user/alpha: Share code for TARGET_NR_sigaction Date: Thu, 22 Apr 2021 16:02:26 -0700 Message-Id: <20210422230227.314751-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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" There's no longer a difference between the alpha code and the generic code. There is a type difference in target_old_sigaction.sa_flags, which can be resolved with a very much smaller ifdef, which allows us to finish sharing the target_sigaction definition. Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 21 ++++++--------------- linux-user/syscall.c | 23 +---------------------- 2 files changed, 7 insertions(+), 37 deletions(-) -- 2.25.1 Reviewed-by: Alex Bennée Reviewed-by: Alex Bennée diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7a1d3b239c..18b031a2f6 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -501,21 +501,12 @@ int do_sigaction(int sig, const struct target_sigaction *act, #endif #if defined(TARGET_ALPHA) -struct target_old_sigaction { - abi_ulong _sa_handler; - abi_ulong sa_mask; - int32_t sa_flags; -}; +typedef int32_t target_old_sa_flags; +#else +typedef abi_ulong target_old_sa_flags; +#endif -/* This is the struct used inside the kernel. The ka_restorer - field comes from the 5th argument to sys_rt_sigaction. */ -struct target_sigaction { - abi_ulong _sa_handler; - abi_ulong sa_flags; - target_sigset_t sa_mask; - abi_ulong ka_restorer; -}; -#elif defined(TARGET_MIPS) +#if defined(TARGET_MIPS) struct target_sigaction { uint32_t sa_flags; #if defined(TARGET_ABI_MIPSN32) @@ -533,7 +524,7 @@ struct target_sigaction { struct target_old_sigaction { abi_ulong _sa_handler; abi_ulong sa_mask; - abi_ulong sa_flags; + target_old_sa_flags sa_flags; #ifdef TARGET_ARCH_HAS_SA_RESTORER abi_ulong sa_restorer; #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 216ee4ca47..9bcd485423 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8980,28 +8980,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #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; - unlock_user_struct(old_act, arg2, 0); - pact = &act; - } - 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; - 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) +#if defined(TARGET_MIPS) struct target_sigaction act, oact, *pact, *old_act; if (arg2) { From patchwork Thu Apr 22 23:02:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 425888 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp788781jao; Thu, 22 Apr 2021 16:08:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7Ru7mPa85UlKsuzL3wqVH41H7/NwTjnvs8KWkPMCxQvvectLsWWt9Aysr9yx5xGj3dySo X-Received: by 2002:a67:60c4:: with SMTP id u187mr1067170vsb.12.1619132909079; Thu, 22 Apr 2021 16:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619132909; cv=none; d=google.com; s=arc-20160816; b=pgCRhQwxXDZs4Ax/Vep0PHMgf+7QrDj5KjzyXnRAgRokoo8Ls6+Bw5Hcqf1LEj4lzC IMyMDcANqUKWPyYyPyxscQu4H9lPx4+XfjSDVdyX2V0Y96skItK0tQhwDHq4JNDDQ/0t hWr2y7T2mHAOFtA2UHjmqy1dxYNIriSB4FJNDrEXc3mXNry9qYxPjhPDpBuSDaHsiX6g 5795ySmYTpKjtEeeVtdpVOENlSh/74xui70DC5P80RTpgT1dKCpwlTXhs4BCWppjRCa+ aB/3pcU60dRk7gI0MblUysPauCuHBwhINgh2guNYi6B2GQPdnudo+EnZI+N+w7vGUhMJ G0UQ== 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=LKfV1I/Csk0qYQwhR0M4lp6iP2nYp4OTkUQuJPZGosY=; b=V9T41K2WB3bwEqcVqgJUuOfZR5Ws4tgAr4x374CZ815ryAGgdEE3+JS4GyWTeXsJbJ afWgv+iaYmxZshov+ryvm1ujggLXEKX3F1VcX2BKJU3jgW20xFLStmZ6qWN4X8DJ/DMy VNCzjacwd3vaysLAHfAz5Tee+B1aBWRLuoB2BWNOsAHcPo00Ovcl2+SVxab7kcIrXSM9 jfocDhQDZuyvYGF3dZ+Oa8pMuhknft7ewKUoTd/Tk4U4Pf2Q8gIL68UA//6bsTtkOCJS s9DRDQahwUtv6KmUySxA+QEeoG9lUwATsZYlWyLD9mQNmBIIDslRN3wgwB9Ey/6YnT8F RsJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C4QyKbBA; 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 n16si2648765vkq.32.2021.04.22.16.08.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Apr 2021 16:08: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=C4QyKbBA; 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]:41774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiQu-0003AV-Hg for patch@linaro.org; Thu, 22 Apr 2021 19:08:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLF-0005Ck-5l for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:37 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:39913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLD-0007pY-HA for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: by mail-pl1-x633.google.com with SMTP id u7so22494823plr.6 for ; Thu, 22 Apr 2021 16:02:34 -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=LKfV1I/Csk0qYQwhR0M4lp6iP2nYp4OTkUQuJPZGosY=; b=C4QyKbBANIxwH1YFMbdaY3BSVgMwjkdCbJ8cZPHBoIwx1zIxj9mDEdfin8uRo/p/Pt i1qwlJPHlbRLOOnthiFVWEpdZbkTF5JQnF/8ekARH+LQ6CW/C/MvyZN17xUMrnj9wTdi j/h4AM6dKUSF+j5jiRFxmFOo79z/y9rAjPttt11qKT6WAh0s5nEF715C0LjCCfhz88a6 E25AREdKNsasDGu8rY40qKNo/mvPeiGjCUyPioguruGBzznjancd0T5J7fcW0nbz3f6b bZmCce+Cw8+9bvx7UtVL2HMJbV9XtT8wUlCoEV+ZQuixfli/ELuO+EOxYriZvViR4c8q dtIg== 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=LKfV1I/Csk0qYQwhR0M4lp6iP2nYp4OTkUQuJPZGosY=; b=bmN/8EH9Effo7A1tC4kTCwnQkNYaaRlRxMQgl0s6ZdHpzftNROukyP0dynAEHFnJkr K1twtAZ8+wBpDLzpe9/qr9aKaICMSJpIPc6LtzOtb7ZKQMpcGRenequeBMROIZkUPSwM sWDaOBRH5SXceleqCO3G9S98vXc7PpDqyDEINAu+dL7IOBtl1ujyBYsrO+TzEDsGfNhK 8SWD06Ff8JS1uwJfifvzAswx+B9B6pcW8JxG9hZxZCiClTrdlmHfxiApdIIK0apWW1/X vGZtadv6RpHKfoK26E+wQ9myuYk1bmhMJpM+GAvoI0UTkwlLDCBloZIpK9Jf48WD6NXb kYAQ== X-Gm-Message-State: AOAM5322CtnbpBsBrOkKu4FZfchM+/jesWH4/++nCj3D26XdsjbGgw5b 4bR+DnDxnVCWUcVc5bI6FwXhsffd15jrNg== X-Received: by 2002:a17:903:18e:b029:ec:b394:981f with SMTP id z14-20020a170903018eb02900ecb394981fmr1161614plg.6.1619132553950; Thu, 22 Apr 2021 16:02:33 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 7/7] linux-user: Tidy TARGET_NR_rt_sigaction Date: Thu, 22 Apr 2021 16:02:27 -0700 Message-Id: <20210422230227.314751-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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" Initialize variables instead of elses. Use an else instead of a goto. Add braces. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9bcd485423..c7c3257f40 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9060,32 +9060,26 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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; - } - } 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, restorer)); - rt_sigaction_fail: - if (act) + } + if (act) { unlock_user_struct(act, arg2, 0); - if (oact) - unlock_user_struct(oact, arg3, 1); + } } return ret; #ifdef TARGET_NR_sgetmask /* not on alpha */