On 11/13/26 08:11, Philippe Mathieu-Daudé wrote:
BNEC (rs == rt), BLTC (rs == rt != 0) and BLTUC (rs == rt) are NOPs,
but flagged the next insn as a forbidden slot. A following branch
then raised RI, and a fault there got a wrong EPC/Cause.BD. nanoMIPS
has neither delay nor forbidden slots (MD01247 p.12), so just fall
through.

Fixes: 11d0fc10b7ef ("target/mips: Add emulation of nanoMIPS 32-bit branch")
Fixes: 14668cfaaf4d ("target/mips: Fix emulation of nanoMIPS BNEC[32]")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
  target/mips/tcg/nanomips_translate.c.inc | 18 ++++++------------
  1 file changed, 6 insertions(+), 12 deletions(-)

The problem would appear to be elsewhere: Why would gen_compute_branch_nm *ever* set forbidden slot, given that nanomips doesn't have them?


r~


diff --git a/target/mips/tcg/nanomips_translate.c.inc 
b/target/mips/tcg/nanomips_translate.c.inc
index 68e9ca9cdb03..72d72f6f84a0 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -4370,26 +4370,20 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, 
DisasContext *ctx)
              switch (extract32(ctx->opcode, 14, 2)) {
              case NM_BNEC:
                  check_nms(ctx);
-                if (rs == rt) {
-                    /* NOP */
-                    ctx->hflags |= MIPS_HFLAG_FBNSLOT;
-                } else {
+                /* rs == rt is never taken: NOP */
+                if (rs != rt) {
                      gen_compute_branch_nm(ctx, OPC_BNE, 4, rs, rt, s);
                  }
                  break;
              case NM_BLTC:
-                if (rs != 0 && rt != 0 && rs == rt) {
-                    /* NOP */
-                    ctx->hflags |= MIPS_HFLAG_FBNSLOT;
-                } else {
+                /* rs == rt != 0 is never taken: NOP */
+                if (rs == 0 || rt == 0 || rs != rt) {
                      gen_compute_compact_branch_nm(ctx, OPC_BLTC, rs, rt, s);
                  }
                  break;
              case NM_BLTUC:
-                if (rs == rt) {
-                    /* NOP */
-                    ctx->hflags |= MIPS_HFLAG_FBNSLOT;
-                } else {
+                /* rs == rt is never taken: NOP */
+                if (rs != rt) {
                      gen_compute_compact_branch_nm(ctx, OPC_BLTUC, rs, rt, s);
                  }
                  break;


Reply via email to