qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alistair Francis" <alistair@alistair23.me>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>, "Hao Wu" <wuhaotsh@google.com>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Joel Stanley" <joel@jms.id.au>,
	qemu-arm@nongnu.org,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Steven Lee" <steven_lee@aspeedtech.com>,
	"Tyrone Ting" <kfting@nuvoton.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Jamin Lin" <jamin_lin@aspeedtech.com>,
	"Troy Lee" <leetroy@gmail.com>, "Anton Johansson" <anjo@rev.ng>
Subject: [PATCH 1/3] target/arm: Expose arm_cpu_code_is_big_endian() prototype in 'cpu.h'
Date: Tue,  1 Oct 2024 00:12:02 +0200	[thread overview]
Message-ID: <20240930221205.59101-2-philmd@linaro.org> (raw)
In-Reply-To: <20240930221205.59101-1-philmd@linaro.org>

Expose arm_cpu_code_is_big_endian() so it can be used by hw/ code.
Use it in few places where it was open coded.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/cpu.h              | 7 +++++++
 linux-user/aarch64/cpu_loop.c | 4 ++--
 linux-user/arm/cpu_loop.c     | 4 ++--
 target/arm/cpu.c              | 6 ++----
 4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index f065756c5c..da8f2b2ec8 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -3057,6 +3057,13 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env)
     }
 }
 
+static inline bool bswap_code(bool sctlr_b);
+
+static inline bool arm_cpu_code_is_big_endian(CPUARMState *env)
+{
+    return bswap_code(arm_sctlr_b(env));
+}
+
 #include "exec/cpu-all.h"
 
 /*
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
index 71cdc8be50..68ff3c14f8 100644
--- a/linux-user/aarch64/cpu_loop.c
+++ b/linux-user/aarch64/cpu_loop.c
@@ -29,7 +29,7 @@
 
 #define get_user_code_u32(x, gaddr, env)                \
     ({ abi_long __r = get_user_u32((x), (gaddr));       \
-        if (!__r && bswap_code(arm_sctlr_b(env))) {     \
+        if (!__r && arm_cpu_code_is_big_endian(env)) {  \
             (x) = bswap32(x);                           \
         }                                               \
         __r;                                            \
@@ -37,7 +37,7 @@
 
 #define get_user_code_u16(x, gaddr, env)                \
     ({ abi_long __r = get_user_u16((x), (gaddr));       \
-        if (!__r && bswap_code(arm_sctlr_b(env))) {     \
+        if (!__r && arm_cpu_code_is_big_endian(env)) {  \
             (x) = bswap16(x);                           \
         }                                               \
         __r;                                            \
diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
index ec665862d9..0cc056be31 100644
--- a/linux-user/arm/cpu_loop.c
+++ b/linux-user/arm/cpu_loop.c
@@ -29,7 +29,7 @@
 
 #define get_user_code_u32(x, gaddr, env)                \
     ({ abi_long __r = get_user_u32((x), (gaddr));       \
-        if (!__r && bswap_code(arm_sctlr_b(env))) {     \
+        if (!__r && arm_cpu_code_is_big_endian(env)) {  \
             (x) = bswap32(x);                           \
         }                                               \
         __r;                                            \
@@ -37,7 +37,7 @@
 
 #define get_user_code_u16(x, gaddr, env)                \
     ({ abi_long __r = get_user_u16((x), (gaddr));       \
-        if (!__r && bswap_code(arm_sctlr_b(env))) {     \
+        if (!__r && arm_cpu_code_is_big_endian(env)) {  \
             (x) = bswap16(x);                           \
         }                                               \
         __r;                                            \
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 19191c2391..f3198ee2f2 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1167,7 +1167,6 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info)
 {
     ARMCPU *ac = ARM_CPU(cpu);
     CPUARMState *env = &ac->env;
-    bool sctlr_b;
 
     if (is_a64(env)) {
         info->cap_arch = CS_ARCH_ARM64;
@@ -1194,8 +1193,7 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info)
         info->cap_mode = cap_mode;
     }
 
-    sctlr_b = arm_sctlr_b(env);
-    if (bswap_code(sctlr_b)) {
+    if (arm_cpu_code_is_big_endian(env)) {
 #if TARGET_BIG_ENDIAN
         info->endian = BFD_ENDIAN_LITTLE;
 #else
@@ -1204,7 +1202,7 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info)
     }
     info->flags &= ~INSN_ARM_BE32;
 #ifndef CONFIG_USER_ONLY
-    if (sctlr_b) {
+    if (arm_sctlr_b(env)) {
         info->flags |= INSN_ARM_BE32;
     }
 #endif
-- 
2.45.2



  reply	other threads:[~2024-09-30 22:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 22:12 [PATCH 0/3] hw/arm: Replace tswap32() by stl_endian_p() Philippe Mathieu-Daudé
2024-09-30 22:12 ` Philippe Mathieu-Daudé [this message]
2024-09-30 22:12 ` [PATCH 2/3] hw/arm: Have arm_write_bootloader() take a ARMCPU argument Philippe Mathieu-Daudé
2024-09-30 22:12 ` [PATCH 3/3] hw/arm: Replace tswap32() calls by target agnostic stl_endian_p() Philippe Mathieu-Daudé
2024-10-01  9:35   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240930221205.59101-2-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=alistair@alistair23.me \
    --cc=andrew@codeconstruct.com.au \
    --cc=anjo@rev.ng \
    --cc=clg@kaod.org \
    --cc=edgar.iglesias@gmail.com \
    --cc=i.mitsyanko@gmail.com \
    --cc=jamin_lin@aspeedtech.com \
    --cc=joel@jms.id.au \
    --cc=kfting@nuvoton.com \
    --cc=laurent@vivier.eu \
    --cc=leetroy@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=steven_lee@aspeedtech.com \
    --cc=thuth@redhat.com \
    --cc=wuhaotsh@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).