Skip to contentSkip to conversation

Mist target patches for 2026-11-24

GIT PULL Applied Philippe Mathieu-Daudé 2 participants 20 messages Nov 24 – Nov 25

lore
Share & tools
lore
#0 lore raw

The following changes since commit 6bf90d4fc5027567cb704d7888f5ec792b4ed75a:

Merge tag 'pull-target-arm-20261124' of https://gitlab.com/pm215/qemu into staging (2026-11-24 07:09:41 -0800)

are available in the Git repository at:

https://github.com/philmd/qemu.git tags/target-misc-20261124

for you to fetch changes up to fd25fe89996688623717b485654e26a0d7f46c62:

target/mips: Do not sign-extend partial LWR results on Octeon (2026-11-25 00:22:48 +0100)

----------------------------------------------------------------
Misc fixes for 11.2

- TCG flags (M68k, PPC) & icount (ARM)
- MIPS opcodes and exceptions
----------------------------------------------------------------

Philippe Mathieu-Daudé (18):
accel/tcg: Check current CPU in icount interrupt handler Revert "target/arm: don't pass env to the sev helper" target/arm: Kick other vCPUs on SEV under TCG round-robin target/m68k: Fix TB_FLAGS_TRACE* definitions
target/ppc: Test CF_NO_GOTO_PTR in cflags, not in TB flags target/mips: Check for MIPS II when decoding BLEZL/BGTZL target/mips: Require rt == 0 when decoding BLEZL/BGTZL target/mips: Require the MT module for MFTR/MTTR target/mips: Enforce alignment and 64-bit CPU for the DSP LX loads target/mips: Fix reset into microMIPS mode when Config3.ISA is 3 target/mips: Fix microMIPS BC2NEZC POOL32I minor opcode target/mips: Fix microMIPS CACHE offset used for ITC tag access target/mips: Fix nanoMIPS BPOSGE32C branch offset sign extension target/mips: Pass the right instruction size for nanoMIPS RESTORE.JRC target/mips: Fix nanoMIPS BC1EQZC/BC1NEZC always raising RI target/mips: Pass the nanoMIPS BREAK code to
generate_exception_break()
target/mips: Decode 6-bit bit number of nanoMIPS BBEQZC/BBNEZC target/mips: Do not sign-extend partial LWR results on Octeon

 target/arm/tcg/helper-defs.h              |  2 +-
 target/m68k/cpu.h                         |  4 +--
 accel/tcg/tcg-accel-ops-icount.c          |  2 +-
 target/arm/tcg/op_helper.c                |  6 ++--
 target/arm/tcg/translate-a64.c            |  2 +-
 target/arm/tcg/translate.c                |  2 +-
 target/mips/cpu.c                         |  2 +-
 target/mips/tcg/translate.c               | 35 ++++++++++++++++++-----
 target/ppc/translate.c                    |  4 +--
 target/mips/tcg/micromips_translate.c.inc |  4 +--
 target/mips/tcg/nanomips_translate.c.inc  | 26 +++++++----------
 11 files changed, 53 insertions(+), 36 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

[PULL 01/18] accel/tcg: Check current CPU in icount interrupt handler

Under round-robin TCG, all vCPUs share one host thread, so qemu_cpu_is_self() is true for every vCPU. The icount interrupt sanity check can therefore abort when an interrupt targets a different vCPU sharing the current thread. Compare current_cpu with the target CPU instead.

Message-ID: <[email protected]>

---
 accel/tcg/tcg-accel-ops-icount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
accel/tcg/tcg-accel-ops-icount.c +1 -1
index d0f7b410fab3..0313a4d128c5 100644
@@ -152,7 +152,7 @@ void icount_handle_interrupt(CPUState *cpu, int mask)
     int old_mask = cpu->interrupt_request;
 
     tcg_handle_interrupt(cpu, mask);
