qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Lucien Murray-Pitts <lucienmp.qemu@gmail.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: Lucien Anti-Spam <lucienmp_antispam@yahoo.com>,
	qemu-devel@nongnu.org, Laurent Vivier <laurent@vivier.eu>
Subject: Re: [Qemu-devel] RFC: Why does target/m68k RTE insn. use gen_exception
Date: Sat, 29 Jun 2019 00:50:30 +0900	[thread overview]
Message-ID: <20190628155030.GA34320@localhost.localdomain> (raw)
In-Reply-To: <eadb57ae-256d-0bb7-5988-f493662a5caf@linaro.org>

On Fri, Jun 28, 2019 at 11:35:48AM +0200, Richard Henderson wrote:
> On 6/28/19 2:27 AM, Lucien Murray-Pitts wrote:
> > 
> > [snip] ... the "return" address is the instruction that causes the exception.
> > So it immediately does return to the ISR.
> > This is a different issue, but I think interrelated to the original problem.
> 
> Is this a synchronous exception, like a SIGSEGV, that the instruction is
> causing?  I have made attempts at fixing asynchronous interrupts, like the
> clock, in the presence of single-stepping.  I haven't tested that in a while
> and I hope it's still working...

This issue is to do with the stack frame generation storing the retaddr
which is the current PC, I cant find any way to obtain the next PC when
not inside the instructions (say a bus handler).  So RTE will return to
the instruction causing SIGSEGV

 op_helper.c
   static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
   ...
     if (cs->exception_index == EXCP_ACCESS) {
      ...
      do_stack_frame(env, &sp, 7, oldsr, 0, retaddr /*LMP: BROKEN - needs PC NEXT*/);

Actually according to the MC68000 manuals the "return address" (the PC saved on
the stack) can be upto 5 instructions later due to prefetch. So some pc_next would best
be used here.

I am not clear how this should work in the presence of an MMU though.

I am triggering this from inside my device by doing the following, since that memory address
should dynamically cause a bus error (I hope this is the right way to do it)
   cpuclass->do_unassigned_access( s->cpu, /*addr*/0x0, /*is_write*/1, /*is_exec*/0, opaque, /*size*/4);

Something similar with TRAP#0 / RTE combination will happen.
Stepping on the TRAP#0 does correctly get me to the ISR, but a subsequent RTE will
step me +1 past the return whilst a break point and run will land in the right place.
I need to experiment a bit more with a solid setup.


> > Further single stepping INTO the failing instruction results in ending up
> > at the ISR +1 instruction
> 
> For a synchronous exception, that sounds like a real bug.
> 
> Probably within cpu_handle_exception,
> 
>   #else
>           if (replay_exception()) {
>               CPUClass *cc = CPU_GET_CLASS(cpu);
>               qemu_mutex_lock_iothread();
>               cc->do_interrupt(cpu);
>               qemu_mutex_unlock_iothread();
> +             /* Single-step into the exception handler.  */
> +             if (cpu->singlestep_enabled) {
> +                 cpu_handle_debug_exception(cpu);
> +             }
>               cpu->exception_index = -1;
>           } else if (!replay_has_interrupt()) {
> 
> 
> r~

I see the function but in 4.0 its been mangled a bit more, so I will have to get
back to you.  Seems that the issue persists in 2.x so maybe this is something new.

Cheers,
Luc



  reply	other threads:[~2019-06-28 15:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2136180936.260219.1561641583358.ref@mail.yahoo.com>
2019-06-27 13:19 ` [Qemu-devel] RFC: Why does target/m68k RTE insn. use gen_exception Lucien Anti-Spam via Qemu-devel
2019-06-27 13:22   ` Lucien Anti-Spam via Qemu-devel
2019-06-27 17:09     ` Richard Henderson
2019-06-28  0:27       ` Lucien Murray-Pitts
2019-06-28  9:35         ` Richard Henderson
2019-06-28 15:50           ` Lucien Murray-Pitts [this message]
2019-06-29 10:15             ` Richard Henderson
2019-06-29 16:36               ` Lucien Murray-Pitts
2019-06-30  8:20                 ` Richard Henderson
2019-07-01  9:10                 ` Peter Maydell
2019-07-01 12:04                   ` Lucien Anti-Spam via Qemu-devel
2019-07-01 12:11                     ` Peter Maydell
2019-07-09 16:58                       ` Lucien Murray-Pitts
2019-07-09 17:06                         ` Peter Maydell
2019-07-09 19:04                         ` Richard Henderson
2019-07-10 13:35                           ` Lucien Murray-Pitts
2019-07-10 17:50                           ` Lucien Murray-Pitts
2019-07-10 18:15                             ` Alex Bennée
2019-07-11  9:00                               ` Peter Maydell
2019-07-11  9:18                             ` Richard Henderson
2019-07-12 20:55                           ` Lucien Murray-Pitts

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=20190628155030.GA34320@localhost.localdomain \
    --to=lucienmp.qemu@gmail.com \
    --cc=laurent@vivier.eu \
    --cc=lucienmp_antispam@yahoo.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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).