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.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
 target/mips/tcg/translate.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index f521e0ec5bd0..6e7e1a0f758e 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -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);
         }
-- 
2.55.0


Reply via email to