-    if (qemu_cpu_is_self(cpu) &&
+    if (current_cpu == cpu &&
         !cpu->neg.can_do_io
         && (mask & ~old_mask) != 0) {
         cpu_abort(cpu, "Raised interrupt while not in I/O function");
Signature · 1 line
2.55.0
#2 lore raw

[PULL 02/18] Revert "target/arm: don't pass env to the sev helper"

In reply to Philippe Mathieu-Daudé

SEV needs the issuing CPU to distinguish it from other vCPUs sharing its host thread under round-robin TCG. Restore the explicit environment argument before fixing that comparison, avoiding a dependency on the global current_cpu pointer in the helper.

This reverts commit c5ec1bfad10346aefb8d7a18cea5118f2056f8a6.

Message-ID: <[email protected]>

---
 target/arm/tcg/helper-defs.h   | 2 +-
 target/arm/tcg/op_helper.c     | 2 +-
 target/arm/tcg/translate-a64.c | 2 +-
 target/arm/tcg/translate.c     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
target/arm/tcg/helper-defs.h +1 -1
index 4f9736e6796d..269ac5150657 100644
@@ -60,7 +60,7 @@ DEF_HELPER_1(yield, void, env)
 DEF_HELPER_1(pre_hvc, void, env)
 DEF_HELPER_2(pre_smc, void, env, i32)
 DEF_HELPER_1(vesb, void, env)
-DEF_HELPER_0(sev, void)
+DEF_HELPER_1(sev, void, env)
 
 DEF_HELPER_3(cpsr_write, void, env, i32, i32)
 DEF_HELPER_2(cpsr_write_eret, void, env, i32)
target/arm/tcg/op_helper.c +1 -1
index b6113096b53b..a862b9eb02da 100644
@@ -468,7 +468,7 @@ void HELPER(wfit)(CPUARMState *env, uint32_t rd)
 #endif
 }
 
-void HELPER(sev)(void)
+void HELPER(sev)(CPUARMState *env)
 {
     CPUState *cs;
 
target/arm/tcg/translate-a64.c +1 -1
index 49472f7d9757..14888202bada 100644
@@ -2148,7 +2148,7 @@ static bool trans_SEV(DisasContext *s, arg_SEV *a)
      * SEV is a NOP for user-mode emulation.
      */
 #ifndef CONFIG_USER_ONLY
-    gen_helper_sev();
+    gen_helper_sev(tcg_env);
 #endif
     return true;
 }
target/arm/tcg/translate.c +1 -1
index 442c34ce84fc..9d80294c9bb2 100644
@@ -3282,7 +3282,7 @@ static bool trans_SEV(DisasContext *s, arg_SEV *a)
 #ifndef CONFIG_USER_ONLY
     if (arm_dc_feature(s, ARM_FEATURE_M) ||
         arm_dc_feature(s, ARM_FEATURE_V6K)) {
-        gen_helper_sev();
+        gen_helper_sev(tcg_env);
     }
 #endif
     return true;
Signature · 1 line
2.55.0
#3 lore raw

[PULL 03/18] target/arm: Kick other vCPUs on SEV under TCG round-robin

In reply to Philippe Mathieu-Daudé

In round-robin (single-thread) TCG, all vCPUs share one host thread, so qemu_cpu_is_self() is true for every vCPU.

The SEV helper used it to skip the kick of the issuing vCPU, and so skipped it for every other vCPU too: a vCPU sleeping in WFE is only woken when the RR kick timer fires.

Compare against the issuing vCPU instead.

Fixes d238858bff60 ("target/arm: Implement WFE, SEV and SEVONPEND")

Message-ID: <[email protected]>

---
 target/arm/tcg/op_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/tcg/op_helper.c +2 -2
index a862b9eb02da..c2fdad7411db 100644
@@ -470,14 +470,14 @@ void HELPER(wfit)(CPUARMState *env, uint32_t rd)
 
 void HELPER(sev)(CPUARMState *env)
 {
-    CPUState *cs;
+    CPUState *self = env_cpu(env), *cs;
 
     BQL_LOCK_GUARD();
 
     CPU_FOREACH(cs) {
         ARMCPU *target_cpu = ARM_CPU(cs);
         target_cpu->env.event_register = true;
-        if (!qemu_cpu_is_self(cs)) {
+        if (cs != self) {
             qemu_cpu_kick(cs);
         }
     }
Signature · 1 line
2.55.0
#4 lore raw

[PULL 04/18] target/m68k: Fix TB_FLAGS_TRACE* definitions

In reply to Philippe Mathieu-Daudé

TB_FLAGS_TRACE and TB_FLAGS_TRACE_BIT are swapped. Fix to avoid m68k_get_tb_cpu_state() set an invalid bit.

Fixes 5e50c6c72bf8 ("target/m68k: implement m68k trace mode")

Message-ID: <[email protected]>

---
 target/m68k/cpu.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/m68k/cpu.h +2 -2
index 781c98f78400..5adca8ed49f7 100644
@@ -606,8 +606,8 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
 #define TB_FLAGS_SFC_S          (1 << TB_FLAGS_SFC_S_BIT)
 #define TB_FLAGS_DFC_S_BIT      15
 #define TB_FLAGS_DFC_S          (1 << TB_FLAGS_DFC_S_BIT)
-#define TB_FLAGS_TRACE          16
-#define TB_FLAGS_TRACE_BIT      (1 << TB_FLAGS_TRACE)
+#define TB_FLAGS_TRACE_BIT      16
+#define TB_FLAGS_TRACE          (1 << TB_FLAGS_TRACE_BIT)
 
 void dump_mmu(CPUM68KState *env);
 
Signature · 1 line
2.55.0
#5 lore raw

[PULL 06/18] target/mips: Check for MIPS II when decoding BLEZL/BGTZL

In reply to Philippe Mathieu-Daudé

Branch-likely instructions were introduced in MIPS II; on MIPS I they signal Reserved Instruction. BEQL/BNEL and the REGIMM likely forms already check ISA_MIPS2, but BLEZL and BGTZL (non-R6) did not.

Fixes d9224450208e ("target-mips: Tighten ISA level checks")

Message-ID: <[email protected]>

---
 target/mips/tcg/translate.c | 2 ++
 1 file changed, 2 insertions(+)
target/mips/tcg/translate.c +2 -0
index 10811db827c9..f521e0ec5bd0 100644
@@ -14621,6 +14621,7 @@ static bool decode_opc_legacy(CPUMIPSState *env, DisasContext *ctx)
             gen_compute_compact_branch(ctx, op, rs, rt, imm << 2);
         } else {
             /* OPC_BLEZL */
+            check_insn(ctx, ISA_MIPS2);
             gen_compute_branch(ctx, op, 4, rs, rt, imm << 2, 4);
         }
         break;
@@ -14634,6 +14635,7 @@ static bool decode_opc_legacy(CPUMIPSState *env, DisasContext *ctx)
             gen_compute_compact_branch(ctx, op, rs, rt, imm << 2);
         } else {
             /* OPC_BGTZL */
+            check_insn(ctx, ISA_MIPS2);
             gen_compute_branch(ctx, op, 4, rs, rt, imm << 2, 4);
         }
         break;
Signature · 1 line
2.55.0
#6 lore raw

[PULL 05/18] target/ppc: Test CF_NO_GOTO_PTR in cflags, not in TB flags

In reply to Philippe Mathieu-Daudé

CF_NO_GOTO_PTR is a TB cflags bit, but it was tested against tb->flags, where bit 10 is HFLAGS_SE. Use tb_cflags().

Message-ID: <[email protected]>

---
 target/ppc/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/translate.c +2 -2
index 467b8f3d4ec2..dccae25bb4ec 100644
@@ -2645,7 +2645,7 @@ static void gen_lookup_and_goto_ptr(DisasContext *ctx)
          * tcg_gen_lookup_and_goto_ptr will exit the TB if
          * CF_NO_GOTO_PTR is set. Count insns now.
          */
-        if (ctx->base.tb->flags & CF_NO_GOTO_PTR) {
+        if (tb_cflags(ctx->base.tb) & CF_NO_GOTO_PTR) {
             pmu_count_insns(ctx);
         }
 
@@ -5160,7 +5160,7 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
          * tcg_gen_lookup_and_goto_ptr will exit the TB if
          * CF_NO_GOTO_PTR is set. Count insns now.
          */
-        if (ctx->base.tb->flags & CF_NO_GOTO_PTR) {
+        if (tb_cflags(ctx->base.tb) & CF_NO_GOTO_PTR) {
             pmu_count_insns(ctx);
         }
 
Signature · 1 line
2.55.0
#7 lore raw

[PULL 09/18] target/mips: Enforce alignment and 64-bit CPU for the DSP LX loads

In reply to Philippe Mathieu-Daudé

The DSP LHX, LWX and LDX loads require a naturally aligned address and raise Address Error otherwise (MD00374 r3.01 p.130-131, MD00375 r3.02 p.145). Use the default memop alignment mask for them (strict, except under linux-user FIXADE); LBUX is a byte access. The Octeon LX forms share gen_lx() and are unchanged.

LDX belongs to the MIPS64 DSP module only, but was decoded on any DSP CPU in a 64-bit build, including 32-bit ones such as the 24KE or 74K. Call check_mips_64() after the DSP Disabled check to raise Reserved Instruction there.

Fixes 9b1a1d68d041 ("target-mips: Add ASE DSP load instructions")

Message-ID: <[email protected]>

---
 target/mips/tcg/translate.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
target/mips/tcg/translate.c +4 -3
index c434da714b0c..55dd69353eee 100644
@@ -13649,17 +13649,18 @@ static void decode_opc_special3_legacy(CPUMIPSState *env, DisasContext *ctx)
         switch (op2) {
 #if defined(TARGET_MIPS64)
         case OPC_LDX:
-            gen_lx(ctx, rd, rs, rt, MO_UQ);
+            check_mips_64(ctx);
+            gen_lx(ctx, rd, rs, rt, MO_UQ | ctx->default_tcg_memop_mask);
             break;
 #endif
         case OPC_LBUX:
             gen_lx(ctx, rd, rs, rt, MO_UB);
             break;
         case OPC_LHX:
-            gen_lx(ctx, rd, rs, rt, MO_SW);
+            gen_lx(ctx, rd, rs, rt, MO_SW | ctx->default_tcg_memop_mask);
             break;
         case OPC_LWX:
-            gen_lx(ctx, rd, rs, rt, MO_SL);
+            gen_lx(ctx, rd, rs, rt, MO_SL | ctx->default_tcg_memop_mask);
             break;
         default:            /* Invalid */
             MIPS_INVAL("MASK LX");
Signature · 1 line
2.55.0
#8 lore raw

[PULL 10/18] target/mips: Fix reset into microMIPS mode when Config3.ISA is 3

In reply to Philippe Mathieu-Daudé

The Config3.ISA == 3 test ANDs bit 14 and bit 15 as two separate constants, so it is always false and no CPU resets into microMIPS mode. Test the 2-bit field instead.

Config3.ISA == 3: both MIPS32 and microMIPS32 are implemented, with microMIPS32 used out of reset (MD00090 rev 6.02, Table 9.67, p. 248).

Fixes 0bbc0396809f ("target/mips: Prevent switching mode Config3 ISA bit nanoMIPS")

Message-ID: <[email protected]>

---
 target/mips/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/cpu.c +1 -1
index 8ad5e49ade41..324e5989cca1 100644
@@ -459,7 +459,7 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type)
         env->CP0_PWField = 0x02;
     }
 
-    if (env->CP0_Config3 & (1 << CP0C3_ISA) & (1 << (CP0C3_ISA + 1))) {
+    if (extract32(env->CP0_Config3, CP0C3_ISA, 2) == 3) {
         /*  microMIPS on reset when Config3.ISA is 3 */
         env->hflags |= MIPS_HFLAG_M16;
     }
Signature · 1 line
2.55.0
#9 lore raw

[PULL 12/18] target/mips: Fix microMIPS CACHE offset used for ITC tag access

In reply to Philippe Mathieu-Daudé

CACHE is encoded in POOL32B with a 9-bit signed offset in bits 8:0 (MD00582 rev 6.04, p. 144). The decoder passed the generic 'imm' (the low 16 bits of the opcode), which also holds the minor opcode and reserved bits 15:9, so the ITC tag access used a wrong effective address. Extract the 9-bit offset, as done for CACHEE.

Fixes 0d74a222c27e ("target-mips: make ITC Configuration Tags accessible")

Message-ID: <[email protected]>

---
 target/mips/tcg/micromips_translate.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/micromips_translate.c.inc +1 -1
index 4ad2b699615e..21374e3ec60f 100644
@@ -1820,7 +1820,7 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx)
         case CACHE:
             check_cp0_enabled(ctx);
             if (ctx->hflags & MIPS_HFLAG_ITC_CACHE) {
-                gen_cache_operation(ctx, rt, rs, imm);
+                gen_cache_operation(ctx, rt, rs, SIMM(ctx->opcode, 0, 9));
             }
             break;
         case LWC2:
Signature · 1 line
2.55.0
#10 lore raw

[PULL 14/18] target/mips: Pass the right instruction size for nanoMIPS RESTORE.JRC

In reply to Philippe Mathieu-Daudé

RESTORE.JRC[32] is a 32-bit instruction (MD01247, printed page 155), but gen_compute_branch_nm() was called with an instruction size of 2 (copy/paste from the 16-bit form), which wrongly set MIPS_HFLAG_B16.

No functional effect: gen_branch() clears MIPS_HFLAG_B16 before anything reads it.

Fixes c02809830346 ("target/mips: Add emulation of some nanoMIPS 32-bit instr")

Message-ID: <[email protected]>

---
 target/mips/tcg/nanomips_translate.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/nanomips_translate.c.inc +1 -1
index f1462c971a93..39ba96230596 100644
@@ -3745,7 +3745,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                                 extract32(ctx->opcode, 2, 1),
                                 extract32(ctx->opcode, 3, 9) << 3);
                     if ((ctx->opcode & 3) == NM_RESTORE_JRC) {
-                        gen_compute_branch_nm(ctx, OPC_JR, 2, 31, 0, 0);
+                        gen_compute_branch_nm(ctx, OPC_JR, 4, 31, 0, 0);
                     }
                     break;
                 default:
Signature · 1 line
2.55.0
#11 lore raw

[PULL 13/18] target/mips: Fix nanoMIPS BPOSGE32C branch offset sign extension

In reply to Philippe Mathieu-Daudé

The BPOSGE32C offset is a signed value s[14:1], with s[14] stored in instruction bit 0 (MD01249 rev 0.04, "BPOSGE32C", printed page 88). The decoder zero-extended it, so backward branches went to the wrong target.

Reuse the sign-extended offset already computed by the P.BR3A pool.

Fixes 6d033ca7513d ("target/mips: Add emulation of DSP ASE for nanoMIPS")

Message-ID: <[email protected]>

---
 target/mips/tcg/nanomips_translate.c.inc | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
target/mips/tcg/nanomips_translate.c.inc +1 -7
index c883b5514f1c..f1462c971a93 100644
@@ -4364,13 +4364,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                     break;
                 case NM_BPOSGE32C:
                     check_dsp_r3(ctx);
-                    {
-                        imm = extract32(ctx->opcode, 1, 13)
-                            | extract32(ctx->opcode, 0, 1) << 13;
-
-                        gen_compute_branch_nm(ctx, OPC_BPOSGE32, 4, -1, -2,
-                                              imm << 1);
-                    }
+                    gen_compute_branch_nm(ctx, OPC_BPOSGE32, 4, -1, -2, s);
                     break;
                 default:
                     gen_reserved_instruction(ctx);
Signature · 1 line
2.55.0
#12 lore raw

[PULL 08/18] target/mips: Require the MT module for MFTR/MTTR

In reply to Philippe Mathieu-Daudé

MFTR/MTTR must raise Reserved Instruction on processors not implementing the MT module (MD00378 pp.46/50, Config3.MT:
table 6.21). Use check_cp0_mt(), as done for the other MT instructions, instead of only check_cp0_enabled().

Fixes ead9360e2fbc ("Partial support for 34K multithreading")

Message-ID: <[email protected]>

---
 target/mips/tcg/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/mips/tcg/translate.c +2 -2
index 6e7e1a0f758e..c434da714b0c 100644
@@ -8588,7 +8588,7 @@ static void gen_cp0(CPUMIPSState *env, DisasContext *ctx, uint32_t opc,
         opn = "mthc0";
         break;
     case OPC_MFTR:
-        check_cp0_enabled(ctx);
+        check_cp0_mt(ctx);
         if (rd == 0) {
             /* Treat as NOP. */
             return;
@@ -8598,7 +8598,7 @@ static void gen_cp0(CPUMIPSState *env, DisasContext *ctx, uint32_t opc,
         opn = "mftr";
         break;
     case OPC_MTTR:
-        check_cp0_enabled(ctx);
+        check_cp0_mt(ctx);
         gen_mttr(env, ctx, rd, rt, (ctx->opcode >> 5) & 1,
                  ctx->opcode & 0x7, (ctx->opcode >> 4) & 1);
         opn = "mttr";
Signature · 1 line
2.55.0
#13 lore raw

[PULL 11/18] target/mips: Fix microMIPS BC2NEZC POOL32I minor opcode

In reply to Philippe Mathieu-Daudé

BC2NEZC is POOL32I minor opcode 0x0b (bits 25:21 = 01011); 0x0a is BC2EQZC. See MD00582 rev 6.04 p. 131 and MD00594 rev 6.04 p. 145.

Both constants are unreferenced, so there is no functional change.

Fixes 3a1f426828cd ("target-mips: add microMIPS32 R6 opcode enum")

Message-ID: <[email protected]>

---
 target/mips/tcg/micromips_translate.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/micromips_translate.c.inc +1 -1
index d6a5c2263b56..4ad2b699615e 100644
@@ -513,7 +513,7 @@ enum {
     TLTIU = 0x0a,
     BC2EQZC = 0x0a,
     TGEIU = 0x0b,
-    BC2NEZC = 0x0a,
+    BC2NEZC = 0x0b,
     TNEI = 0x0c,
     R6_SYNCI = 0x0c,
     LUI = 0x0d,
Signature · 1 line
2.55.0
#14 lore raw

[PULL 07/18] target/mips: Require rt == 0 when decoding BLEZL/BGTZL

In reply to Philippe Mathieu-Daudé

The BLEZL and BGTZL encodings fix rt to 00000. The legacy decoder ignored rt on non-R6 CPUs, executing reserved encodings as BLEZL/BGTZL instead of raising Reserved Instruction. On R6 these opcodes are the compact branches, which already reject rt == 0.

Message-ID: <[email protected]>

---
 target/mips/tcg/translate.c | 8 ++++++++
 1 file changed, 8 insertions(+)
target/mips/tcg/translate.c +8 -0
index f521e0ec5bd0..6e7e1a0f758e 100644
@@ -14621,6 +14621,10 @@ static bool decode_opc_legacy(CPUMIPSState *env, DisasContext *ctx)
             gen_compute_compact_branch(ctx, op, rs, rt, imm << 2);
         } else {
             /* OPC_BLEZL */
+            if (rt != 0) {
+                gen_reserved_instruction(ctx);
+                break;
+            }
             check_insn(ctx, ISA_MIPS2);
             gen_compute_branch(ctx, op, 4, rs, rt, imm << 2, 4);
         }
@@ -14635,6 +14639,10 @@ static bool decode_opc_legacy(CPUMIPSState *env, DisasContext *ctx)
             gen_compute_compact_branch(ctx, op, rs, rt, imm << 2);
         } else {
             /* OPC_BGTZL */
+            if (rt != 0) {
+                gen_reserved_instruction(ctx);
+                break;
+            }
             check_insn(ctx, ISA_MIPS2);
             gen_compute_branch(ctx, op, 4, rs, rt, imm << 2, 4);
         }
Signature · 1 line
2.55.0
#15 lore raw

[PULL 17/18] target/mips: Decode 6-bit bit number of nanoMIPS BBEQZC/BBNEZC

In reply to Philippe Mathieu-Daudé

BBEQZC (MD01247 p.38) and BBNEZC (p.39) encode the bit number in bits 16:11; bit 17 is 'x' (don't care). The decoder used the 7-bit immediate (17:11) of the other P.BRI branches, so a set bit 17 gave a bit number >= 64 and raised Reserved Instruction on cores without 64-bit operations. Decode only 6 bits for these two; BEQIC and the other P.BRI branches really have a 7-bit u field.

Fixes 11d0fc10b7ef ("target/mips: Add emulation of nanoMIPS 32-bit branch")

Message-ID: <[email protected]>

---
 target/mips/tcg/nanomips_translate.c.inc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
target/mips/tcg/nanomips_translate.c.inc +5 -3
index 19cca9463de4..f9ebfe54b4ba 100644
@@ -4430,10 +4430,12 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
         {
             int32_t s = sextract32(ctx->opcode, 0, 1) << 11 |
                         extract32(ctx->opcode, 1, 10) << 1;
-            uint32_t u = extract32(ctx->opcode, 11, 7);
+            uint32_t opc = extract32(ctx->opcode, 18, 3);
+            uint32_t u = extract32(ctx->opcode, 11,
+                                   (opc == NM_BBEQZC ||
+                                    opc == NM_BBNEZC) ? 6 : 7);
 
-            gen_compute_imm_branch(ctx, extract32(ctx->opcode, 18, 3),
-                                   rt, u, s);
+            gen_compute_imm_branch(ctx, opc, rt, u, s);
         }
         break;
     default:
Signature · 1 line
2.55.0
#16 lore raw

[PULL 16/18] target/mips: Pass the nanoMIPS BREAK code to generate_exception_break()

In reply to Philippe Mathieu-Daudé

The nanoMIPS BREAK[32] and BREAK[16] decoders call generate_exception_end() and drop the break code, leaving a stale env->error_code for linux-user. Pass the encoded 'code' 19 bits for BREAK[32], 3 bits for BREAK[16] (MD01247 rev 01.01, p.59).

Complete 6f3533dd1b6a ("target/mips: Extract break code into env->error_code").

Fixes c02809830346 ("target/mips: Add emulation of some nanoMIPS 32-bit")
Fixes 8869ad02bfd9 ("target/mips: Add emulation of nanoMIPS 16-bit misc")

Message-ID: <[email protected]>

---
 target/mips/tcg/nanomips_translate.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/mips/tcg/nanomips_translate.c.inc +2 -2
index dcee8df333f4..19cca9463de4 100644
@@ -3573,7 +3573,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                 }
                 break;
             case NM_BREAK:
-                generate_exception_end(ctx, EXCP_BREAK);
+                generate_exception_break(ctx, extract32(ctx->opcode, 0, 19));
                 break;
             case NM_SDBBP:
                 if (is_uhi(ctx, extract32(ctx->opcode, 0, 19))) {
@@ -4508,7 +4508,7 @@ static int decode_isa_nanomips(CPUMIPSState *env, DisasContext *ctx)
                 }
                 break;
             case NM_BREAK16:
-                generate_exception_end(ctx, EXCP_BREAK);
+                generate_exception_break(ctx, extract32(ctx->opcode, 0, 3));
                 break;
             case NM_SDBBP16:
                 if (is_uhi(ctx, extract32(ctx->opcode, 0, 3))) {
Signature · 1 line
2.55.0
#17 lore raw

[PULL 15/18] target/mips: Fix nanoMIPS BC1EQZC/BC1NEZC always raising RI

In reply to Philippe Mathieu-Daudé

The P.BR3A decoder passes OPC_BC1EQZ / OPC_BC1NEZ (the MIPS CP1 opcodes) to gen_compute_branch_cp1_nm(), but the function switches on the nanoMIPS pool values NM_BC1EQZC (0) and NM_BC1NEZC (1). No call could match, so both instructions raised Reserved Instruction.

The P.BR3A encoding is in MD01247 rev 01.01, printed page 288. Switch on the values the callers pass.

Fixes 11d0fc10b7ef ("target/mips: Add emulation of nanoMIPS 32-bit branch")

Message-ID: <[email protected]>

---
 target/mips/tcg/nanomips_translate.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/mips/tcg/nanomips_translate.c.inc +2 -2
index 39ba96230596..dcee8df333f4 100644
@@ -2558,11 +2558,11 @@ static void gen_compute_branch_cp1_nm(DisasContext *ctx, uint32_t op,
     btarget = addr_add(ctx, ctx->base.pc_next + 4, offset);
 
     switch (op) {
-    case NM_BC1EQZC:
+    case OPC_BC1EQZ:
         tcg_gen_xori_i64(t0, t0, 1);
         ctx->hflags |= MIPS_HFLAG_BC;
         break;
-    case NM_BC1NEZC:
+    case OPC_BC1NEZ:
         /* t0 already set */
         ctx->hflags |= MIPS_HFLAG_BC;
         break;
Signature · 1 line
2.55.0
#18 lore raw

[PULL 18/18] target/mips: Do not sign-extend partial LWR results on Octeon

In reply to Philippe Mathieu-Daudé

The MIPS64 Release 6.05 manual (LWR description) says that when bit 31 is not loaded, bits 63..32 of the destination are implementation
dependent: either unchanged or a copy of bit 31. Both behaviours are architecturally allowed.

Octeon III CN71XX hardware leaves bits 63..32 unchanged unless the whole word is loaded (vAddr[1:0] = 3 for big-endian, 0 for little-endian). QEMU always sign-extended the merged low word.

Seen replaying a risu trace recorded on a Cavium Octeon III CN71XX:
"lwr s7,26334(a2)" left r23 = 0004114d368db793 on the hardware where QEMU had 00000000368db793.

Only change the behaviour for Octeon CPUs (INSN_OCTEON); all other CPUs keep sign-extending the result. LWL always loads bit 31 and is unchanged.

Message-ID: <[email protected]>

---
 target/mips/tcg/translate.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
target/mips/tcg/translate.c +12 -2
index 55dd69353eee..bbcccbbb467f 100644
@@ -2063,7 +2063,7 @@ void gen_lx(DisasContext *ctx, int rd, int base, int index, MemOp mop)
 static void gen_ld(DisasContext *ctx, uint32_t opc,
                    int rt, int base, int offset)
 {
-    TCGv t0, t1;
+    TCGv t0, t1, t2, t3;
     int mem_idx = ctx->mem_idx;
 
     if (rt == 0 && ctx->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F |
@@ -2176,7 +2176,17 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,
         t1 = tcg_temp_new();
         gen_load_gpr(t1, rt);
         gen_lxr(ctx, t1, t0, mem_idx, mo_endian(ctx) | MO_UL);
-        tcg_gen_ext32s_tl(t1, t1);
+        if (ctx->insn_flags & INSN_OCTEON) {
+            t2 = tcg_temp_new();
+            t3 = tcg_temp_new();
+            tcg_gen_ext32s_tl(t3, t1);
+            tcg_gen_andi_tl(t2, t0, 3);
+            tcg_gen_movcond_tl(TCG_COND_EQ, t1, t2,
+                               tcg_constant_tl(disas_is_bigendian(ctx) ? 3 : 0),
+                               t3, t1);
+        } else {
+            tcg_gen_ext32s_tl(t1, t1);
+        }
         gen_store_gpr(t1, rt);
         break;
     case OPC_LLE:
Signature · 1 line
2.55.0
#19 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

The following changes since commit 6bf90d4fc5027567cb704d7888f5ec792b4ed75a:

   Merge tag 'pull-target-arm-20261124' ofhttps://gitlab.com/pm215/qemu into staging (2026-11-24 07:09:41 -0800)

are available in the Git repository at:

   https://github.com/philmd/qemu.git tags/target-misc-20261124

for you to fetch changes up to fd25fe89996688623717b485654e26a0d7f46c62:

Quoted 7 lines
   target/mips: Do not sign-extend partial LWR results on Octeon (2026-11-25 00:22:48 +0100)

----------------------------------------------------------------
Misc fixes for 11.2

- TCG flags (M68k, PPC) & icount (ARM)
- MIPS opcodes and exceptions

Applied, thanks.

r~