qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Martin Galvan <martin.galvan@tallertechnologies.com>
To: Richard Henderson <rth@twiddle.net>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Anthony Liguori" <aliguori@amazon.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH] cpu-exec: Don't mask out external interrupts when single-stepping an invalid instruction.
Date: Mon, 15 Sep 2014 13:02:56 -0300	[thread overview]
Message-ID: <CAOKbPbZ7FF+AAu2EiVqQ0FXTyNC6zFWB8nxzyk9hGbb7yL5EAQ@mail.gmail.com> (raw)
In-Reply-To: <CAOKbPbZ_ZNp=jRtLH2qZ0TwH-Y039Gtn=DZT0rk3oHOrqC+_FA@mail.gmail.com>

I did a bit more research on how Cortex-M handles nested interrupts.
In particular, I noticed if we were to have an invalid instruction
inside the exception handler itself, trying to single-step it would
again cause Qemu not to return control back to gdb. Reading up a bit I
found out that when the CPU is handling an exception, all other
exceptions with the same or lower priority will be blocked.

Qemu seems to implement this by setting the exception as pending, yet
not changing cpu->interrupt_request so that we modify the PC in the
second call to do_interrupt. That seems fine to me, but since the
translation block is the same as before (and if that one contained an
exception_with_syndrome ending in a call to cpu_loop_exit) we'll be
stuck in the loop and we'll never return control to Gdb.

Therefore I have two questions:
1) Is this a bug?
2) If it is, what should the behaviour be? I think we should return
control back to gdb, but we shouldn't try to translate that
instruction again. How could we handle this in a clean way?

On Fri, Sep 12, 2014 at 12:50 PM, Martin Galvan
<martin.galvan@tallertechnologies.com> wrote:
> On Fri, Sep 12, 2014 at 12:37 PM, Richard Henderson <rth@twiddle.net> wrote:
>> Alpha do_interrupt doesn't mess with cpu->interrupt_request at all, and doesn't
>> generate two calls to do_interrupt.  The one call finds the vector for the
>> given interrupt, modifies the PC, and swaps to the shadow register bank.
>>
>
> Indeed it does. The problem is, even if I changed the code inside
> ARM's do_interrupt to set the correct PC in the first call (so the IRQ
> masking wasn't an issue anymore) I'd still be stuck in the loop
> without returning control back to gdb.
>
>> (Which reminds me, we really, Really, need to get those ifdefs in cpu_exec
>> factored out into a nice single cpu callback.  Every time I read this code, I
>> feel I've missed something.)
>
> I totally agree with you there.
>
>>> How do you set cpu->exception_index in to EXCP_DEBUG after calling
>>> do_interrupt with EXCP_OPCDEC?
>>
>> I still don't know, but I know that _I_ don't do it.  I tried stepping through
>> qemu itself here, but I managed to crash the guest gdb in the process; dunno
>> what happened there.
>>
>
> In that case I'll see if I can step through Qemu myself and find out
> how Alpha returns control to gdb. Perhaps we can do the same on ARM.
>
> Thanks a lot!
>
> --
>
> Martín Galván
>
> Software Engineer
>
> Taller Technologies Argentina
>
>
> San Lorenzo 47, 3rd Floor, Office 5
>
> Córdoba, Argentina
>
> Phone: 54 351 4217888 / +54 351 4218211



-- 


Martín Galván

Software Engineer

Taller Technologies Argentina


San Lorenzo 47, 3rd Floor, Office 5

Córdoba, Argentina

Phone: 54 351 4217888 / +54 351 4218211

  reply	other threads:[~2014-09-15 16:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 21:02 [Qemu-devel] [PATCH] cpu-exec: Don't mask out external interrupts when single-stepping an invalid instruction Martin Galvan
2014-09-11 22:13 ` Peter Maydell
2014-09-11 23:52   ` Richard Henderson
2014-09-12 14:33     ` Martin Galvan
2014-09-12 15:37       ` Richard Henderson
2014-09-12 15:50         ` Martin Galvan
2014-09-15 16:02           ` Martin Galvan [this message]
2014-09-15 16:10             ` Peter Maydell
2014-09-15 16:17               ` Andreas Färber
2014-09-15 16:22                 ` 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=CAOKbPbZ7FF+AAu2EiVqQ0FXTyNC6zFWB8nxzyk9hGbb7yL5EAQ@mail.gmail.com \
    --to=martin.galvan@tallertechnologies.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).