* [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code()
@ 2025-11-20 17:59 Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 1/5] accel/tcg: Add endianness variants of " Philippe Mathieu-Daudé
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-20 17:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
Hi Richard,
Quick attempt to remove MO_TE uses for fixed-endianness targets.
For the other targets I started to propagate MemOp in the call
chain, but since IIUC it is constant, I wonder if it isn't simpler
to have a CPUClass::code_endian_mo field, set once with a
target_big_endian() call. I can post another RFC to show, WDYT?
Regards,
Phil.
Philippe Mathieu-Daudé (5):
accel/tcg: Add endianness variants of cpu_ld{uw,l,q}_code()
target/alpha: Use little-endian variant of cpu_ldl_code()
target/loongarch: Use little-endian variant of cpu_ldl_code()
target/sparc: Use big-endian variant of cpu_ldl_code()
target/s390x: Use big-endian variant of cpu_ld{uw,l}_code()
include/accel/tcg/cpu-ldst.h | 43 +++++++++++++++++++++++++++++-----
target/alpha/mem_helper.c | 2 +-
target/loongarch/tcg/tcg_cpu.c | 2 +-
target/s390x/tcg/mem_helper.c | 6 ++---
target/sparc/int32_helper.c | 2 +-
5 files changed, 43 insertions(+), 12 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC-PATCH-for-11.0 1/5] accel/tcg: Add endianness variants of cpu_ld{uw, l, q}_code()
2025-11-20 17:59 [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
@ 2025-11-20 17:59 ` Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 2/5] target/alpha: Use little-endian variant of cpu_ldl_code() Philippe Mathieu-Daudé
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-20 17:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
Allow target with fixed-endianness to not use the MO_TE definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/accel/tcg/cpu-ldst.h | 43 +++++++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 6 deletions(-)
diff --git a/include/accel/tcg/cpu-ldst.h b/include/accel/tcg/cpu-ldst.h
index 0de7f5eaa6b..e4ec4e7d367 100644
--- a/include/accel/tcg/cpu-ldst.h
+++ b/include/accel/tcg/cpu-ldst.h
@@ -481,25 +481,56 @@ static inline uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr)
return cpu_ldb_code_mmu(env, addr, oi, 0);
}
-static inline uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr)
+static inline uint32_t cpu_lduw_le_code(CPUArchState *env, abi_ptr addr)
{
CPUState *cs = env_cpu(env);
- MemOpIdx oi = make_memop_idx(MO_TEUW, cpu_mmu_index(cs, true));
+ MemOpIdx oi = make_memop_idx(MO_LEUW, cpu_mmu_index(cs, true));
return cpu_ldw_code_mmu(env, addr, oi, 0);
}
-static inline uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr)
+static inline uint32_t cpu_ldl_le_code(CPUArchState *env, abi_ptr addr)
{
CPUState *cs = env_cpu(env);
- MemOpIdx oi = make_memop_idx(MO_TEUL, cpu_mmu_index(cs, true));
+ MemOpIdx oi = make_memop_idx(MO_LEUL, cpu_mmu_index(cs, true));
return cpu_ldl_code_mmu(env, addr, oi, 0);
}
-static inline uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr)
+static inline uint64_t cpu_ldq_le_code(CPUArchState *env, abi_ptr addr)
{
CPUState *cs = env_cpu(env);
- MemOpIdx oi = make_memop_idx(MO_TEUQ, cpu_mmu_index(cs, true));
+ MemOpIdx oi = make_memop_idx(MO_LEUQ, cpu_mmu_index(cs, true));
return cpu_ldq_code_mmu(env, addr, oi, 0);
}
+static inline uint32_t cpu_lduw_be_code(CPUArchState *env, abi_ptr addr)
+{
+ CPUState *cs = env_cpu(env);
+ MemOpIdx oi = make_memop_idx(MO_BEUW, cpu_mmu_index(cs, true));
+ return cpu_ldw_code_mmu(env, addr, oi, 0);
+}
+
+static inline uint32_t cpu_ldl_be_code(CPUArchState *env, abi_ptr addr)
+{
+ CPUState *cs = env_cpu(env);
+ MemOpIdx oi = make_memop_idx(MO_BEUL, cpu_mmu_index(cs, true));
+ return cpu_ldl_code_mmu(env, addr, oi, 0);
+}
+
+static inline uint64_t cpu_ldq_be_code(CPUArchState *env, abi_ptr addr)
+{
+ CPUState *cs = env_cpu(env);
+ MemOpIdx oi = make_memop_idx(MO_BEUQ, cpu_mmu_index(cs, true));
+ return cpu_ldq_code_mmu(env, addr, oi, 0);
+}
+
+#if TARGET_BIG_ENDIAN
+# define cpu_lduw_code cpu_lduw_be_code
+# define cpu_ldl_code cpu_ldl_be_code
+# define cpu_ldq_code cpu_ldq_be_code
+#else
+# define cpu_lduw_code cpu_lduw_le_code
+# define cpu_ldl_code cpu_ldl_le_code
+# define cpu_ldq_code cpu_ldq_le_code
+#endif
+
#endif /* ACCEL_TCG_CPU_LDST_H */
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC-PATCH-for-11.0 2/5] target/alpha: Use little-endian variant of cpu_ldl_code()
2025-11-20 17:59 [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 1/5] accel/tcg: Add endianness variants of " Philippe Mathieu-Daudé
@ 2025-11-20 17:59 ` Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 3/5] target/loongarch: " Philippe Mathieu-Daudé
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-20 17:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
Alpha is always little-endian.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/alpha/mem_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/alpha/mem_helper.c b/target/alpha/mem_helper.c
index 2113fe33ae2..d04d086b59d 100644
--- a/target/alpha/mem_helper.c
+++ b/target/alpha/mem_helper.c
@@ -30,7 +30,7 @@ static void do_unaligned_access(CPUAlphaState *env, vaddr addr, uintptr_t retadd
cpu_restore_state(env_cpu(env), retaddr);
pc = env->pc;
- insn = cpu_ldl_code(env, pc);
+ insn = cpu_ldl_le_code(env, pc);
env->trap_arg0 = addr;
env->trap_arg1 = insn >> 26; /* opcode */
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC-PATCH-for-11.0 3/5] target/loongarch: Use little-endian variant of cpu_ldl_code()
2025-11-20 17:59 [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 1/5] accel/tcg: Add endianness variants of " Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 2/5] target/alpha: Use little-endian variant of cpu_ldl_code() Philippe Mathieu-Daudé
@ 2025-11-20 17:59 ` Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 4/5] target/sparc: Use big-endian " Philippe Mathieu-Daudé
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-20 17:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
LoongArch is always little-endian.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/loongarch/tcg/tcg_cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/loongarch/tcg/tcg_cpu.c b/target/loongarch/tcg/tcg_cpu.c
index 9d077c56d9d..3f4b5f9258e 100644
--- a/target/loongarch/tcg/tcg_cpu.c
+++ b/target/loongarch/tcg/tcg_cpu.c
@@ -140,7 +140,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs)
}
if (update_badinstr) {
- env->CSR_BADI = cpu_ldl_code(env, env->pc);
+ env->CSR_BADI = cpu_ldl_le_code(env, env->pc);
}
/* Save PLV and IE */
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC-PATCH-for-11.0 4/5] target/sparc: Use big-endian variant of cpu_ldl_code()
2025-11-20 17:59 [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 3/5] target/loongarch: " Philippe Mathieu-Daudé
@ 2025-11-20 17:59 ` Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 5/5] target/s390x: Use big-endian variant of cpu_ld{uw, l}_code() Philippe Mathieu-Daudé
2025-11-20 20:20 ` [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-20 17:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
SPARC is always big-endian.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/sparc/int32_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c
index b29f693a6bf..a777d17a01c 100644
--- a/target/sparc/int32_helper.c
+++ b/target/sparc/int32_helper.c
@@ -151,7 +151,7 @@ void sparc_cpu_do_interrupt(CPUState *cs)
if (!env->fsr_qne) {
env->fsr_qne = FSR_QNE;
env->fq.s.addr = env->pc;
- env->fq.s.insn = cpu_ldl_code(env, env->pc);
+ env->fq.s.insn = cpu_ldl_be_code(env, env->pc);
}
env->pc = env->npc;
env->npc = env->npc + 4;
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC-PATCH-for-11.0 5/5] target/s390x: Use big-endian variant of cpu_ld{uw, l}_code()
2025-11-20 17:59 [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 4/5] target/sparc: Use big-endian " Philippe Mathieu-Daudé
@ 2025-11-20 17:59 ` Philippe Mathieu-Daudé
2025-11-20 20:20 ` [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-20 17:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
S390x is always big-endian.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/s390x/tcg/mem_helper.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index 24675fc818d..84d901c2008 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -2437,7 +2437,7 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)
tcg_s390_program_interrupt(env, PGM_SPECIFICATION, GETPC());
}
- insn = cpu_lduw_code(env, addr);
+ insn = cpu_lduw_be_code(env, addr);
opc = insn >> 8;
/* Or in the contents of R1[56:63]. */
@@ -2449,10 +2449,10 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)
case 2:
break;
case 4:
- insn |= (uint64_t)cpu_lduw_code(env, addr + 2) << 32;
+ insn |= (uint64_t)cpu_lduw_be_code(env, addr + 2) << 32;
break;
case 6:
- insn |= (uint64_t)(uint32_t)cpu_ldl_code(env, addr + 2) << 16;
+ insn |= (uint64_t)(uint32_t)cpu_ldl_be_code(env, addr + 2) << 16;
break;
default:
g_assert_not_reached();
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code()
2025-11-20 17:59 [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 5/5] target/s390x: Use big-endian variant of cpu_ld{uw, l}_code() Philippe Mathieu-Daudé
@ 2025-11-20 20:20 ` Philippe Mathieu-Daudé
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-20 20:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
[-- Attachment #1: Type: text/plain, Size: 493 bytes --]
On Thu, 20 Nov 2025 at 18:59, Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:
> Hi Richard,
>
> Quick attempt to remove MO_TE uses for fixed-endianness targets.
>
> For the other targets I started to propagate MemOp in the call
> chain, but since IIUC it is constant, I wonder if it isn't simpler
> to have a CPUClass::code_endian_mo field, set once with a
> target_big_endian() call. I can post another RFC to show, WDYT?
>
Not needed, figured a simpler way, posted as v2.
[-- Attachment #2: Type: text/html, Size: 803 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-11-20 20:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20 17:59 [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 1/5] accel/tcg: Add endianness variants of " Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 2/5] target/alpha: Use little-endian variant of cpu_ldl_code() Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 3/5] target/loongarch: " Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 4/5] target/sparc: Use big-endian " Philippe Mathieu-Daudé
2025-11-20 17:59 ` [RFC-PATCH-for-11.0 5/5] target/s390x: Use big-endian variant of cpu_ld{uw, l}_code() Philippe Mathieu-Daudé
2025-11-20 20:20 ` [RFC-PATCH-for-11.0 0/5] accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
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).