From nobody Fri May 17 07:07:46 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 1632491942904648.5115747280078; Fri, 24 Sep 2021 06:59:02 -0700 (PDT) Received: from localhost ([::1]:58464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTljB-0006zD-Rt for importer@patchew.org; Fri, 24 Sep 2021 09:59:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgr-0002wt-Ua for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:37 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:46103) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgq-00058l-A3 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:37 -0400 Received: from quad ([82.142.21.142]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mna0x-1nAI7R3vBl-00jdR4; Fri, 24 Sep 2021 15:56:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 1/7] linux-user/aarch64: Set siginfo_t addr field for SIGTRAP signals Date: Fri, 24 Sep 2021 15:56:25 +0200 Message-Id: <20210924135631.2067582-2-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210924135631.2067582-1-laurent@vivier.eu> References: <20210924135631.2067582-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:fPR3/8rh0PhPJq2VfS7RHrsnKVH7dIdhp/GFaBpA1tqK4y3ot+B 8ST1s+ikw4k1FRiPsf6ktKNj/Y8cyEf0X5e+HiX/E/GW7uZ0AwpOSwaLDnHEGJNMMokI+rk K0rLBIFVfHzmayg405cbDJuIzimafC5SIAdOQB1HGYZgFsiMWbQS5xkfGWOZTjVpiJHh3V+ 4K0s0ZhVlAoYjjM7IlNug== X-UI-Out-Filterresults: notjunk:1;V03:K0:p4A86pW3S8U=:TcCU6kc/qq7AENANt5n4Q7 o8lHi/dQXumLzwJsAmmY4LcRDSNorcpWARm2oAY12cNprC2N9cW7JNfjEg83wx4uTaBtyQGt6 lLTjZeDkq/bBZYtGYHa8SXpldWwIhLxmp1z+ewQq6ou9/+HsI9Pfv+2Kup5eGM9q03VO0B2By S0G48TPFPrKNIOmDRTzvNdAlHZSriA1X10v0Mq8v0Huo2RnLCrVWWI97bljpRpdLiqn0583Cn la3UNAElZbsP32wqQsFxv/ppeBoJkEhmpmdtplKAEKAe2rXHbTyk21iNwcUl6vwb7Yu/CTQQh NqEOsWepBzyFE6yRW2znLCvIlzWMjZDd3b3CdhmJmkJ2hoJGs4PhJtREaxksFWf3HPGBYSRa4 S3U/yiB+fHMWTjYvX+9JSPTjx7EO0G8762Fbjkx5gsfO3T+r8SPqiId2VkcBHX1gjaUHzwpH6 RQtfe1kSlXvi3iiA+y5Vyw09xUmF1joDhHvwFKubRKL5rCtPPS0bWHJu/CRE8i6RHxZKRPfp8 qFCqd/xRr/l+W4CwroZtsuZowiqWex/I63FBYvi7E4c+Dlg7Sbkga2jdyDjfugCbD3KxSuZVm ySvZZM4CavK75NRDhw8oSXy1Ph8zRGgdL17IDWDQZx6bVZUc833j9tIE1TtpBtFlftDgkGGga Plw9NJwAq7sTrxVPPIFnkuPSKoFYNr4TId5rFkKmZhGa612x1xvXGQ3aorF9PjdLUjOJiIgBF GJUpmww39vkhykzxOOU+jwH2de8eTOYJQwYnQw== 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.75; 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_H2=-0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1632491943755100001 Content-Type: text/plain; charset="utf-8" From: Peter Maydell When generating a TRAP_BRKPT SIGTRAP, set the siginfo_t addr field to the PC where the breakpoint/singlestep trap occurred; this is what the kernel does for this signal for this architecture. Fixes: Coverity 1459154 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20210813131809.28655-2-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/aarch64/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 5425b85659a9..980e734e54f3 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -150,6 +150,7 @@ void cpu_loop(CPUARMState *env) info.si_signo =3D TARGET_SIGTRAP; info.si_errno =3D 0; info.si_code =3D TARGET_TRAP_BRKPT; + info._sifields._sigfault._addr =3D env->pc; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_SEMIHOST: --=20 2.31.1 From nobody Fri May 17 07:07:46 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 1632492067921424.32554975978053; Fri, 24 Sep 2021 07:01:07 -0700 (PDT) Received: from localhost ([::1]:36002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTllC-0002PA-Ow for importer@patchew.org; Fri, 24 Sep 2021 10:01:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgt-0002zU-8u for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:39 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:35781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgq-00058S-Ug for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:38 -0400 Received: from quad ([82.142.21.142]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MtfeD-1mi8Le1gHH-00v5ku; Fri, 24 Sep 2021 15:56:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 2/7] linux-user/arm: Set siginfo_t addr field for SIGTRAP signals Date: Fri, 24 Sep 2021 15:56:26 +0200 Message-Id: <20210924135631.2067582-3-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210924135631.2067582-1-laurent@vivier.eu> References: <20210924135631.2067582-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:GG4Ei9bgJnhqFlbD4cbNUt5vrrHJzrkD9ShlT/QeeBu4wmNQPO9 1mu8LTcY+N5/0nFHltZs3sRyODmOzvpSkek+11/QSQ9SFAGGWlnHubSbAKPUKSAcUp9xscL 5zs+fNREp8mHdzCg5yuSbRqOJVDwEKi7qWwUNhihsWPxy2My8m/GO4z6YtwOUdFmsL89lCH ZM39yxwdqcWC+W363dObA== X-UI-Out-Filterresults: notjunk:1;V03:K0:vvNUg0noIpU=:58GBK7gN/HXnlF/zsO7Oim KHMOtK/KEhxJ+H8NkhxAKnnyoMzqGNZhC+6mJDED/Fd8w2L5/T7Jw0HhzA0EtT1406vhtsUXD nTDge4tUGUu9h8HNYhT1a2ttHDKmlENkpgRgjL6hPZyL4R+IfvhZiGuE8f3fP/XwNSQPy1H00 qAarhkxoh7xu5a09elyr/IJBX++RwZb03mTCa8BzwJ6ph92+4kUyPu0R0kTgJ583Kje1CqSqM Tr38GGnJKqc87m592KqyH2szppSW9bmDZyyqMnqA5hQK+UsTQVfzM8Fbzzxf1ecAjMcxiZMKh oIiztPLQFt0E/zL6HjlT6kgVUsJZ+ibN/lPjwdsB45zAtXGjeU3bmOFcykMYM2jCJlA6ly1y0 jLumwkguDkzISRpl/Go4PWTTN79t6QqphcuGBIcbP7TnPc67BbFAX6whFilW3LCwVqoqXvMy2 Y+JdwA7LmPf2lRpfVnVs/hg6R3N+avBWemSP9xdFFPWdbLV2JM8sFGVjATPHvxL9NrBduyWwV gZOFmMDFIgOJZzNX+zJzRvgyIvZKp4rPHj+1jkcAE5NRpC9Gb0vnA/CJuStc+k+hlBr0M13BX saVLLo0QmML0twzNlzqVIBleiLZr7Kp0dqPfcYBsES6gunavet34AqkMfKLy7mWsBDroXWfmh 5iDs4uuQGD+YZBU0fGRuDkZR1AYY2A+4W/6ql1Q3KlzYv9x6Fsd6B2WzPb+6rCAjmWxzU5fLt qZofud5xD/th84/nv+QQ9z3RG5uBs5GuwU9mYw== 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 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: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1632492074358100001 Content-Type: text/plain; charset="utf-8" From: Peter Maydell When generating a TRAP_BRKPT SIGTRAP, set the siginfo_t addr field to the PC where the breakpoint/singlestep trap occurred; this is what the kernel does for this signal for this architecture. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20210813131809.28655-3-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/arm/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 07032b300610..0900d18105a1 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -455,6 +455,7 @@ void cpu_loop(CPUARMState *env) info.si_signo =3D TARGET_SIGTRAP; info.si_errno =3D 0; info.si_code =3D TARGET_TRAP_BRKPT; + info._sifields._sigfault._addr =3D env->regs[15]; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_KERNEL_TRAP: --=20 2.31.1 From nobody Fri May 17 07:07:46 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 1632491909728391.65506800788364; Fri, 24 Sep 2021 06:58:29 -0700 (PDT) Received: from localhost ([::1]:56458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTlie-0005f6-0f for importer@patchew.org; Fri, 24 Sep 2021 09:58:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgt-0002zJ-6P for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:39 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:48477) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgq-00058q-Hc for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:38 -0400 Received: from quad ([82.142.21.142]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MlO9r-1n85CG3njR-00lqMU; Fri, 24 Sep 2021 15:56:34 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 3/7] linux-user/arm: Use force_sig() to deliver fpa11 emulation SIGFPE Date: Fri, 24 Sep 2021 15:56:27 +0200 Message-Id: <20210924135631.2067582-4-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210924135631.2067582-1-laurent@vivier.eu> References: <20210924135631.2067582-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:WOmLcxSORRujtu9L/LcTUgSJGpqELirPKh1VErxI4QC+PGxIwZH wZEpEL/0mEnoJ/bPblYB58GVc8tEMDHBZhDeDwm2twPv5ZYHzHv5NEZNSPoKEpF4HJZoc78 lP6XU8I7vzPoF46k+OvYa3tfXeF05DSG+EU2oKHCdFd5l/wrOJgz1R5+yY7OD6fkV8QEU9K 0pETnl78uqR8jPndnx2DQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:DLmTv2KpK4M=:eSoCpIzkS+03dk0PdP97sj Dl4QWHN2rV91QRpe/TgtwD0K+1lzLthzL3GZA0en0X/wEP3Wujtx0KGiC2XOVzQ2ceRZVzaL/ 6/JW905HAYm+UETifkgcAhfexk0IoThajQ6p4VFAT+43ZnUxjTETNAt490arI4VLhs0SKv7Jk CJWW3/eP/RMg33XSmiZDUUKsbf5AmEkpq1e7fstCwo/xIvpbZ7HAYsy3IN34kG2uwNO6M52cK hOK4wbckR/eGsr/rX1NA2pYsojkedyyGdEPOdczLO6RXq4JTNHFShts9CIrlYveQc9BsGFRfu a55NKKlyIsBIPs+o67Rl+l0vSlc08PQ6VOe9BzhJ1JRLRYkO7qm6AT7RqgRbfsgN6Nn+V2aOj ROmT3LnZ2L7tCKNjRI3p8wFqHsBFaLAE12Z+WcRqiPmtN2fqSip8gDjQH2Pd47XBy1pWZyPDb FNORzoDuWJJ3Dk3vJm0N/W81fDUQ/IlvickS4wNwpXHCtjKKy76WJ6SIz41sFl+yq83XE6/0C wRKXMKmN/CFjfYZ3O4H5ViB91wXwNjwXp+s/To1GcBq3JTHTt7VVIcgFv7iYNlmIY3jQ7NEeI /T3NLGRhr424PRszoC6NGkNJOQ6W9E31p+MosPlp3bJPnKuKEGBfwT8AHqv2JFn2vL8ETb/47 eKoLeqNKjIsbnUGXC3Q9pzDFWwRV5DhIXkrVn1AXjgKRIYyAUicQIcOWxvt0Gf9IZESCPN5Lq JzvDq+UziKqF17iBIzkzf6dDbRSQ/rOmzUs9nQ== 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1632491910718100001 Content-Type: text/plain; charset="utf-8" From: Peter Maydell In the Arm target code, when the fpa11 emulation code tells us we need to send the guest a SIGFPE, we do this with queue_signal(), but we are using the wrong si_type, and we aren't setting the _sifields union members corresponding to either the si_type we are using or the si_type we should be using. As the existing comment notes, the kernel code for this calls the old send_sig() function to deliver the signal. This eventually results in the kernel's signal handling code fabricating a siginfo_t with a SI_KERNEL code and a zero pid and uid. For QEMU this means we need to use QEMU_SI_KILL. We already have a function for that: force_sig() sets up the whole target_siginfo_t the way we need it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20210813131809.28655-4-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/arm/cpu_loop.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 0900d18105a1..fb78a1aab308 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -268,16 +268,13 @@ static bool emulate_arm_fpa11(CPUARMState *env, uint3= 2_t opcode) ts->fpa.fpsr |=3D raise & ~enabled; =20 if (raise & enabled) { - target_siginfo_t info =3D { }; - /* * The kernel's nwfpe emulator does not pass a real si_code. - * It merely uses send_sig(SIGFPE, current, 1). + * It merely uses send_sig(SIGFPE, current, 1), which results in + * __send_signal() filling out SI_KERNEL with pid and uid 0 (under + * the "SEND_SIG_PRIV" case). That's what our force_sig() does. */ - info.si_signo =3D TARGET_SIGFPE; - info.si_code =3D TARGET_SI_KERNEL; - - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig(TARGET_SIGFPE); } else { env->regs[15] +=3D 4; } --=20 2.31.1 From nobody Fri May 17 07:07:46 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 1632491911269370.6404244289305; Fri, 24 Sep 2021 06:58:31 -0700 (PDT) Received: from localhost ([::1]:56552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTlig-0005iU-6n for importer@patchew.org; Fri, 24 Sep 2021 09:58:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgt-0002z7-2t for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:39 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:47669) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgq-00058z-DW for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:38 -0400 Received: from quad ([82.142.21.142]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MysBI-1mq61g1e9C-00vsyT; Fri, 24 Sep 2021 15:56:34 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 4/7] linux-user: Zero out target_siginfo_t in force_sig() Date: Fri, 24 Sep 2021 15:56:28 +0200 Message-Id: <20210924135631.2067582-5-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210924135631.2067582-1-laurent@vivier.eu> References: <20210924135631.2067582-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ppNP15x2czCuvY1892z6woD8TKTsVrnHpcpOymAF7UVDRkS0kdD aJyaezdd2d6rYS1IypNuHESeZdx/tkLUAk4DmOc7DQbt8EcPE32HeJtJOuqlzOkvPaZ+29R IxEtwq5S3OIKUfeAS3oLKyWy0/u+lOBQ6r1+1ZLqSv5TqgwLm2Gb+N5u+Hhom8gipPU8pKx wYbvctDM0/THCs8jCmNxg== X-UI-Out-Filterresults: notjunk:1;V03:K0:u4Nog+Vvs6g=:tIgHdiMIfaivEYr4b2N9WS J4k+vg+jt5GtuguGq6xEs85iEPW6QCpiHck3x/k6W26jISGRWOvXDI+dZ2AudQLC9Zc5kg15e vHOthc/oqWJTmzJcUCGSans3PcAqorYaLgEycDZ86jqceC8d1Yo2LVEYnn5AbnWOvfmXIQeQp AB+HpMsW+NUNNJfHHm0XLh7adtunHcmLXaEpHjLbBwA7MN4ugWuMhlZttarWaGpgtCv3G1erE fVC8Es/lA9OUpZgqQRWAlrsKR5cvIFx/TyYkuEE8wiO3r6pFS+3Ur8gM+cvm4L68nOn8mrgNF TZSO6k2L1m+rk0Ccdbi2HA0eSd3+MkN9y3tCm/mKiNnKd3ND8ZL/azXyDg7SAYjog7p7pZ457 3JR+jOsdL3Fv9xmX1RFaD0DbxeQ4Osb6yYCMn5Gi16cxGuT3tn6vIRU+FkrGj2X4PsI8nLDUn WkzknjygjZQmHKTAgbJg4fzKkMiolfll0JXcuecRztqGawD5TyQjFa/db4ecHeZ1sa5GIr5Lk jE6JcPDP6FcHsNB83EVtw9y+bCJrPWAWfwaxfVPsJ86Rkq+dp+y0F4rsB2fJPZUNba9tKy4ie Ab/PDun4S8eF/Ew4u2Xh6XFIyq5G8VVFcVu088XqPtSHUp3kqDKkPgDWq/gmyvVxZNBvALfp0 VKZVQO0X0zmI5/7GGB0EwHeZuxBHU1TGn7x7OkRdIJero2UQfs1v4B2cLl2TH6OjjsARK7tbA 3YK3A1rzrtnZ//l1kOI9OLsp0o/G47fNoysQ7g== 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.75; 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_H2=-0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1632491912677100004 Content-Type: text/plain; charset="utf-8" From: Peter Maydell The target_siginfo_t we populate in force_sig() will eventually get copied onto the target's stack. Zero it out so that any extra padding in the sifields union is consistently zero when the guest sees it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20210813131809.28655-5-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index f8346f5ec5fd..910b9dc6f7d1 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -641,7 +641,7 @@ void force_sig(int sig) { CPUState *cpu =3D thread_cpu; CPUArchState *env =3D cpu->env_ptr; - target_siginfo_t info; + target_siginfo_t info =3D {}; =20 info.si_signo =3D sig; info.si_errno =3D 0; --=20 2.31.1 From nobody Fri May 17 07:07:46 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 1632492127598503.619680410181; Fri, 24 Sep 2021 07:02:07 -0700 (PDT) Received: from localhost ([::1]:37778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTlmA-0003fl-Gj for importer@patchew.org; Fri, 24 Sep 2021 10:02:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgt-000314-UV for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:39 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:60799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgr-00059W-4J for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:39 -0400 Received: from quad ([82.142.21.142]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mcp3E-1n3Ngm3ivS-00ZyOz; Fri, 24 Sep 2021 15:56:35 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 5/7] linux-user: Provide new force_sig_fault() function Date: Fri, 24 Sep 2021 15:56:29 +0200 Message-Id: <20210924135631.2067582-6-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210924135631.2067582-1-laurent@vivier.eu> References: <20210924135631.2067582-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:Aa/W3+/9Dd/FWKEHqQrSMRuBgk3RRcCeVu9Z8Z4ztYIsgzvM0pR frAf6FULRJj5hXG6AFG0xeToUdC+jA1IePhgKUikjFKiX/UOq0bPHqKgqEyGBRHKIu69NgK j74TlMGV6DkFxddn18xq4wdERh3QbaEMDqV72SCfpTsgxuA7dtS3+Inz5GNfTUg8Js0QCqq anyYXLa4dXGDQr3cIkDhw== X-UI-Out-Filterresults: notjunk:1;V03:K0:gNsuaqKw5uw=:BRlI4WXHriuCEU09lruvwV MMqojHOBzyWENOd0kNRREKN3cEicKYGlh2LrOH7fufbZXsGP9y4DJf6cJUMUUyxz6Gl2IeWOL 9zqDdaUc1k9PFf3B/VukKu52EwjK9DCG41+u9WGRjQvCzm80tuy/88HTP9UpBqW52JUhCyN3u kwxEZibWcCc4G4KHKefQpwbpDOq48EXx1IvJ/zjLC5NF1xsPtEvtu4BDxiW1Y0+P4EKUyWXdz YOq0oVxf55fWXWXKFrbrtv4OCruFYi2cq9rc/8i5m/svnHoRw3bZpK3eTiBgkacb6kyN3WPHh A9UUYlVvVKIJdHwayJZN6stzCrlMwS17HxznjNNy6WtOyCoLPl0wYMpZTK+GtqtSFu7ASfBxt mbEibhEkQt1cWARPOj7bUloHb34Mhxd/6Ntf8at+/tkjVT80cSHNzjx1Yv7fgJ+9JfLXUwVzc tU6WPw3d5HPRqj/M9+j6EnFyipVHKkTikup4QQd+o7HtAWlBNSNK+0ioJcRVrfkyXjXGpnTg0 AJg9MpGuKjNabDIKExUYKsafsW3nq7ZzbN7wzeVej4wKCIoUrDi2fsY2FEgi+5inuvVtCfrVw evyLPeHdfSUnFLTTbEEFW1VgypZeZDSEFSHE1XwdVVVNDoMELOoIW/gJZf70H6782w6vGa2MM 7Ud4/f4MlfIjn1RduBzA3pDvhe5Zb0ciH0XwlOWMcj4xhLed526+zp126gBdRVLUZfsevO+db 5wZuOy1dRkKJ7pDgc0Rb8BEiJvTQiGqGckHH2w== 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.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1632492129796100003 Content-Type: text/plain; charset="utf-8" From: Peter Maydell In many places in the linux-user code we need to queue a signal for the guest using the QEMU_SI_FAULT si_type. This requires that the caller sets up and passes us a target_siginfo, including setting the appropriate part of the _sifields union for the si_type. In a number of places the code forgets to set the _sifields union field. Provide a new force_sig_fault() function, which does the same thing as the Linux kernel function of that name -- it takes the signal number, the si_code value and the address to use in _sifields._sigfault, and assembles the target_siginfo itself. This makes the callsites simpler and means it's harder to forget to pass in an address value. We follow force_sig() and the kernel's force_sig_fault() in not requiring the caller to pass in the CPU pointer but always acting on the CPU of the current thread. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20210813131809.28655-6-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/signal-common.h | 1 + linux-user/signal.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 58ea23f6ea94..79511becb4e7 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -40,6 +40,7 @@ void tswap_siginfo(target_siginfo_t *tinfo, void set_sigmask(const sigset_t *set); void force_sig(int sig); void force_sigsegv(int oldsig); +void force_sig_fault(int sig, int code, abi_ulong addr); #if defined(TARGET_ARCH_HAS_SETUP_FRAME) void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUArchState *env); diff --git a/linux-user/signal.c b/linux-user/signal.c index 910b9dc6f7d1..203821645509 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -651,6 +651,23 @@ void force_sig(int sig) queue_signal(env, info.si_signo, QEMU_SI_KILL, &info); } =20 +/* + * Force a synchronously taken QEMU_SI_FAULT signal. For QEMU the + * 'force' part is handled in process_pending_signals(). + */ +void force_sig_fault(int sig, int code, abi_ulong addr) +{ + CPUState *cpu =3D thread_cpu; + CPUArchState *env =3D cpu->env_ptr; + target_siginfo_t info =3D {}; + + info.si_signo =3D sig; + info.si_errno =3D 0; + info.si_code =3D code; + info._sifields._sigfault._addr =3D addr; + queue_signal(env, sig, QEMU_SI_FAULT, &info); +} + /* Force a SIGSEGV if we couldn't write to memory trying to set * up the signal frame. oldsig is the signal we were trying to handle * at the point of failure. --=20 2.31.1 From nobody Fri May 17 07:07:46 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 1632492258410851.1915475227137; Fri, 24 Sep 2021 07:04:18 -0700 (PDT) Received: from localhost ([::1]:43096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTloH-0007NC-93 for importer@patchew.org; Fri, 24 Sep 2021 10:04:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgu-00032i-KM for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:40 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:59141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgs-0005AF-5R for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:40 -0400 Received: from quad ([82.142.21.142]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N3bGP-1muGu01dop-010c3Y; Fri, 24 Sep 2021 15:56:35 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 6/7] linux-user/arm: Use force_sig_fault() Date: Fri, 24 Sep 2021 15:56:30 +0200 Message-Id: <20210924135631.2067582-7-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210924135631.2067582-1-laurent@vivier.eu> References: <20210924135631.2067582-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:GR3BsFG5L32UWDfi68Eb/l0ifBT1ItetpTC46iNdBYsV5jx+Jee 1nm3TfPWBMjNPfjChpHxjcTz+vCA4a+RpvzFRnwItOHSAPi39hRepSq549WvlsK34h3i/5Y TTNBWUJIEj306mH+QdRNRivMfykFKRLiKNLbRmWrw2bUorP6MIeCJIRPqRC/ZjTt04JoF45 lW1bWUcsNmzT69OeCMRUQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:DJQyKOes5TI=:faTkQ5QLfVg0DQJSUAajCm P+wrEh1GoxAGqFYED1CPQSgj6gT8QZd53r3t+q0V7VI5d6TtRf6YfQW5xbtaPx/ZhTHFKHe/Y ms0P4dkecvvWL1k2JQL3U4XH/58oYbg3eDjFc/wuNKH4j2Z2gwtRZymZ8Hgxy0KprlvNbiolX 4MhlqYikDqgq3Gb4sZSPp3Tjj6OqAbJ8RMzWmB8X/o02cnc9YTiphwad2v5ACuyylGtsjgpQd BPqwEoevY4NcdpvCX2l4nm/JAaN50ZYXy1bUCNbr1edPWWwtZNfK3OAW4X5tlQbaE9aS6rLj9 w6jbORUqkYQng7ICsC5BjU9ynAjT73GkqfwlNeN548bOej7MgffV6m/2NR05pl50Hz+HAUeza xi57A468AFEupY7GTC+vAS7xBgu7i2EK2xCjggkiEQnkoypGH3LkRG4Jy5NV6ClptMjv/WdYW KNyLcMt/8ohhjAbH3CNbDXA/i/aPqxVSCNrUDfP5RobgXx6Vp4qRftCGWRxeJH5vMR4NysNEm 9Lej9JmFYrictpDBCt2SGcD7wbahELDzPnj2zfvEg4LKtrdNfeN+SO61AiXRn7dTonJhcu8bT ndnLkLzkM8SFp8H+lZNYiWNcG2Pt/X2HBkSsuuN4Ihmi5xLvwYXsBgopKqCCu1OKu6lYqtDfg kXmqKOZkTBzMYLuDjKCIs+k/5HsoElu/Ty4tRI7Z03BhGSOw0YSrOEmBSE/ynIH173K2vzj5a piun5XUBWldG/OOMviWCzTlRxGoAMeZ0M4Dp3g== 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.24; 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1632492261067100001 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Use the new force_sig_fault() function instead of setting up a target_siginfo_t and calling queue_signal(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20210813131809.28655-7-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/arm/cpu_loop.c | 53 +++++++++++---------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index fb78a1aab308..ae09adcb9501 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -94,7 +94,6 @@ static void arm_kernel_cmpxchg64_helper(CPUARMState *env) { uint64_t oldval, newval, val; uint32_t addr, cpsr; - target_siginfo_t info; =20 /* Based on the 32 bit code in do_kernel_trap */ =20 @@ -143,12 +142,9 @@ segv: end_exclusive(); /* We get the PC of the entry address - which is as good as anything, on a real kernel what you get depends on which mode it uses. */ - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D env->exception.vaddress; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->exception.vaddress); } =20 /* Handle a jump to the kernel code page. */ @@ -286,8 +282,6 @@ void cpu_loop(CPUARMState *env) CPUState *cs =3D env_cpu(env); int trapnr; unsigned int n, insn; - target_siginfo_t info; - uint32_t addr; abi_ulong ret; =20 for(;;) { @@ -322,11 +316,8 @@ void cpu_loop(CPUARMState *env) break; } =20 - info.si_signo =3D TARGET_SIGILL; - info.si_errno =3D 0; - info.si_code =3D TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr =3D env->regs[15]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, + env->regs[15]); } break; case EXCP_SWI: @@ -394,18 +385,14 @@ void cpu_loop(CPUARMState *env) * Otherwise SIGILL. This includes any SWI with * immediate not originally 0x9fxxxx, because * of the earlier XOR. + * Like the real kernel, we report the addr of= the + * SWI in the siginfo si_addr but leave the PC + * pointing at the insn after the SWI. */ - info.si_signo =3D TARGET_SIGILL; - info.si_errno =3D 0; - info.si_code =3D TARGET_ILL_ILLTRP; - info._sifields._sigfault._addr =3D env->regs[1= 5]; - if (env->thumb) { - info._sifields._sigfault._addr -=3D 2; - } else { - info._sifields._sigfault._addr -=3D 4; - } - queue_signal(env, info.si_signo, - QEMU_SI_FAULT, &info); + abi_ulong faultaddr =3D env->regs[15]; + faultaddr -=3D env->thumb ? 2 : 4; + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLT= RP, + faultaddr); } break; } @@ -436,24 +423,14 @@ void cpu_loop(CPUARMState *env) break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - addr =3D env->exception.vaddress; - { - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D addr; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + /* XXX: check env->error_code */ + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: excp_debug: - info.si_signo =3D TARGET_SIGTRAP; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr =3D env->regs[15]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[1= 5]); break; case EXCP_KERNEL_TRAP: if (do_kernel_trap(env)) --=20 2.31.1 From nobody Fri May 17 07:07:46 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 1632492068089178.476572642704; Fri, 24 Sep 2021 07:01:08 -0700 (PDT) Received: from localhost ([::1]:36028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTllC-0002Q2-Vx for importer@patchew.org; Fri, 24 Sep 2021 10:01:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgu-00031v-CA for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:40 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:56441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgr-0005AD-Ty for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:40 -0400 Received: from quad ([82.142.21.142]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M3lLh-1mU2nw3aR1-000uhQ; Fri, 24 Sep 2021 15:56:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 7/7] linux-user/aarch64: Use force_sig_fault() Date: Fri, 24 Sep 2021 15:56:31 +0200 Message-Id: <20210924135631.2067582-8-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210924135631.2067582-1-laurent@vivier.eu> References: <20210924135631.2067582-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:J3ppuy8nfO+aKlVA06tx1O+/lmCpIvulGhaBp63Ja53tzKTkDx/ lU51QVqlImUxMDgEqZ9CWiZwxxqnYZdOZeMLpoqtf5R1jtbg1FTna6Ny1O1pFtLIuMXrY/n JTT+k8T2HuTmlI7udk8CJrRYaGMkg8gYRIldit/FyMMaWFjLc6zSijNqJ3srsDIrs9xvDWN SfPkt53kNdp4O6biL/6jA== X-UI-Out-Filterresults: notjunk:1;V03:K0:IVFbgakdjLc=:fcUK1nHhTn8Vazbaf7hreC oJLChlIRB5bzP0iXVnzWeSZBGgLLw1rZruTDpgCYKoyg/m3bxU7lOTU01YRUX7pIHYbcYUa3B rFUn54Me50TWoSTgdOTaR3ZkYUscCHBAxrGxgBeYj8+Ms7+Eswp6sfQdX8FWWBDDWrk7YN4uf 7ZspxwEdd3pT2IflHcMDenVvLz1xbxXCv4OMe8nPOXHU624rhWoPgMQR5Cx4lwzgN8sa3zWMZ FFpP8WQgDVO9ueNvJSjSfBd3xNSG5DAwCB9JXlmdOzGGb1TcteWRY92olT36JIf/V6AfqQYYe vDas0PmujcEO94c9Azo8FR0kTJyjYB/Q2ebE1GrAxsXPdMD9qvEd6yF9pSIJgVBvDREk3jTZ4 UjdHHb9ufty2TQGIo/y8xp/pBE2ywl8ISCVbD3BPQwIMouNT0aJKyd+gNkLtWo2WNfk7hj6SH 3YdS2lsRf7nu9acZ28+Z6LknK9UOsW1BedPIaoxq6tGNZlq2GxOsYu1VJy0OHQpIiucB7C2j3 e/sBBKsfIZ+PRVr54Zw7VLvALlA8Vi6tF7syermrayfgoH0Mn2+2OOoIOHJLLGYWwyPaUlkcP emP4mwoxlhAAjWUzrtnBOsy/7joGKIm0uuRKqOLl5PLCstr1vZcJYbYEVNIDQfNkJio8KXzeC RE+OB2BLvgpMERQsIS6RmfuTEvD6BFzlv9vlykdu6jaxRD5VRi8oiXbJjQzyRpE8dVF+TaHNz kMIUEFuKvsS/N0Jz2w53cHkB8kwKzfed6Is/Gw== 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 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: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1632492074587100003 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Use the new force_sig_fault() function instead of setting up a target_siginfo_t and calling queue_signal(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20210813131809.28655-8-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/aarch64/cpu_loop.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 980e734e54f3..034b737435a3 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -79,9 +79,8 @@ void cpu_loop(CPUARMState *env) { CPUState *cs =3D env_cpu(env); - int trapnr, ec, fsc; + int trapnr, ec, fsc, si_code; abi_long ret; - target_siginfo_t info; =20 for (;;) { cpu_exec_start(cs); @@ -110,18 +109,10 @@ void cpu_loop(CPUARMState *env) /* just indicate that signals should be handled asap */ break; case EXCP_UDEF: - info.si_signo =3D TARGET_SIGILL; - info.si_errno =3D 0; - info.si_code =3D TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr =3D env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->pc); break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - info._sifields._sigfault._addr =3D env->exception.vaddress; - /* We should only arrive here with EC in {DATAABORT, INSNABORT= }. */ ec =3D syn_get_ec(env->exception.syndrome); assert(ec =3D=3D EC_DATAABORT || ec =3D=3D EC_INSNABORT); @@ -130,28 +121,24 @@ void cpu_loop(CPUARMState *env) fsc =3D extract32(env->exception.syndrome, 0, 6); switch (fsc) { case 0x04 ... 0x07: /* Translation fault, level {0-3} */ - info.si_code =3D TARGET_SEGV_MAPERR; + si_code =3D TARGET_SEGV_MAPERR; break; case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ - info.si_code =3D TARGET_SEGV_ACCERR; + si_code =3D TARGET_SEGV_ACCERR; break; case 0x11: /* Synchronous Tag Check Fault */ - info.si_code =3D TARGET_SEGV_MTESERR; + si_code =3D TARGET_SEGV_MTESERR; break; default: g_assert_not_reached(); } =20 - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, si_code, env->exception.vaddre= ss); break; case EXCP_DEBUG: case EXCP_BKPT: - info.si_signo =3D TARGET_SIGTRAP; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr =3D env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case EXCP_SEMIHOST: env->xregs[0] =3D do_common_semihosting(cs); @@ -171,11 +158,7 @@ void cpu_loop(CPUARMState *env) /* Check for MTE asynchronous faults */ if (unlikely(env->cp15.tfsr_el[0])) { env->cp15.tfsr_el[0] =3D 0; - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - info._sifields._sigfault._addr =3D 0; - info.si_code =3D TARGET_SEGV_MTEAERR; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MTEAERR, 0); } =20 process_pending_signals(env); --=20 2.31.1