On 10/3/24 23:44, Thomas Huth wrote:
On 03/10/2024 23.40, Philippe Mathieu-Daudé wrote:
OK I guess I'm seeing Thomas point now; this series cover was not clear
enough. The goal is to remove TARGET_BIG_ENDIAN so we can build half
objects and do a little step toward the single binary.
Ok, that piece of information was missing in the patch description, indeed.
But the tswap function should already work with common code, see the target_needs_bswap()
stuff in include/exec/tswap.h, so maybe this change here even is not needed at all?
The current practice of target_needs_bswap() merely restricts the scope of
TARGET_BIG_ENDIAN, allowing devices to be built once. It still requires TARGET_BIG_ENDIAN
to exist.
For the goal of single-binary, target_needs_bswap() cannot exist, since there may be no
one correct answer across the system. We will need the sort of infrastructure that Phil
is adding: endianness being chosen by the machine model and/or the instantiated devices.
What is left is deciding on the exact API to use. The ld/st_endian_p interface with a
boolean seems reasonable. It interacts well with TARGET_BIG_ENDIAN as an intermediate
step, as well as with the virtio legacy cpu mode dependent callback.
r~