On 5/5/25 5:59 AM, Paolo Bonzini wrote:
On Mon, May 5, 2025 at 12:54 PM Philippe Mathieu-Daudé
<phi...@linaro.org> wrote:
I don't think target_long/target_ulong is a big blocker towards single-
binary anyway. The trick is to confine it to target/, making it
essentially a #define. That is, let target/* include one of two new
headers target_long_32.h and target_long_64.h. See lore.kernel.org/
r/68b6c799-6407-43cc-aebc-a0ef6b8b6...@redhat.com as well.
In an ideal world, it should be eliminated completely.
The root problem is that it creates variation of symbols/types, which
obviously can't be unified later when we mix targets together.
Of course, it's a paradigm shift, as QEMU traditionally was written with
the "per target" approach in mind.
From this perspective, the only place where it could eventually survive
is within static functions or types private to a compilation unit, only
if this compilation unit is private to a unique target architecture
(TARGET_AARCH64 only for instance).
But in this case, it's much more easy to get rid of it and replace with
it the real type directly. So I don't see any good reason to keep it
anywhere.
Our solution here is to "widen" the concerned definitions, using vaddr
or uint64_t for target_ulong (vaddr is possible only for addresses,
because we removed 64 bits guests support on 32 bits hosts - I hope it
won't bite us later).
For target_long, it's more tricky, as sign extension matters.
The problem is that it will necessarily break some stable interfaces,
which were expecting a uint32_t before, but I think it's a necessary
change to do at some point. But it can be done slowly and on a per
target basis.
Yes, I have this tagged to understand and address. Maybe Pierrick
already understood the issue (similar mention from Richard? [1]) and
is addressing it, see [2].
Those are different. TCGv_vaddr is able to store a *host* pointer,
i.e. a host uintptr_t. But target_long/target_ulong are already
completely absent from tcg/ (there are a couple appearances in
include/tcg), so I'm proposing to remove them completely and leave
them as just macros.
From what I understood, the original meaning is that vaddr can contain
a *guest* pointer, and not a *host* pointer. Since 64 bits targets have
been disabled for 32 bits hosts, vaddr definition was changed to
uintptr_t, where it was uint64_t before. [1]
[1]
https://gitlab.com/qemu-project/qemu/-/commit/a70af12addd9060fdf8f3dbd42b42e3072c3914f
Please give me a shout once the target-arm/ series lands, I can look
into this further.
The current series is mostly complete, and focused on low hanging
fruits. The one remaining are a bit harder, and/or have external
dependencies, but I didn't see anything impossible so far.
Luckily, we didn't have a lot of target_ulong in Arm related structs, so
it's pretty easy to change. Some other architectures (especially the
ones using them in cpu.h) will be harder.
Paolo