public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH for-11.0] tcg: Pass host-endian values to plugin_gen_mem_callbacks_*
Date: Wed, 25 Mar 2026 08:15:51 -0700	[thread overview]
Message-ID: <1bc4bc8c-4ef7-445f-816f-f76380ee264a@linaro.org> (raw)
In-Reply-To: <8c67019a-49c0-4651-9c02-0d15ae262888@linaro.org>

On 3/24/26 9:59 PM, Richard Henderson wrote:
> On 3/25/26 11:39, Pierrick Bouvier wrote:
>> Hi Richard,
>>
>> On 3/24/26 5:40 PM, Richard Henderson wrote:
>>> If the host does not support swapped-endian loads and stores,
>>> then we emulate those within the tcg expanders with explicit
>>> bswap operations.
>>>
>>> However, we were passing values to the plugin interface in
>>> the middle of those bswap operations, which meant that we
>>> would pass values of the wrong endianness to plugins when
>>> running on hosts without swapped-endian loads and stores.
>>>
>>> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3351
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>> ---
>>>
>>> Hi Pierrick,
>>>
>>> On IRC I expressed the opinion that there was an additional
>>> big-endian bug with how we treat neg.plugin_mem_value_low,
>>> but I now see that isn't true, because of how we adjust the
>>> store address in plugin_gen_mem_callbacks_i32.
>>>
>>
>> Yes, we store the value directly swapped, so there is no further transformation needed.
>
> It's not about storing the value swapped, it's about storing the i32 to the low part of
> the uint64_t for the host endianness.
>

I finally realized the orig_value we had is already in host-endian 
order, while I was assuming it was in target-endian order. Thus the 
confusion in our conversion. All good now.

>> It works, but it is still not clear to me why the value orig_val (which is not swapped and
>> in target-endian order) gets stored swapped correctly in neg.plugin_mem_value_low.
> 
> Again, it is *not* swapped: orig_val is host-endian order, and so is neg.plugin_mem_value_low.
> 
>> I'll probably add another patch to document that better in plugin api, and remove the
>> additional swapping done in tests/tcg/plugins/mem.c.
> 
> What swapping is that?
>

It tracks memory regions we accessed, so which byte was written matters 
in this case, thus the need to swap to target-endian order.

> There's a variable called "swapped_value", but it appears to be mis-named, or a remnant of
> swapping that used to occur.
>

It's basically the value in target-endian order. FROM_BE should to TO_BE 
as well, even though both macros do exactly the same (FROM or TO acting 
as documentation to express the intent).

> 
> r~



  reply	other threads:[~2026-03-25 15:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25  0:40 [PATCH for-11.0] tcg: Pass host-endian values to plugin_gen_mem_callbacks_* Richard Henderson
2026-03-25  1:39 ` Pierrick Bouvier
2026-03-25  4:59   ` Richard Henderson
2026-03-25 15:15     ` Pierrick Bouvier [this message]
2026-03-25  2:45 ` Pierrick Bouvier

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=1bc4bc8c-4ef7-445f-816f-f76380ee264a@linaro.org \
    --to=pierrick.bouvier@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