qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Fedorov <serge.fdrv@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2] target-arm: Clean up DISAS_UPDATE usage in AArch32 translation code
Date: Sun, 15 Nov 2015 23:30:05 +0300	[thread overview]
Message-ID: <5648EB4D.5090801@gmail.com> (raw)
In-Reply-To: <CAFEAcA-fe930BBty9p=r9XYY3QrJdq0utOnK7Or_4-Udd9LmHA@mail.gmail.com>

On 14.11.2015 22:45, Peter Maydell wrote:
> On 13 November 2015 at 21:13, Sergey Fedorov <serge.fdrv@gmail.com> wrote:
>> On 10.11.2015 15:15, Peter Maydell wrote:
>>> So the way the 32-bit code works for singlestep is complicated
>>> because of the need to handle the conditional instructions,
>>> which means you get a lot more cases like "this is a conditional
>>> SWI" that need to be handled. A quick summary of some of the
>>> possible cases:
>>>
>>>  * unconditional normal instruction:
>>>     -- need to write the PC and condexec bits back to the CPU state
>>>     -- then take a singlestep insn (either the architectural one
>>>        or the EXCP_DEBUG one depending on which sort of step we are doing)
>>>  * unconditional exception-generating instruction
>>>     -- for architectural step of SWI/HVC/SMC we need to advance the
>>>        singlestep state machine so that they behave correctly
>>>     -- generate the relevant exception and then no point writing the
>>>        code to take EXCP_DEBUG &c because we won't get to it
>>>  * conditional instruction (including cond. branches):
>>>     -- earlier code has already written back the PC for the
>>>        "condition passed" case
>>>     -- write out the code which takes the singlestep exception for
>>>        the "condition passed" case
>>>     -- then do gen_set_label(dc->condlabel)
>>>     -- then the code to take the single step exception after
>>>        executing for the "condition failed" case
>>>
>>> In particular in this bit:
>>>         if (dc->condjmp || !dc->is_jmp) {
>>>             gen_set_pc_im(dc, dc->pc);
>>>             dc->condjmp = 0;
>> Hi Peter,
>>
>> Thank you a lot for your explanation! It was really helpful for
>> understanding the code :) One thing I wasn't sure of was whether this
>> "dc->condjmp = 0" means that "condition failed" codepath below will also
>> generate an exception whereas it shouldn't?
> You want a singlestep exception for both conditional-insn
> failed and conditional-insn passed (either way we've executed
> the instruction and should return control to the debugger).

To be clear, I mean SWI/HVC/SMC exceptions could be generated when
singlestepping through a conditional-insn failed codepath.

>
> (The code is I think more confusing than it needs to be
> and also somewhat repetitive in the way we have the same code for
> "handle a trap insn if condjmp" and "handle a trap insn if
> not condjmp".)

I think I could make this code more clear and concise as well as put
some comments to describe it :)

Best regards,
Sergey

>
>> Getting into the way the condexec bits handled I see that
>> gen_set_condexec() should be called before
>> gen_helper_check_breakpoints(), and probably also before
>> gen_helper_access_check_cp_reg() because these helpers can raise an
>> exception. I'm going to prepare patches for that soon.
> Yes, I think this is right in both cases. (I'm kind of
> surprised that we haven't noticed the invalid condexec
> for conditional Thumb mode system register accesses, but
> I guess mostly guests don't try to access registers that
> are going to trap.)

  reply	other threads:[~2015-11-15 20:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09 19:37 [Qemu-devel] [PATCH v2] target-arm: Clean up DISAS_UPDATE usage in AArch32 translation code Sergey Fedorov
2015-11-10 12:15 ` Peter Maydell
2015-11-13 21:13   ` Sergey Fedorov
2015-11-14 19:45     ` Peter Maydell
2015-11-15 20:30       ` Sergey Fedorov [this message]
2015-11-15 21:43         ` Peter Maydell
2015-11-10 13:47 ` 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=5648EB4D.5090801@gmail.com \
    --to=serge.fdrv@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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).