Use target_big_endian() for BE8 code-order handling. Preserve the behavior of the existing fixed-endian targets.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- target/arm/cpu.h | 10 ++++++++-- linux-user/arm/cpu_loop.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index b2f393f50184..7fb1726e8744 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -22,6 +22,7 @@ #include "kvm-consts.h" #include "qemu/cpu-float.h" +#include "qemu/target-info.h" #include "hw/core/registerfields.h" #include "cpu-qom.h" #include "exec/cpu-common.h" @@ -2660,11 +2661,16 @@ static inline int sme_vq(CPUARMState *env) static inline bool bswap_code(bool sctlr_b) { #ifdef CONFIG_USER_ONLY - /* BE8 (SCTLR.B = 0, TARGET_BIG_ENDIAN = 1) is mixed endian. - * The invalid combination SCTLR.B=1/CPSR.E=1/TARGET_BIG_ENDIAN=0 + /* + * BE8 (SCTLR.B = 0, big-endian target) is mixed endian. + * The invalid combination SCTLR.B=1/CPSR.E=1/little-endian target * would also end up as a mixed-endian mode with BE code, LE data. */ +#ifdef TARGET_RUNTIME_ENDIAN + return target_big_endian() ^ sctlr_b; +#else return TARGET_BIG_ENDIAN ^ sctlr_b; +#endif #else /* All code access in ARM is little endian, and there are no loaders * doing swaps that need to be reversed diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 262ab5cc416d..6d19a9a8a070 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -505,7 +505,7 @@ void init_main_thread(CPUState *cs, struct image_info *info) } } - if (TARGET_BIG_ENDIAN) { + if (target_big_endian()) { /* Enable BE8. */ if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4 && (info->elf_flags & EF_ARM_BE8)) { -- 2.55.0
