From nobody Sat May 4 10:26:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 154205591358558.45844408667381; Mon, 12 Nov 2018 12:51:53 -0800 (PST) Received: from localhost ([::1]:50597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJBP-0004NX-Rw for importer@patchew.org; Mon, 12 Nov 2018 15:51:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJ9c-0003MY-BU for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:49:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMJ9b-00088f-B2 for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:49:52 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:34581) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gMJ9a-000882-Vp for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:49:51 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MeknF-1fnnD83Wfl-00an7b; Mon, 12 Nov 2018 21:49:36 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 21:49:26 +0100 Message-Id: <20181112204929.12625-2-laurent@vivier.eu> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112204929.12625-1-laurent@vivier.eu> References: <20181112204929.12625-1-laurent@vivier.eu> X-Provags-ID: V03:K1:W7OfH3Cd/slzVN7fFnjD0i0Uc4NBPqa70zKKNeX2V+KGaPYZOsv 5IlL2DcvKcsY0v3lTwy+M+ClmpO2OYKlyHYzO+Lha/JOQp5GxKaYS3VDncsCHY1Zd82dGes tph93I01pKY/rFv6GxU6J8/7xwGPAzvP+y6M8YM3U6Fmp4RcUubKyeQ/QUh8xgKlqngQ1JZ hkX+NdjUAgTdaPVpzwBBw== X-UI-Out-Filterresults: notjunk:1;V01:K0:PbbQe1lucS8=:0HYUyMuJGtSDjGpIR7ti/C 8+vYFBhWb1RnPifPRtlbdrSpegezJj8I6esBgGKh+QmX+53HYeTcNGjWwc6kPjSLnq2UPoadS PiIbT6KF47ckWza0ByMusAFPXFMGkPr36BSMQSF6eA9NtZ+lvQFG8oPX77MzHlj1RZTEQb9Wi /yDhwOdhhZ+DvsgNQeOMsL/Rk+FmOlOujccnvZqKP2BuVe6dDCcwLDfnZ66cBwBnqHaSimdkf FP0nWp7mRsT1ifVnV7nojzYm1eIdcLTKa7qZ8856K4+2I76WRAurxi0X0zlVKdSBXvJObf9/s ld1qiIQfu0jELkQM+y1Fa1nOBDuc2EbgI9RIqWyDoL87hkynRLr+DKYTWwXr8DI6A9tIhygjG /WG/KosWrbq43VqhFymOLMS0Zey9uMr1UEAPIqXTWoENsQMcOt8TnIggYBgpbINezOKbZ+A5a lMsjKml8TjsIEi9EHoyIuFN/wrJr4NB8MgdRi6eb/T9LgxID6YaHxV1QkQVLiGZ52BliRAT+F VEBPPO67ShKrdKOWkgx86AUItiCOJzhcvwgDuHuYj5UhZyEel0oruymxbn++nwrxLogDOsh9P 8COVOxpaR3n0QwpSok0pNBkcef1B8kGo/pcWvNAjtwOztLuhlb/abar31j9356B2IWZezTUMO NiJcNVJbpXimoFH39rKQANgq/3bSucuLzZrnSzBN1wVk569bt3g6yUuDEpIZz21WrCtBReFTR Fl9VtcyAqTI+StjNWeG+sFb4j8xDzraPv+8nGHygv5dlvCcncuYAiS9P8t55EdIYvx5nT1AkD PPhaMpt X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PULL 1/4] linux-user: Remove dead error-checking code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Remove some dead code spotted by Coverity (CID 1009855, 1390854, 1390847). The underlying cause in all these cases is the same: QEMU's put_user operations can't result in errors, but the kernel's equivalent does. So when code was copied from the kernel signal-frame-setup/teardown code, checks on error flags that were needed in the kernel became dead code for us. Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Message-Id: <20181019161715.12122-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/m68k/signal.c | 3 --- linux-user/sh4/signal.c | 4 ---- linux-user/sparc/signal.c | 2 -- 3 files changed, 9 deletions(-) diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c index 38bd77ec16..49ff87c77b 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -334,9 +334,6 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, (uint32_t *)(frame->retcode + 0)); __put_user(0x4e40, (uint16_t *)(frame->retcode + 4)); =20 - if (err) - goto give_sigsegv; - /* Set up to return from userspace */ =20 env->aregs[7] =3D frame_addr; diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c index c6752baa7e..cc89a48ff8 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -279,7 +279,6 @@ long do_sigreturn(CPUSH4State *regs) sigset_t blocked; target_sigset_t target_set; int i; - int err =3D 0; =20 frame_addr =3D regs->gregs[15]; trace_user_do_sigreturn(regs, frame_addr); @@ -292,9 +291,6 @@ long do_sigreturn(CPUSH4State *regs) __get_user(target_set.sig[i], &frame->extramask[i - 1]); } =20 - if (err) - goto badframe; - target_to_host_sigset_internal(&blocked, &target_set); set_sigmask(&blocked); =20 diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index e44e99993c..295e415b1e 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -256,8 +256,6 @@ void setup_frame(int sig, struct target_sigaction *ka, /* t 0x10 */ val32 =3D 0x91d02010; __put_user(val32, &sf->insns[1]); - if (err) - goto sigsegv; } unlock_user(sf, sf_addr, sizeof(struct target_signal_frame)); return; --=20 2.17.2 From nobody Sat May 4 10:26:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542056048050144.51035467020483; Mon, 12 Nov 2018 12:54:08 -0800 (PST) Received: from localhost ([::1]:50610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJDh-0006SZ-O5 for importer@patchew.org; Mon, 12 Nov 2018 15:54:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJA3-0003j3-4c for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:50:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMJA0-0000Hs-CY for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:50:19 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:46453) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gMJA0-0000Gv-1L for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:50:16 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MlNYj-1fcleX1Noz-00lofL; Mon, 12 Nov 2018 21:49:36 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 21:49:27 +0100 Message-Id: <20181112204929.12625-3-laurent@vivier.eu> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112204929.12625-1-laurent@vivier.eu> References: <20181112204929.12625-1-laurent@vivier.eu> X-Provags-ID: V03:K1:vOFFLZth2b/P11W17dZZJO2WzqguzPqKfp2NLFHAj3TLsL4TPLT GjY41vKGOrTKR7b0/Wg7ulBYL1GnVGr+HiJNjXbkTTmtH8Sha3vNAul/7/MHshfmdYjVFo5 Qj2CllcA1zyoGk7RES57ZYkssj1RG+OU2wdV9aLNLN5kFb/w2jLIqTpo1ArzcT1eZzHswwX uAH/N1TSWJzRi4tANeaug== X-UI-Out-Filterresults: notjunk:1;V01:K0:0P3X6aCz0tY=:nRVWeeW5KuVrp4Jfdty3lE QbQMbVtFq1d56bwHTovylCVYsVJPoofzNV1gwKTEgeECTegGSPdoNrMz6GfLRPXVbavXmfdKG 4lZGF3wkwrO1cNJtBmHA34cR0JS8Y+ULrNYL1FG11lgSL/y/APQUWEXJy3+sip07ZzSMJWzM3 dMEzmISPYmTiMFlLI1osYfR7VI9r/57WNEsrxJ09yMQ9V0MC5yrlJCSwqqXWAZvHaTmWV7LRK 2e4j6Bao7BMfJS8GHjqgo7YeVJEMPu2noYfvSJ0hFI5Me245DRCyjCahugkzvCAOX4cbi6zAQ 8LwjoqEJP+JOigDI6fprhXZ+9F44OnN49wUt+WcCUYwsz6Lk8I0xnmFZE65YgMBF7xv6BS2JB 0n05BWTpagrTKYTcm5HrhLqPql64sCniJVtstWoN3hK7lL8sixOsRpYI890cZVt5hdJ/KxG+M sc3cspPAeqIyQinOrAdReFNe12SlZO3aBRWPEmpvS3y8KZlgDKNvc9jx1eklSlGrAn3HscDSl DonhnG4VeFt8HIiErYYRUvTKBUzskpsELqejA3TpNkCBNgATuP9uZrsRTNdB2xEVlP2uXGGxy BQOJceZ2GDTqPFWNFjDKHfuQPEka8SERT/wKCY1bfHPlDH9NIfF485v+OqZ6VA0ClgGWnHnqo CWQVmsnlrfWoQ3I2zqKn93ErBtY+GBoO4JveSNx9hVTrUsGCuQ5U9UgDbmP34EuBbi9+TrJTf zQY3qowQDYbxIl/Bti/YGSOs+zCCcAuVakPAp7MA6XzdWCtzwvpf79XSNvpx0//Vgu5TJPsgg IyVKpGS X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.135 Subject: [Qemu-devel] [PULL 2/4] linux-user: Don't call gdb_handlesig() before queue_signal() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Maydell The CPU main-loop routines for linux-user generally call gdb_handlesig() when they're about to queue a SIGTRAP signal. This is wrong, because queue_signal() will cause us to pend a signal, and process_pending_signals() will then call gdb_handlesig() itself. So the effect is that we notify gdb of the SIGTRAP, and then if gdb says "OK, continue with signal X" we will incorrectly notify gdb of the signal X as well. We don't do this double-notify for anything else, only SIGTRAP. Remove this unnecessary and incorrect code from all the targets except for nios2 (whose main loop is doing something different and broken, and will be handled in a separate patch). This bug only manifests if the user responds to the reported SIGTRAP using "signal SIGFOO" rather than "continue"; since the latter is the overwhelmingly common thing to do after a breakpoint most people won't have hit this. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20181019174958.26616-2-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/aarch64/cpu_loop.c | 13 +++++-------- linux-user/alpha/cpu_loop.c | 12 ++++-------- linux-user/arm/cpu_loop.c | 16 ++++------------ linux-user/cris/cpu_loop.c | 16 ++++------------ linux-user/hppa/cpu_loop.c | 11 ++++------- linux-user/i386/cpu_loop.c | 16 ++++------------ linux-user/m68k/cpu_loop.c | 16 ++++------------ linux-user/microblaze/cpu_loop.c | 16 ++++------------ linux-user/mips/cpu_loop.c | 16 ++++------------ linux-user/openrisc/cpu_loop.c | 11 ++++------- linux-user/ppc/cpu_loop.c | 15 +++++---------- linux-user/riscv/cpu_loop.c | 2 +- linux-user/s390x/cpu_loop.c | 9 +++------ linux-user/sh4/cpu_loop.c | 17 ++++------------- linux-user/sparc/cpu_loop.c | 16 ++++------------ linux-user/xtensa/cpu_loop.c | 11 ++++------- 16 files changed, 62 insertions(+), 151 deletions(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index c97a646546..65d815f030 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -73,7 +73,7 @@ void cpu_loop(CPUARMState *env) { CPUState *cs =3D CPU(arm_env_get_cpu(env)); - int trapnr, sig; + int trapnr; abi_long ret; target_siginfo_t info; =20 @@ -121,13 +121,10 @@ void cpu_loop(CPUARMState *env) break; case EXCP_DEBUG: case EXCP_BKPT: - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_SEMIHOST: env->xregs[0] =3D do_arm_semihosting(env); diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c index c1a98c8cbf..824b6d6658 100644 --- a/linux-user/alpha/cpu_loop.c +++ b/linux-user/alpha/cpu_loop.c @@ -179,14 +179,10 @@ void cpu_loop(CPUAlphaState *env) } break; case EXCP_DEBUG: - info.si_signo =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (info.si_signo) { - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } else { - arch_interrupt =3D false; - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_INTERRUPT: /* Just indicate that signals should be handled asap. */ diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 26928fbbb2..ee68aa60bf 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -397,18 +397,10 @@ void cpu_loop(CPUARMState *env) break; case EXCP_DEBUG: excp_debug: - { - int sig; - - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) - { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_KERNEL_TRAP: if (do_kernel_trap(env)) diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c index 37bdcfa8cc..dacf604c7d 100644 --- a/linux-user/cris/cpu_loop.c +++ b/linux-user/cris/cpu_loop.c @@ -64,18 +64,10 @@ void cpu_loop(CPUCRISState *env) } break; case EXCP_DEBUG: - { - int sig; - - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) - { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c index 0301c766c6..880955fdef 100644 --- a/linux-user/hppa/cpu_loop.c +++ b/linux-user/hppa/cpu_loop.c @@ -182,13 +182,10 @@ void cpu_loop(CPUHPPAState *env) queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_DEBUG: - trapnr =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (trapnr) { - info.si_signo =3D trapnr; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, trapnr, QEMU_SI_FAULT, &info); - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c index 2374abfd0b..51cfa006c9 100644 --- a/linux-user/i386/cpu_loop.c +++ b/linux-user/i386/cpu_loop.c @@ -225,18 +225,10 @@ void cpu_loop(CPUX86State *env) /* just indicate that signals should be handled asap */ break; case EXCP_DEBUG: - { - int sig; - - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) - { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c index 30c3332af4..bfb41bbcc5 100644 --- a/linux-user/m68k/cpu_loop.c +++ b/linux-user/m68k/cpu_loop.c @@ -112,18 +112,10 @@ void cpu_loop(CPUM68KState *env) } break; case EXCP_DEBUG: - { - int sig; - - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) - { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_l= oop.c index 2af93eb39a..c2190e15fd 100644 --- a/linux-user/microblaze/cpu_loop.c +++ b/linux-user/microblaze/cpu_loop.c @@ -113,18 +113,10 @@ void cpu_loop(CPUMBState *env) } break; case EXCP_DEBUG: - { - int sig; - - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) - { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index 97e495747f..d0f62ec9b6 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -592,18 +592,10 @@ done_syscall: /* just indicate that signals should be handled asap */ break; case EXCP_DEBUG: - { - int sig; - - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) - { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_SC: if (do_store_exclusive(env)) { diff --git a/linux-user/openrisc/cpu_loop.c b/linux-user/openrisc/cpu_loop.c index 6c6ea871e1..f496e4b48a 100644 --- a/linux-user/openrisc/cpu_loop.c +++ b/linux-user/openrisc/cpu_loop.c @@ -85,13 +85,10 @@ void cpu_loop(CPUOpenRISCState *env) /* We processed the pending cpu work above. */ break; case EXCP_DEBUG: - trapnr =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (trapnr) { - info.si_signo =3D trapnr; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c index 133a87f349..801f5ace29 100644 --- a/linux-user/ppc/cpu_loop.c +++ b/linux-user/ppc/cpu_loop.c @@ -69,7 +69,7 @@ void cpu_loop(CPUPPCState *env) { CPUState *cs =3D CPU(ppc_env_get_cpu(env)); target_siginfo_t info; - int trapnr, sig; + int trapnr; target_ulong ret; =20 for(;;) { @@ -449,15 +449,10 @@ void cpu_loop(CPUPPCState *env) env->gpr[3] =3D ret; break; case EXCP_DEBUG: - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } else { - arch_interrupt =3D false; - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index f137d39d7e..4cf3e94632 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -88,7 +88,7 @@ void cpu_loop(CPURISCVState *env) break; case EXCP_DEBUG: gdbstep: - signum =3D gdb_handlesig(cs, TARGET_SIGTRAP); + signum =3D TARGET_SIGTRAP; sigcode =3D TARGET_TRAP_BRKPT; break; default: diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c index 99f5f1594f..51b5412ea2 100644 --- a/linux-user/s390x/cpu_loop.c +++ b/linux-user/s390x/cpu_loop.c @@ -61,12 +61,9 @@ void cpu_loop(CPUS390XState *env) break; =20 case EXCP_DEBUG: - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) { - n =3D TARGET_TRAP_BRKPT; - goto do_signal_pc; - } - break; + sig =3D TARGET_SIGTRAP; + n =3D TARGET_TRAP_BRKPT; + goto do_signal_pc; case EXCP_PGM: n =3D env->int_pgm_code; switch (n) { diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c index fdd348170b..47e54b9b61 100644 --- a/linux-user/sh4/cpu_loop.c +++ b/linux-user/sh4/cpu_loop.c @@ -57,19 +57,10 @@ void cpu_loop(CPUSH4State *env) /* just indicate that signals should be handled asap */ break; case EXCP_DEBUG: - { - int sig; - - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } else { - arch_interrupt =3D false; - } - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case 0xa0: case 0xc0: diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 91f714afc6..7d5b337b97 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -268,18 +268,10 @@ void cpu_loop (CPUSPARCState *env) } break; case EXCP_DEBUG: - { - int sig; - - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) - { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); diff --git a/linux-user/xtensa/cpu_loop.c b/linux-user/xtensa/cpu_loop.c index d142988ebe..bee78edb8a 100644 --- a/linux-user/xtensa/cpu_loop.c +++ b/linux-user/xtensa/cpu_loop.c @@ -239,13 +239,10 @@ void cpu_loop(CPUXtensaState *env) } break; case EXCP_DEBUG: - trapnr =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (trapnr) { - info.si_signo =3D trapnr; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, trapnr, QEMU_SI_FAULT, &info); - } + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXC_DEBUG: default: --=20 2.17.2 From nobody Sat May 4 10:26:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15420560883931023.1040650456579; Mon, 12 Nov 2018 12:54:48 -0800 (PST) Received: from localhost ([::1]:50612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJEN-0007m3-8i for importer@patchew.org; Mon, 12 Nov 2018 15:54:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJA2-0003iQ-BK for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:50:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMJ9z-0000HC-Kc for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:50:18 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:54491) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gMJ9z-0000Em-0H for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:50:15 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M7JnA-1gPd4n0Iii-007n5W; Mon, 12 Nov 2018 21:49:37 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 21:49:28 +0100 Message-Id: <20181112204929.12625-4-laurent@vivier.eu> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112204929.12625-1-laurent@vivier.eu> References: <20181112204929.12625-1-laurent@vivier.eu> X-Provags-ID: V03:K1:HfFNGfjOKqUxp3LgkgvMvyoPLly08E89MNwOX1SkSG7DJMyVjOm otYJdf5ZE7W4SDy51UfLxR4aNxFichsMK4CL4T7e4si7QRxFYNHhut3jItWjXZwI4bf/dMe sZjFk72GKi8ymA0/CkP6ZZgmTb3ZhgJb3xBLySOpiY3E9U0dQHPMZmu/CM7CicOCzqfh3dO QHu7bXlfg/a8X54N/dq6g== X-UI-Out-Filterresults: notjunk:1;V01:K0:NoUl7/7vTes=:diUVavNUzEVU9N9AbTiXuY X7wSeswQs7CYXpc3v/dcQWcQLwlh+ORW0oNsm1Z0U8SvEp7rUiIugarZmESfHTk/PzoDTO7Ef 0xbYuFgOzLyH9wUEkYcS0hFwDF8T5giQxNtSdcZadXWlByCaQS7IzqISp3b98n4dBE24jRgQK TSSZ51t1gXx/aMZMfNRVJw25HN3rYPSnDrXr2/eBpQNjvrbwTleiJY6nYe1BtMZDiGVMqmTaw thVtZGE2WyB6NXZF7FcVTFri1ae7ZBcmJm10Z4jlsvBe5bhkttbuvlqji/eh0x8mvtpuI2FjZ NZswcDgoVdrl/I3Wewmoe9qKlksULjapnDtJ9dfZWfyyaV/C/t3BulzyeTWU2ea4joDvX/95m Bo3gEm/rFwBdM8ZX0RjWjmWuD+9nsHN1cowR780aitMsra0vGYuHj8zktNWqmdbi3CdWHyvkC JdooJc9DG0hXgyKh8Hoyngo+6RU+TPWXYNldgkfBNzj6/rErdQxF0mJiZWNQN4jjG5FyB43mJ 8aAUHdkVJIkxIE+ttFTrH8KN/+JuOW8k3+5kYn1/yqklGog3iB+T66jv2Z5ic+xMqZZ/XJwq/ OTwSlReaVwgSf4O8GgHX6vISe3D65D0FQzWzeMIvIwtH/Pii4fqM0Z8/K/pCmUQ80GS4dfS/9 QsaZn4QcRtww7X5VD7tEJIKyHaQW9AJDwlxp5uVQnfPO56O8YrtZP6pi6mgS6qLTYsnNRXq/F dVgiAD09KtHJN7bds0piUcJTmI2q0+A4zJ/oQaLCVcrOIgD4A7MoxXl1TvFs+P1abB2C/fWR6 TroiwJE X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.130 Subject: [Qemu-devel] [PULL 3/4] linux-user: Clean up nios2 main loop signal handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Maydell The nios2 main loop code's code does some odd things with gdb_handlesig() that no other target CPU does: it has some signals that are delivered to gdb and only to gdb. Stop doing this, and instead behave like all the other targets: * a trap instruction becomes a SIGTRAP * an unhandled exception type returned from cpu_exec() causes us to abort(), not to try to hand gdb a SIGILL This fixes in passing Coverity issue CID 1390853, which was a complaint that the old code failed to check the return value from gdb_handlesig(). Signed-off-by: Peter Maydell Message-Id: <20181019174958.26616-3-peter.maydell@linaro.org> Reviewed-by: Richard Henderson [lv: removed gdbsig unused variable] Signed-off-by: Laurent Vivier --- linux-user/nios2/cpu_loop.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index dac7a06181..b96b1aa119 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -26,13 +26,12 @@ void cpu_loop(CPUNios2State *env) CPUState *cs =3D ENV_GET_CPU(env); Nios2CPU *cpu =3D NIOS2_CPU(cs); target_siginfo_t info; - int trapnr, gdbsig, ret; + int trapnr, ret; =20 for (;;) { cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - gdbsig =3D 0; =20 switch (trapnr) { case EXCP_INTERRUPT: @@ -68,7 +67,10 @@ void cpu_loop(CPUNios2State *env) env->regs[R_EA] =3D env->regs[R_PC] + 4; env->regs[R_PC] =3D cpu->exception_addr; =20 - gdbsig =3D TARGET_SIGTRAP; + info.si_signo =3D TARGET_SIGTRAP; + info.si_errno =3D 0; + info.si_code =3D TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; } case 0xaa: @@ -106,14 +108,7 @@ kuser_fail: default: EXCP_DUMP(env, "\nqemu: unhandled CPU exception %#x - aborting= \n", trapnr); - gdbsig =3D TARGET_SIGILL; - break; - } - if (gdbsig) { - gdb_handlesig(cs, gdbsig); - if (gdbsig !=3D TARGET_SIGTRAP) { - exit(EXIT_FAILURE); - } + abort(); } =20 process_pending_signals(env); --=20 2.17.2 From nobody Sat May 4 10:26:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542055912790640.3288786352629; Mon, 12 Nov 2018 12:51:52 -0800 (PST) Received: from localhost ([::1]:50596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJBP-0004ND-IB for importer@patchew.org; Mon, 12 Nov 2018 15:51:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJ9c-0003MT-7X for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:49:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMJ9Z-00087C-Fl for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:49:52 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:35453) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gMJ9Z-00085R-2m for qemu-devel@nongnu.org; Mon, 12 Nov 2018 15:49:49 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mn2Fb-1ffVTS2g0F-00kB2X; Mon, 12 Nov 2018 21:49:37 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 21:49:29 +0100 Message-Id: <20181112204929.12625-5-laurent@vivier.eu> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112204929.12625-1-laurent@vivier.eu> References: <20181112204929.12625-1-laurent@vivier.eu> X-Provags-ID: V03:K1:b+LZb2Y0pVvZTZtaHGZs87Y4zM2Dk7XLbDZat7YCkp4LTCFUnqX aExOMnwnL2CTCp8EptC98uEy9mO4qo/sdqcbQadP1rBk/MOPGNQQMK1mNxlLLyUQC0fQzAL C5hph5I2jucN68s2QcIbaOFTMOZyD//XUASp/THgJSrzSC/+JNO4u7Yb9DgsGe2hJn8kAcY yWo2dTQ4zN0pITH6yjvUw== X-UI-Out-Filterresults: notjunk:1;V01:K0:Y+HWKE1VmyE=:D/iM9CkLzBFiUdu+efJOGz Tic079WDohY0r91af/d3LYuUiYghTAW9tJUW4wxPIR0Ojt0OPG+r1N7Rc100Rp9WrTjB7iVv2 BqRsrVhYpGnFHhTPfehpTm8BloqB0zd79L/EbG9AEQuF/0DdDMzkwcZY1KK3ztcaAxNu1QJmf mheu/xtN8+6Rfbm3w7FD8kiK/9h8HY+9rE6IohuY8WXfKyJP/AtI44ufGTphqO6VyjROss1Zt VxxNfsihQaAjaSvfDroz8gbo7btg7hDbRKIuKt4XfaqvN3tYrTVEwldg6J8ACNuXrOaV7NN3q wFP+Ma4EggZDFOjxiXqrt5m5mDAW81VC2UFNUmBbERVj/nngYzBQeUpP2NgORKtXBs57WCwuY 4/quh/sysngR1x8kh6YoWZtnGcpgn5Kp0MXr223QwDHpETt4r75ZFocH/Q/EwhW5xQwhgOtrH 0S7fcZREG2KhMlwpP+AOm5jHyaj1Lm0xi70Qv2tFEgJzMmYLvoARsq/7Ewz3OzxlrDCJJ+sFa mK/mZ2SDW45MHr6J62AeprqMV7yUlzJUiajiLIEXhhAmvqZOql1kWUmPVz8G/oUMdmrBLkV+0 1iPJRJEq/c7PRQcGo+pcHGzJOT9JoXELIJ9kCHSHEh3fDd4p+Z/KJr03/RR716u7jDdEOBO0Z cSRwEOmKkeyWJeNJBUmKyRJBk1njxL29ZvgtY+ye1/QgFpVE8iS1JZD8VXmJkJKpY0pXbEGzw lJfknxRLXjP7TZ6iNniFPSMuR/vhUyqFlt4z21WFxvrZ0LbKt9pDZdvMVw4FWaYIe+MKK0hOb RKpq+L2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PULL 4/4] linux-user: Add support for SO_REUSEPORT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Yunqiang Su , Laurent Vivier , Aleksandar Markovic Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Yunqiang Su Add support for SO_REUSEPORT, including strace support. SO_REUSEPORT was introduced relatively recently, since Linux 3.9, so use '#if defined SO_REUSEPORT'. Signed-off-by: Yunqiang Su Signed-off-by: Aleksandar Markovic Reviewed-by: Laurent Vivier Message-Id: <1540904108-30873-4-git-send-email-aleksandar.markovic@rt-rk.co= m> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 3 +++ linux-user/syscall.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index 33f4a506a2..d1d14945f9 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1742,6 +1742,9 @@ print_optint: case TARGET_SO_REUSEADDR: gemu_log("SO_REUSEADDR,"); goto print_optint; + case TARGET_SO_REUSEPORT: + gemu_log("SO_REUSEPORT,"); + goto print_optint; case TARGET_SO_TYPE: gemu_log("SO_TYPE,"); goto print_optint; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 810a58b704..5c166928a4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2061,6 +2061,11 @@ set_timeout: case TARGET_SO_REUSEADDR: optname =3D SO_REUSEADDR; break; +#ifdef SO_REUSEPORT + case TARGET_SO_REUSEPORT: + optname =3D SO_REUSEPORT; + break; +#endif case TARGET_SO_TYPE: optname =3D SO_TYPE; break; @@ -2222,6 +2227,11 @@ static abi_long do_getsockopt(int sockfd, int level,= int optname, case TARGET_SO_REUSEADDR: optname =3D SO_REUSEADDR; goto int_case; +#ifdef SO_REUSEPORT + case TARGET_SO_REUSEPORT: + optname =3D SO_REUSEPORT; + goto int_case; +#endif case TARGET_SO_TYPE: optname =3D SO_TYPE; goto int_case; --=20 2.17.2