Commit fe207cd6a0 for qemu.org
commit fe207cd6a0728d4ed65d2ae29803cf1d59935da0
Author: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Date: Thu Nov 12 22:03:33 2026 +0100
target/mips: Decode 6-bit bit number of nanoMIPS BBEQZC/BBNEZC
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")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20261113161158.25811-17-philmd@oss.qualcomm.com>
diff --git a/target/mips/tcg/nanomips_translate.c.inc b/target/mips/tcg/nanomips_translate.c.inc
index 19cca9463d..f9ebfe54b4 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -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: