qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Marek Vasut <marex@denx.de>, Riku Voipio <riku.voipio@iki.fi>,
	Chris Wulff <crwulff@gmail.com>,
	patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH 2/2] linux-user: Clean up nios2 main loop signal handling
Date: Mon, 12 Nov 2018 17:12:09 +0100	[thread overview]
Message-ID: <592c1ffc-fc4b-580f-91d8-cfc9131c783b@vivier.eu> (raw)
In-Reply-To: <20181019174958.26616-3-peter.maydell@linaro.org>

On 19/10/2018 19:49, Peter Maydell wrote:
> 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 <peter.maydell@linaro.org>
> ---
> Disclaimer: compile tested, and the change makes conceptual
> sense, but I have no nios2 test environment.

I'll push a slightly modified version of this patch: gdbsig is now
unused and my compiler complains about that.

Thanks,
Laurent

> ---
>  linux-user/nios2/cpu_loop.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c
> index dac7a061813..973dd54d791 100644
> --- a/linux-user/nios2/cpu_loop.c
> +++ b/linux-user/nios2/cpu_loop.c
> @@ -68,7 +68,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 +109,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);
> 

  reply	other threads:[~2018-11-12 16:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-19 17:49 [Qemu-devel] [PATCH 0/2] linux-user: Don't call gdb_handlesig unnecessarily Peter Maydell
2018-10-19 17:49 ` [Qemu-devel] [PATCH 1/2] linux-user: Don't call gdb_handlesig() before queue_signal() Peter Maydell
2018-10-19 17:49 ` [Qemu-devel] [PATCH 2/2] linux-user: Clean up nios2 main loop signal handling Peter Maydell
2018-11-12 16:12   ` Laurent Vivier [this message]
2018-10-20 19:49 ` [Qemu-devel] [PATCH 0/2] linux-user: Don't call gdb_handlesig unnecessarily Richard Henderson
2018-11-12 14:39 ` Peter Maydell
2018-11-12 14:46   ` Laurent Vivier
2018-11-12 14:48     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=592c1ffc-fc4b-580f-91d8-cfc9131c783b@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=crwulff@gmail.com \
    --cc=marex@denx.de \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).