The long term goal is to remove endianness knowledge from QEMU system binaries, allowing them to run vCPU in any endianness. For that target_words_bigendian(), TARGET_BIG_ENDIAN and few other things (like MO_TE) must be removed.
Have each target implement a datapath_is_big_endian() handler to express whether the CPU data is expected to be accessed in big endian or not. Few targets already provide a such functionality (ARM, PPC); for some the data endianness is exposed via a CPU bit; and for many the data endianness is fixed. Use this handler in 3 places: disas/, the generic-loader device and the VirtIO core layer. Note, a similar CPUClass::codepath_is_big_endian() helper could be useful for translator_ld/st_swap() API. Philippe Mathieu-Daudé (20): exec/tswap: Rename target_words_bigendian -> qemu_binary_is_bigendian hw/core/cpu: Introduce CPUClass::datapath_is_big_endian() handler target/arm: Implement CPUClass::datapath_is_big_endian target/ppc: Register CPUClass::datapath_is_big_endian target/rx: Implement CPUClass::datapath_is_big_endian target/sparc: Implement CPUClass::datapath_is_big_endian target/riscv: Implement CPUClass::datapath_is_big_endian target/sh4: Expose CPUSH4State::little_endian property target/sh4: Implement CPUClass::datapath_is_big_endian target/microblaze: Implement CPUClass::datapath_is_big_endian target/mips: Implement CPUClass::datapath_is_big_endian target/xtensa: Implement xtensa_isa_is_big_endian() target/xtensa: Implement CPUClass::datapath_is_big_endian target: Implement CPUClass::datapath_is_big_endian (little-endian) target: Implement CPUClass::datapath_is_big_endian (big-endian) hw/core/cpu: Expose cpu_datapath_is_big_endian() method disas: Use cpu_datapath_is_big_endian() hw/core/generic-loader: Use cpu_datapath_is_big_endian() hw/virtio: Use cpu_datapath_is_big_endian() hw/core/cpu: Remove cpu_virtio_is_big_endian() include/exec/tswap.h | 18 +++++++++--------- include/hw/core/cpu.h | 22 ++++++++++++---------- include/hw/core/sysemu-cpu-ops.h | 8 -------- include/hw/xtensa/xtensa-isa.h | 1 + target/microblaze/cpu.h | 2 ++ target/sh4/cpu.h | 6 ++++++ cpu-target.c | 2 +- disas/disas-common.c | 3 +-- hw/core/cpu-common.c | 7 +++++++ hw/core/cpu-sysemu.c | 11 ----------- hw/core/generic-loader.c | 7 ++----- hw/display/vga.c | 4 ++-- hw/virtio/virtio.c | 4 ++-- system/qtest.c | 2 +- target/alpha/cpu.c | 6 ++++++ target/arm/cpu.c | 4 ++-- target/avr/cpu.c | 7 ++++++- target/hexagon/cpu.c | 6 ++++++ target/hppa/cpu.c | 6 ++++++ target/i386/cpu.c | 6 ++++++ target/loongarch/cpu.c | 6 ++++++ target/m68k/cpu.c | 6 ++++++ target/microblaze/cpu.c | 11 +++++++++++ target/mips/cpu.c | 9 +++++++++ target/openrisc/cpu.c | 6 ++++++ target/ppc/cpu_init.c | 8 ++++---- target/riscv/cpu.c | 17 +++++++++++++++++ target/rx/cpu.c | 10 ++++++++++ target/s390x/cpu.c | 6 ++++++ target/sh4/cpu.c | 16 ++++++++++++++++ target/sparc/cpu.c | 15 +++++++++++++++ target/tricore/cpu.c | 6 ++++++ target/xtensa/cpu.c | 8 ++++++++ target/xtensa/xtensa-isa.c | 7 +++++++ 34 files changed, 205 insertions(+), 58 deletions(-) -- 2.45.2