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
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/20260511190634.472174-1-richard.henderson@linaro.org/ 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 -- 2.55.0
On 11/12/26 11:08, Philippe Mathieu-Daudé wrote: > 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. Why would we want to do this? qemu-aarch64_be exists, but is essentially unused. It's certainly not supported by upstream Linux. Having runtime selection of endianness seems silly within that context. r~
On Fri, 13 Nov 2026 at 18:39, Richard Henderson <richard.henderson@linaro.org> wrote: > > On 11/12/26 11:08, Philippe Mathieu-Daudé wrote: > > 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. > > Why would we want to do this? qemu-aarch64_be exists, but is > essentially unused. It's certainly not supported by upstream Linux. I know the kernel just dropped big-endian kernel support recently, but did that also extend to userspace ? (We should check with the kernel and gcc folks about whether/when it makes sense to deprecate qemu-aarch64_be.) > Having runtime selection of endianness seems silly within that context. As a more general question, is this something we would want for architectures where both endiannesses are relevant (e.g. mips, ppc64)? At the moment we consistently for all targets handle big vs little endian as "it's a separate target with its own executable". That's convenient because you can at compile time hardwire in things like variations in struct layout between the two. We could switch to doing that kind of thing at runtime, but what is the benefit we're aiming for by doing that? thanks -- PMM
On 13/11/26 19:55, Peter Maydell wrote: > On Fri, 13 Nov 2026 at 18:39, Richard Henderson > <richard.henderson@linaro.org> wrote: >> >> On 11/12/26 11:08, Philippe Mathieu-Daudé wrote: >>> 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. >> >> Why would we want to do this? qemu-aarch64_be exists, but is >> essentially unused. It's certainly not supported by upstream Linux. > > I know the kernel just dropped big-endian kernel support > recently, but did that also extend to userspace ? > > (We should check with the kernel and gcc folks about > whether/when it makes sense to deprecate qemu-aarch64_be.) > >> Having runtime selection of endianness seems silly within that context. > > As a more general question, is this something we would want > for architectures where both endiannesses are relevant (e.g. > mips, ppc64)? At the moment we consistently for all targets > handle big vs little endian as "it's a separate target with > its own executable". That's convenient because you can at > compile time hardwire in things like variations in struct > layout between the two. We could switch to doing that kind > of thing at runtime, but what is the benefit we're aiming > for by doing that? I did the other conversions (Microblaze, Xtensa, PPC, MIPS, SH4) and wanted to test the water first where this would get more attention, with the series involving less changes. My motivation is MIPS where we currently have 6 binaries and I'd like to add binaries to cover more ABIs without having a combinatory explosion and have 18 linux-user MIPS binaries. With this approach I reduced the current MIPS set to 3 binaries and add 2 more, ending with 5 covering more ABIs instead of currently 6. In order to get there I need the few core changes introduced in this series, which affect all user binaries. I have the idea ARM users are the first ones interested by no performance change thus is where I started the benchmark to prove this approach have no impact in emulation. The TargetInfo structure change (one initializer LTO-protected and all accessors via read-only exposed structure) is also what Richard was very keen to have (page size support planned) instead of the current approach. I'm thus returning the question as: why would we not want to do this? Regards, Phil.
On Mon, 16 Nov 2026 at 08:53, Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> wrote: > > On 13/11/26 19:55, Peter Maydell wrote: > > As a more general question, is this something we would want > > for architectures where both endiannesses are relevant (e.g. > > mips, ppc64)? At the moment we consistently for all targets > > handle big vs little endian as "it's a separate target with > > its own executable". That's convenient because you can at > > compile time hardwire in things like variations in struct > > layout between the two. We could switch to doing that kind > > of thing at runtime, but what is the benefit we're aiming > > for by doing that? > > I did the other conversions (Microblaze, Xtensa, PPC, MIPS, SH4) > and wanted to test the water first where this would get more attention, > with the series involving less changes. > > My motivation is MIPS where we currently have 6 binaries and I'd like > to add binaries to cover more ABIs without having a combinatory > explosion and have 18 linux-user MIPS binaries. With this approach I > reduced the current MIPS set to 3 binaries and add 2 more, ending with > 5 covering more ABIs instead of currently 6. > > In order to get there I need the few core changes introduced in this > series, which affect all user binaries. I have the idea ARM users are > the first ones interested by no performance change thus is where > I started the benchmark to prove this approach have no impact in emulation. > > The TargetInfo structure change (one initializer LTO-protected and > all accessors via read-only exposed structure) is also what Richard > was very keen to have (page size support planned) instead of the > current approach. > > I'm thus returning the question as: why would we not want to do this? Mostly because what we have today works, and the idea of "the target ABI is known at compile-time" is quite deeply embedded in the way the linux-user code is written (both in terms of ifdefs and also C types being defined appropriately for one specific ABI). The idea of not having to have 18 different MIPS linux-user binaries is pretty tempting, though. thanks -- PMM
On 11/16/2026 2:00 AM, Peter Maydell wrote: > On Mon, 16 Nov 2026 at 08:53, Philippe Mathieu-Daudé > <philmd@oss.qualcomm.com> wrote: >> >> On 13/11/26 19:55, Peter Maydell wrote: >>> As a more general question, is this something we would want >>> for architectures where both endiannesses are relevant (e.g. >>> mips, ppc64)? At the moment we consistently for all targets >>> handle big vs little endian as "it's a separate target with >>> its own executable". That's convenient because you can at >>> compile time hardwire in things like variations in struct >>> layout between the two. We could switch to doing that kind >>> of thing at runtime, but what is the benefit we're aiming >>> for by doing that? >> >> I did the other conversions (Microblaze, Xtensa, PPC, MIPS, SH4) >> and wanted to test the water first where this would get more attention, >> with the series involving less changes. >> >> My motivation is MIPS where we currently have 6 binaries and I'd like >> to add binaries to cover more ABIs without having a combinatory >> explosion and have 18 linux-user MIPS binaries. With this approach I >> reduced the current MIPS set to 3 binaries and add 2 more, ending with >> 5 covering more ABIs instead of currently 6. >> >> In order to get there I need the few core changes introduced in this >> series, which affect all user binaries. I have the idea ARM users are >> the first ones interested by no performance change thus is where >> I started the benchmark to prove this approach have no impact in emulation. >> >> The TargetInfo structure change (one initializer LTO-protected and >> all accessors via read-only exposed structure) is also what Richard >> was very keen to have (page size support planned) instead of the >> current approach. >> >> I'm thus returning the question as: why would we not want to do this? > > Mostly because what we have today works, and the idea of "the > target ABI is known at compile-time" is quite deeply embedded in the > way the linux-user code is written (both in terms of ifdefs and > also C types being defined appropriately for one specific ABI). > The last part is what we had for system mode, and precisely what we have been able to eliminate while working on the single-binary. We could keep minimal wrappers to previous binaries in case we want to wait a few releases to completely remove them. In this case, the benefit is that the same existing binary (without endianness variant) will be able to run "more things". Since we talk about user-mode, it's strictly dependent on the program passed in parameter, and we don't need to manually specify endianness anywhere. For the "how to make sure it works like before?", as usual, testing, and a small leap of faith are required. Overall, I think it would be a nice move for user-mode. > The idea of not having to have 18 different MIPS linux-user binaries > is pretty tempting, though. > > thanks > -- PMM Regards, Pierrick
On Mon, 16 Nov 2026 at 16:31, Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> wrote: > > On 11/16/2026 2:00 AM, Peter Maydell wrote: > > On Mon, 16 Nov 2026 at 08:53, Philippe Mathieu-Daudé > > <philmd@oss.qualcomm.com> wrote: > >> > >> On 13/11/26 19:55, Peter Maydell wrote: > >>> As a more general question, is this something we would want > >>> for architectures where both endiannesses are relevant (e.g. > >>> mips, ppc64)? At the moment we consistently for all targets > >>> handle big vs little endian as "it's a separate target with > >>> its own executable". That's convenient because you can at > >>> compile time hardwire in things like variations in struct > >>> layout between the two. We could switch to doing that kind > >>> of thing at runtime, but what is the benefit we're aiming > >>> for by doing that? > >> > >> I did the other conversions (Microblaze, Xtensa, PPC, MIPS, SH4) > >> and wanted to test the water first where this would get more attention, > >> with the series involving less changes. > >> > >> My motivation is MIPS where we currently have 6 binaries and I'd like > >> to add binaries to cover more ABIs without having a combinatory > >> explosion and have 18 linux-user MIPS binaries. With this approach I > >> reduced the current MIPS set to 3 binaries and add 2 more, ending with > >> 5 covering more ABIs instead of currently 6. > >> > >> In order to get there I need the few core changes introduced in this > >> series, which affect all user binaries. I have the idea ARM users are > >> the first ones interested by no performance change thus is where > >> I started the benchmark to prove this approach have no impact in emulation. > >> > >> The TargetInfo structure change (one initializer LTO-protected and > >> all accessors via read-only exposed structure) is also what Richard > >> was very keen to have (page size support planned) instead of the > >> current approach. > >> > >> I'm thus returning the question as: why would we not want to do this? > > > > Mostly because what we have today works, and the idea of "the > > target ABI is known at compile-time" is quite deeply embedded in the > > way the linux-user code is written (both in terms of ifdefs and > > also C types being defined appropriately for one specific ABI). > > > > The last part is what we had for system mode, and precisely what we have > been able to eliminate while working on the single-binary. Yes, but it's taken a lot of work to get to that point. For system mode we had some clear reasons why that work was necessary and worthwhile. For user-mode it's less clear to me. Keeping the zoo of MIPS ABIs under control seems the most promising reason. For aarch64 in particular I would prefer to deprecate-and-drop big-endian support (probably starting with the deprecation for 12.0, rather than pushing it into 11.2), since the kernel just did that in 7.4. thanks -- PMM
On 16/11/26 17:53, Peter Maydell wrote: > On Mon, 16 Nov 2026 at 16:31, Pierrick Bouvier > <pierrick.bouvier@oss.qualcomm.com> wrote: >> >> On 11/16/2026 2:00 AM, Peter Maydell wrote: >>> On Mon, 16 Nov 2026 at 08:53, Philippe Mathieu-Daudé >>> <philmd@oss.qualcomm.com> wrote: >>>> >>>> On 13/11/26 19:55, Peter Maydell wrote: >>>>> As a more general question, is this something we would want >>>>> for architectures where both endiannesses are relevant (e.g. >>>>> mips, ppc64)? At the moment we consistently for all targets >>>>> handle big vs little endian as "it's a separate target with >>>>> its own executable". That's convenient because you can at >>>>> compile time hardwire in things like variations in struct >>>>> layout between the two. We could switch to doing that kind >>>>> of thing at runtime, but what is the benefit we're aiming >>>>> for by doing that? >>>> >>>> I did the other conversions (Microblaze, Xtensa, PPC, MIPS, SH4) >>>> and wanted to test the water first where this would get more attention, >>>> with the series involving less changes. >>>> >>>> My motivation is MIPS where we currently have 6 binaries and I'd like >>>> to add binaries to cover more ABIs without having a combinatory >>>> explosion and have 18 linux-user MIPS binaries. With this approach I >>>> reduced the current MIPS set to 3 binaries and add 2 more, ending with >>>> 5 covering more ABIs instead of currently 6. >>>> >>>> In order to get there I need the few core changes introduced in this >>>> series, which affect all user binaries. I have the idea ARM users are >>>> the first ones interested by no performance change thus is where >>>> I started the benchmark to prove this approach have no impact in emulation. >>>> >>>> The TargetInfo structure change (one initializer LTO-protected and >>>> all accessors via read-only exposed structure) is also what Richard >>>> was very keen to have (page size support planned) instead of the >>>> current approach. >>>> >>>> I'm thus returning the question as: why would we not want to do this? >>> >>> Mostly because what we have today works, and the idea of "the >>> target ABI is known at compile-time" is quite deeply embedded in the >>> way the linux-user code is written (both in terms of ifdefs and >>> also C types being defined appropriately for one specific ABI). While we could go one step further and manage distincts ABIs at runtime, I don't see the point so far, and that might have some performance impact (although I'm not that sure). While endianness is part of the kernel ABI, the changes are less invasive because we already did them on system path. >> The last part is what we had for system mode, and precisely what we have >> been able to eliminate while working on the single-binary. > > Yes, but it's taken a lot of work to get to that point. For > system mode we had some clear reasons why that work was > necessary and worthwhile. For user-mode it's less clear to me. On that point, I already did the work -- and test / benchmark -- so it isn't an issue ;) The expected review part isn't huge neither. > Keeping the zoo of MIPS ABIs under control seems the most > promising reason. > > For aarch64 in particular I would prefer to deprecate-and-drop > big-endian support (probably starting with the deprecation for > 12.0, rather than pushing it into 11.2), since the kernel just > did that in 7.4. Tangent to this, it makes sense to deprecate quickly enough on QEMU side when a host-related project we use deprecates / removes it; when this is guest related I don't see the urge, in particular when the maintenance is almost zero cost. For the particular aarch64_be I agree what we lacks is coverage testing; but for other features I'd prefer we keep them as long as there is interest within QEMU users, independent of external projects change like the Linux kernel.
On Mon, 16 Nov 2026 at 17:05, Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> wrote: > On 16/11/26 17:53, Peter Maydell wrote: > > For aarch64 in particular I would prefer to deprecate-and-drop > > big-endian support (probably starting with the deprecation for > > 12.0, rather than pushing it into 11.2), since the kernel just > > did that in 7.4. > Tangent to this, it makes sense to deprecate quickly enough on > QEMU side when a host-related project we use deprecates / removes > it; when this is guest related I don't see the urge, in particular > when the maintenance is almost zero cost. For the particular > aarch64_be I agree what we lacks is coverage testing; but for > other features I'd prefer we keep them as long as there is interest > within QEMU users, independent of external projects change like > the Linux kernel. I'm not in a huge hurry about deprecating aarch64_be (as you say it's not a huge cost to us to carry it, though it is a small extra amount of compilation time in CI). It's more that I would favour dropping it over doing any future work or refactoring on it. In terms of QEMU user interest, I really don't think we actually have much of it (though of course it's difficult to tell since users don't tell us about stuff that works for them). About the only thing I can remember is https://gitlab.com/qemu-project/qemu/-/work_items/3958 which is a report from one user that it doesn't work for them at all! (My suspicion is that this is because their userspace is built with some custom local kernel / libc changes which aren't upstream.) As Richard says, BE AArch64 on Linux has pretty much never been something with much serious interest, and the config has been marked BROKEN in Linux for some time prior to removal. I don't think there is a big stock of BE userspace binaries out there that people want to try to run. thanks -- PMM
On 11/16/26 09:05, Philippe Mathieu-Daudé wrote: > Tangent to this, it makes sense to deprecate quickly enough on > QEMU side when a host-related project we use deprecates / removes > it; when this is guest related I don't see the urge, in particular > when the maintenance is almost zero cost. For the particular > aarch64_be I agree what we lacks is coverage testing; but for > other features I'd prefer we keep them as long as there is interest > within QEMU users, independent of external projects change like > the Linux kernel. There have been a couple of attempts at aarch64_be, but *never* any upstream traction. qemu-linux-user is about emulating Linux -- you can't divorce these two. In my opinion, those that want to work on aarch64_be can work in system mode, where the endian switching bits work as required by the architecture. r~
On 16/11/26 23:28, Richard Henderson wrote: > On 11/16/26 09:05, Philippe Mathieu-Daudé wrote: >> Tangent to this, it makes sense to deprecate quickly enough on >> QEMU side when a host-related project we use deprecates / removes >> it; when this is guest related I don't see the urge, in particular >> when the maintenance is almost zero cost. For the particular >> aarch64_be I agree what we lacks is coverage testing; but for >> other features I'd prefer we keep them as long as there is interest >> within QEMU users, independent of external projects change like >> the Linux kernel. > > There have been a couple of attempts at aarch64_be, but *never* any > upstream traction. qemu-linux-user is about emulating Linux -- you > can't divorce these two. > > In my opinion, those that want to work on aarch64_be can work in system > mode, where the endian switching bits work as required by the architecture. OK I'm happy dropping Aarch64_be. Patches 7-10 are still common to all targets and worth review comments :)
On 11/16/2026 3:00 PM, Philippe Mathieu-Daudé wrote: > On 16/11/26 23:28, Richard Henderson wrote: >> On 11/16/26 09:05, Philippe Mathieu-Daudé wrote: >>> Tangent to this, it makes sense to deprecate quickly enough on >>> QEMU side when a host-related project we use deprecates / removes >>> it; when this is guest related I don't see the urge, in particular >>> when the maintenance is almost zero cost. For the particular >>> aarch64_be I agree what we lacks is coverage testing; but for >>> other features I'd prefer we keep them as long as there is interest >>> within QEMU users, independent of external projects change like >>> the Linux kernel. >> >> There have been a couple of attempts at aarch64_be, but *never* any >> upstream traction. qemu-linux-user is about emulating Linux -- you >> can't divorce these two. >> >> In my opinion, those that want to work on aarch64_be can work in >> system mode, where the endian switching bits work as required by the >> architecture. > > OK I'm happy dropping Aarch64_be. Patches 7-10 are still common to all > targets and worth review comments :) Beyond aarch64, what about qemu-arm and qemu-armeb? If we all agree to try to unify that, I would be happy to help review the series. Regards, Pierrick
© 2016 - 2026 Red Hat, Inc.