From patchwork Mon Nov 12 20:49:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 150877 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3598397ljp; Mon, 12 Nov 2018 12:53:41 -0800 (PST) X-Google-Smtp-Source: AJdET5eKH/EDWHKbZQ1j/5//HHvQhKq5QUzgGdXryqgJYjlK9FjnDoXg2PRT5x8wD7LOt2IVQSYW X-Received: by 2002:ac8:450c:: with SMTP id q12mr2381783qtn.309.1542056021871; Mon, 12 Nov 2018 12:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542056021; cv=none; d=google.com; s=arc-20160816; b=BRsQkniBRJ5zOEZ5YCDgz0YcBeZr2yp7d0Fmw9uguoOpc9SHsrRiTQNtaYY774kxCM XvXOUzC+4UlWt85de1xp9TnxQ7YVD8xiy6+gEKHHoIPGbZYkgh0lezkTzlb00QDYLmYx ymWH6DtH/vT0NrUUrd5vBZH5B46/5ScSgE+FMAMx6g4AD0hQNHMqWPVOY7wb4CJXFsYy xKOMZC0qHCIZ7tqDFPpdr38VoKEjb+emLLhbO/XY1MuL9XAwME0zdyXrKInKoMc2lEzU A6X+meq3DJM86h42ez2kNlqBicbOmAZpxFW8sIV6NTJWXSXeR4tFfOtcBierkwDP9RFF 9A5Q== 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:subject:references:in-reply-to :message-id:date:to:from; bh=op3HqANgMmAeAkYRDmaOsRoncuwlwu3DpID6TbkCS7o=; b=hTqLzwP9ZXN6dJBe705QArXEFh4GhrXaysMUxYUBSRnhP+lT1TanwhO782Q5gdGV68 h5xBISK3bUIKVEOJ9YZDWvKoKzzMFdGA7s300WFVFUePvTfB2Hc2pXzIz702lfTSMGhb 3yY9nAH1MhrWybFW0u9E+bgLu43iWJF0/ZTlNEDnEW3Dy+xh0sytdFL1LhJCw8Qy+SGm hXM5eOlVAg0l4vB2+oUI/R6S3zWNuzDMy1Qw5QRciq3oXFFhoXjkjkYBXHR/wDaOYYs0 E2tN5DPkg0Xsbaop3icDg1JgaAw3S3oysh2nbsxxDAnybvGPSfWgucFztl3cTx26zYRO XFBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y13si5764224qti.151.2018.11.12.12.53.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Nov 2018 12:53:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:50608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJDJ-0006FN-9M for patch@linaro.org; Mon, 12 Nov 2018 15:53:41 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.2 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 = ENV_GET_CPU(env); Nios2CPU *cpu = NIOS2_CPU(cs); target_siginfo_t info; - int trapnr, gdbsig, ret; + int trapnr, ret; for (;;) { cpu_exec_start(cs); trapnr = cpu_exec(cs); cpu_exec_end(cs); - gdbsig = 0; switch (trapnr) { case EXCP_INTERRUPT: @@ -68,7 +67,10 @@ void cpu_loop(CPUNios2State *env) env->regs[R_EA] = env->regs[R_PC] + 4; env->regs[R_PC] = cpu->exception_addr; - gdbsig = TARGET_SIGTRAP; + info.si_signo = TARGET_SIGTRAP; + info.si_errno = 0; + info.si_code = 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 = TARGET_SIGILL; - break; - } - if (gdbsig) { - gdb_handlesig(cs, gdbsig); - if (gdbsig != TARGET_SIGTRAP) { - exit(EXIT_FAILURE); - } + abort(); } process_pending_signals(env);