qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>,
	Anton Johansson <anjo@rev.ng>
Subject: [RFC-PATCH-for-11.0 v3 08/21] target/mips: Replace cpu_ld{uw, l}_code() by explicit endianness variants
Date: Fri, 21 Nov 2025 14:44:50 +0100	[thread overview]
Message-ID: <20251121134503.30914-9-philmd@linaro.org> (raw)
In-Reply-To: <20251121134503.30914-1-philmd@linaro.org>

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/mips/tcg/system/tlb_helper.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/target/mips/tcg/system/tlb_helper.c b/target/mips/tcg/system/tlb_helper.c
index 566924b079e..415c214c5b4 100644
--- a/target/mips/tcg/system/tlb_helper.c
+++ b/target/mips/tcg/system/tlb_helper.c
@@ -997,18 +997,30 @@ static void set_hflags_for_handler(CPUMIPSState *env)
     }
 }
 
+static uint16_t lduw_code(CPUMIPSState *env, target_ulong addr)
+{
+    return mips_env_is_bigendian(env) ? cpu_lduw_be_code(env, addr)
+                                      : cpu_lduw_le_code(env, addr);
+}
+
+static uint32_t ldl_code(CPUMIPSState *env, target_ulong addr)
+{
+    return mips_env_is_bigendian(env) ? cpu_ldl_be_code(env, addr)
+                                      : cpu_ldl_le_code(env, addr);
+}
+
 static inline void set_badinstr_registers(CPUMIPSState *env)
 {
     if (env->insn_flags & ISA_NANOMIPS32) {
         if (env->CP0_Config3 & (1 << CP0C3_BI)) {
-            uint32_t instr = (cpu_lduw_code(env, env->active_tc.PC)) << 16;
+            uint32_t instr = (lduw_code(env, env->active_tc.PC)) << 16;
             if ((instr & 0x10000000) == 0) {
-                instr |= cpu_lduw_code(env, env->active_tc.PC + 2);
+                instr |= lduw_code(env, env->active_tc.PC + 2);
             }
             env->CP0_BadInstr = instr;
 
             if ((instr & 0xFC000000) == 0x60000000) {
-                instr = cpu_lduw_code(env, env->active_tc.PC + 4) << 16;
+                instr = lduw_code(env, env->active_tc.PC + 4) << 16;
                 env->CP0_BadInstrX = instr;
             }
         }
@@ -1020,11 +1032,11 @@ static inline void set_badinstr_registers(CPUMIPSState *env)
         return;
     }
     if (env->CP0_Config3 & (1 << CP0C3_BI)) {
-        env->CP0_BadInstr = cpu_ldl_code(env, env->active_tc.PC);
+        env->CP0_BadInstr = ldl_code(env, env->active_tc.PC);
     }
     if ((env->CP0_Config3 & (1 << CP0C3_BP)) &&
         (env->hflags & MIPS_HFLAG_BMASK)) {
-        env->CP0_BadInstrP = cpu_ldl_code(env, env->active_tc.PC - 4);
+        env->CP0_BadInstrP = ldl_code(env, env->active_tc.PC - 4);
     }
 }
 
-- 
2.51.0



  parent reply	other threads:[~2025-11-22  4:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21 13:44 [RFC-PATCH-for-11.0 v3 00/21] accel/tcg: Remove most MO_TE uses in cpu_ld/st_code/data() Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 01/21] accel/tcg: Add endianness variants of cpu_ld{uw, l, q}_code() Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 02/21] target/alpha: Use little-endian variant of cpu_ldl_code() Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 03/21] target/loongarch: " Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 04/21] target/sparc: Use big-endian " Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 05/21] target/s390x: Use big-endian variant of cpu_ld{uw, l}_code() Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 06/21] target/riscv: Use little-endian variant of cpu_ld{l, q}_code() Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 07/21] target/ppc: Replace cpu_ldl_code() by explicit endianness variants Philippe Mathieu-Daudé
2025-11-21 13:44 ` Philippe Mathieu-Daudé [this message]
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 09/21] accel/tcg: Remove non-explicit endian cpu_ld*_code() helpers Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 10/21] target/hexagon: Use little-endian variant of cpu_ld/st_data*() Philippe Mathieu-Daudé
2025-11-22  2:26   ` Brian Cain
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 11/21] target/tricore: " Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 12/21] target/rx: " Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 13/21] target/m68k: " Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 14/21] target/s390x: " Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 15/21] target/sparc: " Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 16/21] target/i386: " Philippe Mathieu-Daudé
2025-11-21 13:44 ` [RFC-PATCH-for-11.0 v3 17/21] target/hppa: " Philippe Mathieu-Daudé
2025-11-21 13:45 ` [RFC-PATCH-for-11.0 v3 18/21] target/riscv: Use little-endian variant of cpu_ld/st_data*() for vector Philippe Mathieu-Daudé
2025-11-21 13:45 ` [RFC-PATCH-for-11.0 v3 19/21] target/sh4: Replace cpu_stl_data() by explicit endianness variants Philippe Mathieu-Daudé
2025-11-21 13:45 ` [RFC-PATCH-for-11.0 v3 20/21] target/mips: Use big-endian variant of cpu_ld/st_data*() for MSA Philippe Mathieu-Daudé
2025-11-21 13:45 ` [RFC-PATCH-for-11.0 v3 21/21] accel/tcg: Remove non-explicit endian cpu_ld/st*_data*() helpers Philippe Mathieu-Daudé

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=20251121134503.30914-9-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=anjo@rev.ng \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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).