From: Peter Maydell <peter.maydell@linaro.org>
To: Gustavo Romero <gustavo.romero@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, Anton Johansson <anjo@rev.ng>
Subject: Re: [PATCH] target/arm: Fix accidental write to TCG constant
Date: Thu, 6 Nov 2025 15:57:56 +0000 [thread overview]
Message-ID: <CAFEAcA_gkyMTynt6ndVCDaq1RwwvpOUbYNm-=RjE17xuuTTCyw@mail.gmail.com> (raw)
In-Reply-To: <5ad511f4-eb36-4d49-90a6-fbb1e5f67c6c@linaro.org>
On Thu, 6 Nov 2025 at 15:48, Gustavo Romero <gustavo.romero@linaro.org> wrote:
>
> Hi folks,
>
> On 11/6/25 15:49, Richard Henderson wrote:
> > Currently an unpredictable movw such as
> >
> > movw pc, 0x123
>
> bah, how did you get this insn.? Are you using any fuzzer? :P
>
>
> > results in the tinycode
> >
> > and_i32 $0x123,$0x123,$0xfffffffc
> > mov_i32 pc,$0x123
> > exit_tb $0x0
> >
> > which is clearly a bug, writing to a constant is incorrect and discards
> > the result of the mask. Fix this by adding a temporary in store_reg().
> The difference between v1 and v2 is:
>
> v1:
> mov_i32 tmp3,$0x123
> and_i32 tmp3,tmp3,$0xfffffffc
> mov_i32 pc,tmp3
>
> v2 (this version)
> and_i32 pc,$0x123,$0xfffffffc
>
>
> I think we need only a v3 that updates the commit message since we
> are not adding a temporary anymore.
>
> Interestingly, I was not able to crash the host when native code
> was generated from:
>
> and_i32 $0x123,$0x123,$0xfffffffc
The commit message doesn't say this crashes, it says it
discards the result of the mask. (That is, we intended to
clear the low bits of the guest PC but don't.)
Should there be a TCG debug assert for "TCGv for the
result of an operation is a constant" ?
thanks
-- PMM
next prev parent reply other threads:[~2025-11-06 15:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 14:49 [PATCH] target/arm: Fix accidental write to TCG constant Richard Henderson
2025-11-06 15:48 ` Gustavo Romero
2025-11-06 15:57 ` Peter Maydell [this message]
2025-11-06 16:01 ` Richard Henderson
2025-11-06 17:14 ` Anton Johansson via
2025-11-14 13:03 ` Peter Maydell
-- strict thread matches above, loose matches on Subject: below --
2025-11-05 17:30 Anton Johansson via
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='CAFEAcA_gkyMTynt6ndVCDaq1RwwvpOUbYNm-=RjE17xuuTTCyw@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=anjo@rev.ng \
--cc=gustavo.romero@linaro.org \
--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).