From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm <qemu-arm@nongnu.org>, QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 03/11] target/arm: Introduce read_pc
Date: Wed, 7 Aug 2019 11:04:35 -0700 [thread overview]
Message-ID: <061145be-4cd4-b8e6-ae5c-562a59e8088f@linaro.org> (raw)
In-Reply-To: <CAFEAcA_MFg1_gpaT5+X71s8r5SYZFTizdXs2vQ_6mLooP7E+kg@mail.gmail.com>
On 8/7/19 10:27 AM, Peter Maydell wrote:
>> +/* The architectural value of PC. */
>> +static uint32_t read_pc(DisasContext *s)
>> +{
>> + return s->pc_curr + (s->thumb ? 4 : 8);
>> +}
>> +
>> /* Set a variable to the value of a CPU register. */
>> static void load_reg_var(DisasContext *s, TCGv_i32 var, int reg)
>> {
>> if (reg == 15) {
>> - uint32_t addr;
>> - /* normally, since we updated PC, we need only to add one insn */
>> - if (s->thumb)
>> - addr = (long)s->pc + 2;
>> - else
>> - addr = (long)s->pc + 4;
>> - tcg_gen_movi_i32(var, addr);
>> + tcg_gen_movi_i32(var, read_pc(s));
>
> So previously:
> * for A32 we would return s->pc + 4, which is the same as s->pc_curr + 8
> * for T16 we would return s->pc + 2, which is the same as s->pc_curr + 4
> * for T32 we would return s->pc + 2 -- but that's not the same as
> s->pc_curr + 4, it's s->pc_curr + 6...
>
> Since s->pc_curr + 4 is the right architectural answer, are we
> fixing a bug here? Or are all the places where T32 code calls
> this function UNPREDICTABLE for the reg == 15 case ?
I believe that this is UNPREDICTABLE.
The T32 cases that reference the PC that are not UNPREDICTABLE, literal memory
references and adr, are all of the form (s->pc & ~3) and do not come through
load_reg_var(). Those will be unified by add_reg_for_lit() in the next patch.
r~
next prev parent reply other threads:[~2019-08-07 18:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-07 4:53 [Qemu-devel] [PATCH 00/11] target/arm: decodetree prep patches Richard Henderson
2019-08-07 4:53 ` [Qemu-devel] [PATCH 01/11] target/arm: Pass in pc to thumb_insn_is_16bit Richard Henderson
2019-08-08 5:47 ` Philippe Mathieu-Daudé
2019-08-07 4:53 ` [Qemu-devel] [PATCH 02/11] target/arm: Introduce pc_curr Richard Henderson
2019-08-07 4:53 ` [Qemu-devel] [PATCH 03/11] target/arm: Introduce read_pc Richard Henderson
2019-08-07 17:27 ` Peter Maydell
2019-08-07 18:04 ` Richard Henderson [this message]
2019-08-07 18:16 ` Peter Maydell
2019-08-07 18:25 ` Richard Henderson
2019-08-07 4:53 ` [Qemu-devel] [PATCH 04/11] target/arm: Introduce add_reg_for_lit Richard Henderson
2019-08-08 5:43 ` Philippe Mathieu-Daudé
2019-08-07 4:53 ` [Qemu-devel] [PATCH 05/11] target/arm: Remove redundant s->pc & ~1 Richard Henderson
2019-08-07 4:53 ` [Qemu-devel] [PATCH 06/11] target/arm: Replace s->pc with s->base.pc_next Richard Henderson
2019-08-07 4:53 ` [Qemu-devel] [PATCH 07/11] target/arm: Replace offset with pc in gen_exception_insn Richard Henderson
2019-08-07 4:53 ` [Qemu-devel] [PATCH 08/11] target/arm: Replace offset with pc in gen_exception_internal_insn Richard Henderson
2019-08-07 4:53 ` [Qemu-devel] [PATCH 09/11] target/arm: Remove offset argument to gen_exception_bkpt_insn Richard Henderson
2019-08-07 4:53 ` [Qemu-devel] [PATCH 10/11] target/arm: Use unallocated_encoding for aarch32 Richard Henderson
2019-08-07 17:35 ` Philippe Mathieu-Daudé
2019-08-26 8:45 ` [Qemu-devel] [Qemu-arm] " Laurent Desnogues
2019-08-07 4:53 ` [Qemu-devel] [PATCH 11/11] target/arm: Remove helper_double_saturate Richard Henderson
2019-08-07 17:52 ` [Qemu-devel] [PATCH 00/11] target/arm: decodetree prep patches Peter Maydell
2019-08-09 12:49 ` 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=061145be-4cd4-b8e6-ae5c-562a59e8088f@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.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).