Skip to content

linux-user/aarch64: Support both endianness at runtime

Philippe Mathieu-Daudé qemu-arm qemu-devel 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 11 repliesIn review
  2. v18 patches 1 replySuperseded

Changes in v2 from the cover letter

- add ./configure error msg
- cover ARM32

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12tests/tcg/aarch64_be: Check data byte order in hellotests/tcg/aarch64_be/hello.c+10 -60 replies
2/12tests/tcg/arm: Add BE8 and BE32 hello teststests/tcg/arm/hello-arm-be.c tests/tcg/arm/hello-arm-be32.c tests/tcg/arm/hello-arm.ref +1 more+50 -00 replies
3/12linux-user/aarch64: Move ELF/vDSO endian checks to runtimelinux-user/aarch64/elfload.c linux-user/aarch64/meson.build linux-user/aarch64/target_elf.h +2 more+16 -180 replies
4/12linux-user/aarch64: Move CPU/signal endian checks to runtimelinux-user/aarch64/cpu_loop.c linux-user/aarch64/signal.c target/arm/gdbstub64.c +2 more+16 -240 replies
5/12linux-user/arm: Move ELF/vDSO endian checks to runtimelinux-user/arm/elfload.c linux-user/arm/meson.build linux-user/arm/target_proc.h +2 more+21 -560 replies
6/12linux-user/arm: Move CPU endian checks to runtimelinux-user/arm/cpu_loop.c target/arm/cpu.h+9 -30 replies
7/12target-info: Support runtime-endian Linux-user targetsinclude/exec/tswap.h include/qemu/target-info-def.h include/qemu/target-info.h +2 more+84 -60 replies
8/12linux-user: Honor runtime byte order in ABI accesseslinux-user/elfload.c linux-user/qemu.h linux-user/syscall.c +1 more+20 -160 replies
9/12linux-user: Select target byte order from the ELF headerlinux-user/main.c+26 -00 replies
10/12meson: Support Linux-user executable aliasesmeson.build+12 -10 replies
11/12linux-user/aarch64: Unify both endianness under qemu-aarch64.gitlab-ci.d/buildtest.yml .gitlab-ci.d/crossbuild-template.yml configs/targets/aarch64-linux-user.mak +5 more+36 -160 replies
12/12linux-user/arm: Unify both endianness under qemu-armconfigs/targets/arm-linux-user.mak configs/targets/armeb-linux-user.mak configure +2 more+23 -110 replies

Reviews trailers per patch

None of the 12 patches has a Reviewed-by or Acked-by.

PatchRichard Henderson
1/12
2/12
3/12
4/12
5/12
6/12
7/12Inspired-by
8/12
9/12
10/12
11/12
12/12

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH-for-12.0 v2 00/12] linux-user/aarch64: Support both endianness at runtime

Since v1:
- add ./configure error msg
- cover ARM32

This series lets qemu-aarch64 run both little- and big-endian ELF binaries, retaining qemu-aarch64_be as a compatibility alias.

The ELF loader selects the target byte order once, before execution. AArch64 CPU, signal, ABI and vDSO handling then use that selection. Fixed-endian targets and system emulation retain their existing accessors.

Runtime-endian TargetInfo data is exposed const to readers, allowing target_big_endian() to be inlined without a separate boolean cache. The writable initializer remains outside LTO, preserving the boundary between ELF initialization and subsequent reads.

I compared the complete series against its baseline, with normal and LTO builds and LE/BE guests and did not notice significative speed down.

The inspiration comes from previous optimization intent from Richard:
https://lore.kernel.org/qemu-devel/[email protected]/

Philippe Mathieu-Daudé (12):
tests/tcg/aarch64_be: Check data byte order in hello tests/tcg/arm: Add BE8 and BE32 hello tests linux-user/aarch64: Move ELF/vDSO endian checks to runtime linux-user/aarch64: Move CPU/signal endian checks to runtime linux-user/arm: Move ELF/vDSO endian checks to runtime linux-user/arm: Move CPU endian checks to runtime
target-info: Support runtime-endian Linux-user targets
linux-user: Honor runtime byte order in ABI accesses
linux-user: Select target byte order from the ELF header
meson: Support Linux-user executable aliases linux-user/aarch64: Unify both endianness under qemu-aarch64 linux-user/arm: Unify both endianness under qemu-arm

 docs/about/deprecated.rst                 | 23 +++++++++++++
 docs/user/main.rst                        | 18 +++++++++--
 configure                                 | 12 ++++++-
 configs/targets/aarch64-linux-user.mak    |  2 ++
 configs/targets/aarch64_be-linux-user.mak | 10 ------
 configs/targets/arm-linux-user.mak        |  2 ++
 configs/targets/armeb-linux-user.mak      |  9 ------
 meson.build                               | 39 +++++++++++++++++++++--
 include/exec/tswap.h                      | 11 ++++---
 include/qemu/target-info-def.h            | 14 ++++++++
 include/qemu/target-info.h                | 20 ++++++++++++
 linux-user/aarch64/target_elf.h           |  6 +---
 linux-user/aarch64/target_syscall.h       |  6 +---
 linux-user/arm/target_proc.h              | 20 ++++--------
 linux-user/arm/target_syscall.h           |  6 +---
 linux-user/qemu.h                         | 17 +++++++++-
 linux-user/syscall_defs.h                 |  7 ----
 target/arm/cpu.h                          | 10 ++++--
 target/arm/internals.h                    |  2 +-
 linux-user/aarch64/cpu_loop.c             | 12 +++----
 linux-user/aarch64/elfload.c              | 10 +++++-
 linux-user/aarch64/signal.c               | 20 ++++--------
 linux-user/arm/cpu_loop.c                 |  2 +-
 linux-user/arm/elfload.c                  | 36 +++++++--------------
 linux-user/elfload.c                      |  6 +---
 linux-user/main.c                         | 26 +++++++++++++++
 linux-user/syscall.c                      |  6 ++--
 linux-user/uname.c                        | 13 ++------
 target-info-def.c                         | 19 +++++++++++
 target/arm/gdbstub64.c                    |  4 +--
 target/arm/tcg/translate-sve.c            |  2 +-
 tests/tcg/aarch64_be/hello.c              | 16 ++++++----
 tests/tcg/arm/hello-arm-be.c              | 34 ++++++++++++++++++++
 tests/tcg/arm/hello-arm-be32.c            |  4 +++
 .gitlab-ci.d/buildtest.yml                |  2 +-
 .gitlab-ci.d/crossbuild-template.yml      |  4 +--
 linux-user/aarch64/meson.build            | 10 +++---
 linux-user/arm/meson.build                |  4 ---
 tests/tcg/aarch64_be/meson.build          |  4 +--
 tests/tcg/arm/hello-arm.ref               |  1 +
 tests/tcg/arm/meson.build                 | 11 +++++++
 41 files changed, 323 insertions(+), 157 deletions(-)
 delete mode 100644 configs/targets/aarch64_be-linux-user.mak
 delete mode 100644 configs/targets/armeb-linux-user.mak
 create mode 100644 tests/tcg/arm/hello-arm-be.c
 create mode 100644 tests/tcg/arm/hello-arm-be32.c
 create mode 100644 tests/tcg/arm/hello-arm.ref
Signature · 1 line
2.55.0