Commit 95ab09fca2 for qemu.org
commit 95ab09fca200eb6da3769fc89f52ca43c0c96e0d
Author: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Date: Tue Nov 10 18:44:36 2026 +0100
target/mips: Fix nanoMIPS BPOSGE32C branch offset sign extension
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")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20261113161158.25811-11-philmd@oss.qualcomm.com>
diff --git a/target/mips/tcg/nanomips_translate.c.inc b/target/mips/tcg/nanomips_translate.c.inc
index c883b5514f..f1462c971a 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -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);