Commit ae3b0b05fd for qemu.org
commit ae3b0b05fd27c0d7fe0df8c0b6e9d9f28cdec803
Author: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Date: Tue Nov 10 22:56:50 2026 +0100
target/mips: Fix nanoMIPS BC1EQZC/BC1NEZC always raising RI
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")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20261113161158.25811-13-philmd@oss.qualcomm.com>
diff --git a/target/mips/tcg/nanomips_translate.c.inc b/target/mips/tcg/nanomips_translate.c.inc
index 39ba962305..dcee8df333 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -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;