From nobody Sun May 19 06:23:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646752373148316.61603411296335; Tue, 8 Mar 2022 07:12:53 -0800 (PST) Received: from localhost ([::1]:53402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRbW8-0005dw-4T for importer@patchew.org; Tue, 08 Mar 2022 10:12:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRbMJ-0006p9-2O for qemu-devel@nongnu.org; Tue, 08 Mar 2022 10:02:43 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:34081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRbMB-0001P5-7i for qemu-devel@nongnu.org; Tue, 08 Mar 2022 10:02:40 -0500 Received: from quad ([82.142.8.122]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mc0Aj-1o1EDo0rNf-00dVc1; Tue, 08 Mar 2022 16:02:31 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 1/3] linux-user: Remove stale "not threadsafe" comments Date: Tue, 8 Mar 2022 16:02:26 +0100 Message-Id: <20220308150228.1616561-2-laurent@vivier.eu> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220308150228.1616561-1-laurent@vivier.eu> References: <20220308150228.1616561-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:g0/m7rk5vgMpUu+DmJ4kO/QPFY6DXLwcCyecfVQ7Aih7NFunlJ7 s/O7n8B+yKXrg2nIZp+nPxOsPhDCv604zMxlHYrhwkJ1GupY6iTy0GGmAP4UZkK0AZNxH1y PTpbEy7eMbmRFCpoviCEfEJmLakupxT9VOXxHADxP33pBVxFvKpn1O9m6jip8rlEZMtun9N XE9bjAF1VB/KG+NpFKIhg== X-UI-Out-Filterresults: notjunk:1;V03:K0:LzK3DYsLtJw=:YqFSzsJcTivoiku3HaGCwJ ke9x4+iNcNvOKtcGcG4E7Sxvt9vDlmAAVtltHAlaJT+NdhtM15T9KznXoCZRN9WIQ65xtMXSO FSmriWdqMN7HXPla6m8VMDJT8yafXheGzgndNVbxt3H2wc+/vexWJMbf2fT/WP0u+BkLuTD8q UZ6358R0QryLQIHZS9m4rkApn1mgiFcGi7DOVAut8RDIpPR+kI/cWEJt2tiD1kkOiKtuwN2MU jGu76TD4ChVSKb3JKRG5Znp/MffwoNtrGQLkOnjBuw8DWGsaTce6RtHiehMhYvsyex3qH9Ogu aylY3XVWD7qEAPFcEqta/DSm1LnfsdsBBpW7JqddvKlBya8bGeQcPQSK36Ltnd2GfwY7GQ4s8 5ie2ENPIAHyWNnABRkXdmI1kAus34KQlbKSOyqnuHNAUlLzNZiKdGcz+EpYaluJjMoUPYr1hp O7k08BlpooPvFTiWAnM1+S5DUFO/44YjbGPExKrysW2xTpxazbN/oPVkH6tE97Z4ti/25y84o 2VPiD7Ay3kKdN7wnrwtn1VScSx1qcY/uAf12adgwOgfLMpVgWJ0SUPfUDqJEELLXKvM19UFCH sG15PkBmp2LMFGMqQVcqr9wFoIrnK/yDO4Rc2fNchug7EyCbWS2Ti48O6L6j6h7cLxURVyTKl ooHfyQc7LBs+Mu95rv47U4RHuVwel5nFzKA1/CGC+Yi6/3NuL/7+12tmBk3Cj/DHq4sM= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1646752374684100001 From: Peter Maydell In linux-user/signal.c we have two FIXME comments claiming that parts of the signal-handling code are not threadsafe. These are very old, as they were first introduced in commit 624f7979058 in 2008. Since then we've radically overhauled the signal-handling logic, while carefully preserving these FIXME comments. It's unclear exactly what thread-safety issue the original author was trying to point out -- the relevant data structures are in the TaskStruct, which makes them per-thread and only operated on by that thread. The old code at the time of that commit did have various races involving signal handlers being invoked at awkward times; possibly this was what was meant. Delete these FIXME comments: * they were written at a time when the way we handled signals was completely different * the code today appears to us to not have thread-safety issues * nobody knows what the problem the comments were trying to point out was so they are serving no useful purpose for us today. Signed-off-by: Peter Maydell Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Warner Losh Message-Id: <20220114155032.3767771-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/signal.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 27a0ff30e971..2a3f3cc23f92 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -999,7 +999,6 @@ int do_sigaction(int sig, const struct target_sigaction= *act, oact->sa_mask =3D k->sa_mask; } if (act) { - /* FIXME: This is not threadsafe. */ __get_user(k->_sa_handler, &act->_sa_handler); __get_user(k->sa_flags, &act->sa_flags); #ifdef TARGET_ARCH_HAS_SA_RESTORER @@ -1149,7 +1148,6 @@ void process_pending_signals(CPUArchState *cpu_env) sigset_t *blocked_set; =20 while (qatomic_read(&ts->signal_pending)) { - /* FIXME: This is not threadsafe. */ sigfillset(&set); sigprocmask(SIG_SETMASK, &set, 0); =20 --=20 2.35.1 From nobody Sun May 19 06:23:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646752104855813.5908553566163; Tue, 8 Mar 2022 07:08:24 -0800 (PST) Received: from localhost ([::1]:41652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRbRl-0006CO-Rk for importer@patchew.org; Tue, 08 Mar 2022 10:08:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRbMJ-0006p8-2U for qemu-devel@nongnu.org; Tue, 08 Mar 2022 10:02:43 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:45533) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRbME-0001Pl-NY for qemu-devel@nongnu.org; Tue, 08 Mar 2022 10:02:40 -0500 Received: from quad ([82.142.8.122]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N5n3t-1oFP4O3L35-017FnR; Tue, 08 Mar 2022 16:02:31 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 2/3] linux-user/ppc: deliver SIGTRAP on POWERPC_EXCP_TRAP Date: Tue, 8 Mar 2022 16:02:27 +0100 Message-Id: <20220308150228.1616561-3-laurent@vivier.eu> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220308150228.1616561-1-laurent@vivier.eu> References: <20220308150228.1616561-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:C0YXGPelNegwDbXFjL5CHv+mmF0Vj+sUCn8WE1MWuK31S2WP+4y fLM4vwhF/KyxJs8y1UFLPGxC6FKd4irhizXr5gFTIQxWbiEUrANcNkrLQE8NIDDviae7V5x OowwfO+fR9e1ro93/JGVdfdZn/xdFY14Wzx3mhH5JuoT6c8uuam8DOfg6pi7AamFhnxKm1I yRJYedc/zmXd7E/h9xlSw== X-UI-Out-Filterresults: notjunk:1;V03:K0:qxUEWptHZkY=:ITqxbkNX78Om62qm7gHpVN zU2fI2/S6ZjNdFW8QOvR8IzVt9Zrf7pc2zsg5NvBpDPP6A/2RbgsXBHfkorqgMNQeOuOTA3ow vKF/1TPmYNlAEMle/qgL4HBKKW6HQIm4EL4HPtu9Ur1+8pWkRJXASqstrHIdU6L55Gq7fh9OW dZnJ6uu630C6m2uoZB8Nne1lsR6kdCFkvRaPujPdfJC1tQ8LUEq0bn9W4XdEf4U3Yk++tCtjX pe6EXUT2T6+7hcqIo8L+YAWLPP7n0T7dRrRZxR9UdyfBO5P3O4wu4B/t/U01fqcHz2Wn+P28G /Hm+Kpy0nRMmu2GzJxE9p2j6WjYlR0JoMHO8NJ6k29b1SrNuQ61XoFoppCzWEzdgpXMPEjvDm 3ioIqcgkMkremmcxgJtplx/32E92X9O4XnNfiYCF7owzUorPXBP25FIU09HQjUmpJO196/U6v Ix2EyucQBFgj1UgL/9CTdgchBYaDFUevQPHNQePpiY1opnr63q2Wb/H9Ff47QsF7zXFrsSrLV M55ovTRYQa88f4zwxNumwHx2/DeY+Oew925rf8K9GYVypQEiCm7+imenD1bgm6+tuMUaZ8DDK /ckysao+VYum0Yv1QzLLEqlq48ByNoy7m5VCqK7Fn3C3pIOaTAPxEX1BWgr+gHUuGYIFkoxcZ WALZn+r18IBvIeE6UvSZRBdTSFg9QEOows5JITXhoGFCr2nyP6Fw1gh2/KROee3UNXUc= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Matheus Ferst , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1646752107245100001 Content-Type: text/plain; charset="utf-8" From: Matheus Ferst Handle POWERPC_EXCP_TRAP in cpu_loop to deliver SIGTRAP on tw[i]/td[i]. The si_code comes from do_program_check in the kernel source file arch/powerpc/kernel/traps.c Reviewed-by: Richard Henderson Signed-off-by: Matheus Ferst Message-Id: <20220113170456.1796911-2-matheus.ferst@eldorado.org.br> Signed-off-by: Laurent Vivier --- linux-user/ppc/cpu_loop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c index c5d809916f51..b468f199e4d2 100644 --- a/linux-user/ppc/cpu_loop.c +++ b/linux-user/ppc/cpu_loop.c @@ -181,7 +181,8 @@ void cpu_loop(CPUPPCState *env) } break; case POWERPC_EXCP_TRAP: - cpu_abort(cs, "Tried to call a TRAP\n"); + si_signo =3D TARGET_SIGTRAP; + si_code =3D TARGET_TRAP_BRKPT; break; default: /* Should not happen ! */ --=20 2.35.1 From nobody Sun May 19 06:23:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646752213829343.20317875791; Tue, 8 Mar 2022 07:10:13 -0800 (PST) Received: from localhost ([::1]:47630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRbTY-0001nw-RA for importer@patchew.org; Tue, 08 Mar 2022 10:10:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRbMJ-0006p7-2e for qemu-devel@nongnu.org; Tue, 08 Mar 2022 10:02:43 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:32839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRbME-0001Pi-5a for qemu-devel@nongnu.org; Tue, 08 Mar 2022 10:02:39 -0500 Received: from quad ([82.142.8.122]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MA88C-1nKQcs19XG-00BYqK; Tue, 08 Mar 2022 16:02:32 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 3/3] tests/tcg/ppc64le: change signal_save_restore_xer to use SIGTRAP Date: Tue, 8 Mar 2022 16:02:28 +0100 Message-Id: <20220308150228.1616561-4-laurent@vivier.eu> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220308150228.1616561-1-laurent@vivier.eu> References: <20220308150228.1616561-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:QikEJERJ1Cq9jEKmiElBfDsuTyEoq8AKUf4Em9T11lhG9Q3PlQf JDVj9+/HYeOw6vtFS4Ihoz4oDyEezcsriJzFxWOXRlO9teldaAbASj9hRWrHGkYB9zTjXlN w37ipuxVmGh79lRkEBujHgAiYDNq43MulJv/4mTSDAxPViKG9V/btftEPJIGWW3b57X3G38 gY0VPJcHVf0Lii0KG7oHg== X-UI-Out-Filterresults: notjunk:1;V03:K0:Tx5IUjlafhc=:2fOVi83c4ZiuJfco6S/EyK M1fOxlZ1/3ljojRcpsjckIlfnjMjVkGcZSzV5PCeJ+oyOapfHQ3SQejaMvsGPXDgTprPKqt6z 6tN97Djo/4GMbye1Iqx7TwT9280haokUMo/Oxda5rgwwAcmIva6sr6/ActcnA/IUeQ2TaQlSB AoDXXbjJOpPF/+/ETHPXcatq3FiUY3/D3Hath5wG/RPFlqtDBWyEjUW8nSMaPPKc6MArh6WPm J85XWoruHC483TUDb4m6veLCUfWm16CvXugN4cb30fXecymTY9+fY8WceS4PQWXGLS/YgvzWD 7NXUV4Brgp7FjtP1aTX0B4YCHI2IfvLtLTeBgeDPAV4z4dU1Q3zPkWzFnOxMHTkumOf39fvDa J3F2a9aYleor6s2EJHAfTtvo+ZxHY09zym+5HclEOgHTe4GSZb89btsQdgSL6F7EgWz5JtpxL KSI4GTFB9qzQT9B40Cz3591PazMSigDkHiYeybdPCCqZLLQ2fdQZN51W8G8kwSxc0FT7rQNS7 nSi//wBao+01fr770vDLZON+eqXouuOzkApOVhRSXKGE3+mzx9pHGKkCOyu4e1XGvGpFzp+tE ue/8A3uRpN5O+V+MvwpH1bm4RZAgztP1PjSV2tt7cGakcfUd/4HXKD801cAWFoxYg9D4nEKQu DiTwlf9TXkpW41J210JaKErag/KGd7hjOmM83lsrK9TAtcdshjQg9rnt6N1pOYX4Ud8g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Matheus Ferst , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1646752215083100001 Content-Type: text/plain; charset="utf-8" From: Matheus Ferst Now that linux-user delivers the signal on tw, we can change signal_save_restore_xer to use SIGTRAP instead of SIGILL. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Matheus Ferst Message-Id: <20220113170456.1796911-3-matheus.ferst@eldorado.org.br> Signed-off-by: Laurent Vivier --- tests/tcg/ppc64le/signal_save_restore_xer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tcg/ppc64le/signal_save_restore_xer.c b/tests/tcg/ppc64l= e/signal_save_restore_xer.c index e4f8a07dd7e0..9227f4f45551 100644 --- a/tests/tcg/ppc64le/signal_save_restore_xer.c +++ b/tests/tcg/ppc64le/signal_save_restore_xer.c @@ -11,7 +11,7 @@ =20 uint64_t saved; =20 -void sigill_handler(int sig, siginfo_t *si, void *ucontext) +void sigtrap_handler(int sig, siginfo_t *si, void *ucontext) { ucontext_t *uc =3D ucontext; uc->uc_mcontext.regs->nip +=3D 4; @@ -23,14 +23,14 @@ int main(void) { uint64_t initial =3D XER_CA | XER_CA32, restored; struct sigaction sa =3D { - .sa_sigaction =3D sigill_handler, + .sa_sigaction =3D sigtrap_handler, .sa_flags =3D SA_SIGINFO }; =20 - sigaction(SIGILL, &sa, NULL); + sigaction(SIGTRAP, &sa, NULL); =20 asm("mtspr 1, %1\n\t" - ".long 0x0\n\t" + "trap\n\t" "mfspr %0, 1\n\t" : "=3Dr" (restored) : "r" (initial)); --=20 2.35.1