target/arm/cpu.h | 16 ---------------- linux-user/arm/cpu_loop.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 16 deletions(-)
bswap_code() is now used once in get_user_code_u32(),
inline it and simplify removing dead system code.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/cpu.h | 16 ----------------
linux-user/arm/cpu_loop.c | 10 ++++++++++
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 657ff4ab20b..917e9919e8c 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2568,22 +2568,6 @@ static inline int sme_vq(CPUARMState *env)
return EX_TBFLAG_A64(env->hflags, SVL) + 1;
}
-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
- * would also end up as a mixed-endian mode with BE code, LE data.
- */
- return TARGET_BIG_ENDIAN ^ sctlr_b;
-#else
- /* All code access in ARM is little endian, and there are no loaders
- * doing swaps that need to be reversed
- */
- return 0;
-#endif
-}
-
enum {
QEMU_PSCI_CONDUIT_DISABLED = 0,
QEMU_PSCI_CONDUIT_SMC = 1,
diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
index 19874f4c727..24a66b52cee 100644
--- a/linux-user/arm/cpu_loop.c
+++ b/linux-user/arm/cpu_loop.c
@@ -29,6 +29,16 @@
#include "user/page-protection.h"
#include "target/arm/syndrome.h"
+static inline bool bswap_code(bool sctlr_b)
+{
+ /*
+ * BE8 (SCTLR.B = 0, TARGET_BIG_ENDIAN = 1) is mixed endian.
+ * The invalid combination SCTLR.B=1/CPSR.E=1/TARGET_BIG_ENDIAN=0
+ * would also end up as a mixed-endian mode with BE code, LE data.
+ */
+ return TARGET_BIG_ENDIAN ^ sctlr_b;
+}
+
#define get_user_code_u32(x, gaddr, env) \
({ abi_long __r = get_user_u32((x), (gaddr)); \
if (!__r && bswap_code(arm_sctlr_b(env))) { \
--
2.53.0
On 4/7/26 2:23 PM, Philippe Mathieu-Daudé wrote:
> bswap_code() is now used once in get_user_code_u32(),
> inline it and simplify removing dead system code.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/cpu.h | 16 ----------------
> linux-user/arm/cpu_loop.c | 10 ++++++++++
> 2 files changed, 10 insertions(+), 16 deletions(-)
>
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 657ff4ab20b..917e9919e8c 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -2568,22 +2568,6 @@ static inline int sme_vq(CPUARMState *env)
> return EX_TBFLAG_A64(env->hflags, SVL) + 1;
> }
>
> -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
> - * would also end up as a mixed-endian mode with BE code, LE data.
> - */
> - return TARGET_BIG_ENDIAN ^ sctlr_b;
> -#else
> - /* All code access in ARM is little endian, and there are no loaders
> - * doing swaps that need to be reversed
> - */
> - return 0;
> -#endif
> -}
> -
> enum {
> QEMU_PSCI_CONDUIT_DISABLED = 0,
> QEMU_PSCI_CONDUIT_SMC = 1,
> diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
> index 19874f4c727..24a66b52cee 100644
> --- a/linux-user/arm/cpu_loop.c
> +++ b/linux-user/arm/cpu_loop.c
> @@ -29,6 +29,16 @@
> #include "user/page-protection.h"
> #include "target/arm/syndrome.h"
>
> +static inline bool bswap_code(bool sctlr_b)
> +{
> + /*
> + * BE8 (SCTLR.B = 0, TARGET_BIG_ENDIAN = 1) is mixed endian.
> + * The invalid combination SCTLR.B=1/CPSR.E=1/TARGET_BIG_ENDIAN=0
> + * would also end up as a mixed-endian mode with BE code, LE data.
> + */
> + return TARGET_BIG_ENDIAN ^ sctlr_b;
> +}
> +
> #define get_user_code_u32(x, gaddr, env) \
> ({ abi_long __r = get_user_u32((x), (gaddr)); \
> if (!__r && bswap_code(arm_sctlr_b(env))) { \
I don't think so, Richard wants to remove bswap_code completely and
get_user_code_u32 is last usage of it. I'm waiting for his patch to
integrate it in series.
© 2016 - 2026 Red Hat, Inc.