qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Michael Rolnik <mrolnik@gmail.com>, qemu-devel@nongnu.org
Cc: Sarah Harris <S.E.Harris@kent.ac.uk>, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH RFC v20 5/8] target/avr: Add instruction translation
Date: Fri, 31 May 2019 10:31:27 -0500	[thread overview]
Message-ID: <89ce6f5b-17d6-5a11-c8c6-da23f1245162@linaro.org> (raw)
In-Reply-To: <20190530190738.22713-6-mrolnik@gmail.com>

On 5/30/19 2:07 PM, Michael Rolnik wrote:
> +    /* decode first instruction */
> +    ctx.inst[0].cpc = pc_start;
> +    decode_opc(&ctx, &ctx.inst[0]);
> +    do {
> +        /* set curr/next PCs */
> +        cpc = ctx.inst[0].cpc;
> +        npc = ctx.inst[0].npc;
> +
> +        /* decode next instruction */
> +        ctx.inst[1].cpc = ctx.inst[0].npc;
> +        decode_opc(&ctx, &ctx.inst[1]);
> +
> +        /* translate current instruction */
> +        tcg_gen_insn_start(cpc);
> +        num_insns++;

I don't believe that this simultaneous decode of two instructions is correct.

Consider if ctx.inst[0] is a branch instruction that is placed as the very last
word of memory.  Ordinarily, the branch would be executed and the
TranslationBlock ended.

However, the advance read of ctx.inst[1] will cause a read from unmapped
address space (causing an exception), or read from a device (causing "Bad ram
pointer" and an abort from qemu_ram_addr_from_host_nofail).

I believe that the feature that you're attempting to support with this, skip
the next instruction, should be handled via an internal flag bit.  This would
end up looking a lot like the HPPA nullify bit, or somewhat like the ARM thumb
condexec_mask.  I can go into specifics if needed.

Such a change would also allow you to structure this code to use
"exec/translator.h", which in the future will likely be mandatory.


r~


  reply	other threads:[~2019-05-31 15:32 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30 19:07 [Qemu-devel] [PATCH RFC v20 0/8] QEMU AVR 8 bit cores Michael Rolnik
2019-05-30 19:07 ` [Qemu-devel] [PATCH RFC v20 1/8] target/avr: Add outward facing interfaces and core CPU logic Michael Rolnik
2019-05-31  8:02   ` Igor Mammedov
2019-05-31  8:15     ` Michael Rolnik
2019-05-31  9:56       ` Igor Mammedov
2019-05-30 19:07 ` [Qemu-devel] [PATCH RFC v20 2/8] target/avr: Add instruction helpers Michael Rolnik
2019-05-31 13:50   ` Richard Henderson
2019-05-30 19:07 ` [Qemu-devel] [PATCH RFC v20 3/8] target/avr: Add mechanism to check for active debugger connection Michael Rolnik
2019-05-31 13:54   ` Richard Henderson
2019-06-01 21:12     ` Michael Rolnik
2019-06-03 15:44       ` Richard Henderson
2019-06-03 16:29         ` Michael Rolnik
2019-06-03 16:36           ` Richard Henderson
2019-06-03 17:04             ` Michael Rolnik
2019-06-05  7:20               ` Michael Rolnik
2019-06-05 14:36                 ` Richard Henderson
2019-06-05 15:19                   ` Michael Rolnik
2019-06-05 16:06                     ` Richard Henderson
2019-06-05 16:10                     ` Alex Bennée
2019-06-05 17:57                       ` Michael Rolnik
2019-05-30 19:07 ` [Qemu-devel] [PATCH RFC v20 4/8] target-avr: Add instruction decoding Michael Rolnik
2019-05-31 14:45   ` Richard Henderson
2019-06-03 20:13     ` Michael Rolnik
2019-06-03 21:48       ` Richard Henderson
2019-05-30 19:07 ` [Qemu-devel] [PATCH RFC v20 5/8] target/avr: Add instruction translation Michael Rolnik
2019-05-31 15:31   ` Richard Henderson [this message]
2019-06-02  3:44     ` Michael Rolnik
2019-06-03 15:31       ` Richard Henderson
2019-06-03 15:34         ` Michael Rolnik
2019-05-30 19:07 ` [Qemu-devel] [PATCH RFC v20 6/8] target/avr: Add limited support for USART and 16 bit timer peripherals Michael Rolnik
2019-05-30 19:07 ` [Qemu-devel] [PATCH RFC v20 7/8] target/avr: Add example board configuration Michael Rolnik
2019-05-31  8:06   ` Igor Mammedov
2019-05-30 19:07 ` [Qemu-devel] [PATCH RFC v20 8/8] target/avr: Register AVR support with the rest of QEMU, the build system, and the MAINTAINERS file Michael Rolnik
2019-05-31 14:50   ` Eric Blake
2019-06-01 21:20     ` Michael Rolnik
2019-06-03 19:47       ` Eric Blake
2019-06-03 19:53         ` Michael Rolnik
2019-05-30 20:16 ` [Qemu-devel] [PATCH RFC v20 0/8] QEMU AVR 8 bit cores no-reply

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=89ce6f5b-17d6-5a11-c8c6-da23f1245162@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=S.E.Harris@kent.ac.uk \
    --cc=mrolnik@gmail.com \
    --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).