qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
	Gustavo Romero <gustavo.romero@linaro.org>
Cc: 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 17:01:03 +0100	[thread overview]
Message-ID: <40afd528-ece1-42eb-8d02-d2094ebc58c9@linaro.org> (raw)
In-Reply-To: <CAFEAcA_gkyMTynt6ndVCDaq1RwwvpOUbYNm-=RjE17xuuTTCyw@mail.gmail.com>

On 11/6/25 16:57, Peter Maydell wrote:
> 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" ?

There is, at least with --enable-debug-tcg.
I assumed there was a crash from the description,
but I haven't yet tried the test case Gustavo put together.


r~



  reply	other threads:[~2025-11-06 16:01 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
2025-11-06 16:01     ` Richard Henderson [this message]
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=40afd528-ece1-42eb-8d02-d2094ebc58c9@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=anjo@rev.ng \
    --cc=gustavo.romero@linaro.org \
    --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).