Skip to content

Commit

Permalink
MIPS: Fix branch emulation for BLTC and BGEC instructions
Browse files Browse the repository at this point in the history
Commits f1b4406 ("MIPS: Emulate the
new MIPS R6 B{L,G}T{Z,}{AL,}C instructions") and commit
a8ff66f ("MIPS: Emulate the new MIPS
R6 B{L,G}E{Z,}{AL,}C instructions") added support for emulating various
branch compact instructions. However, it missed the case for those which
use the old BLEZL and BGTZL opcodes leading to random crashes when the R6
emulator is disabled. We fix this by ensuring that the 'rt' field is not
zero which is always true for these branch compact instructions.

Fixes: f1b4406 ("MIPS: Emulate the new MIPS R6 B{L,G}T{Z,}{AL,}C instructions")
Fixes: a8ff66f ("MIPS: Emulate the new MIPS R6 B{L,G}E{Z,}{AL,}C instructions")
Cc: <stable@vger.kernel.org> # 4.0+
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: Markos Chandras <markos.chandras@imgtec.com>
Patchwork: https://patchwork.linux-mips.org/patch/10582/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Markos Chandras authored and Ralf Baechle committed Jul 9, 2015
1 parent 761b449 commit e9d92d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions arch/mips/kernel/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ int __compute_return_epc_for_insn(struct pt_regs *regs,
break;

case blezl_op: /* not really i_format */
if (NO_R6EMU)
if (!insn.i_format.rt && NO_R6EMU)
goto sigill_r6;
case blez_op:
/*
Expand Down Expand Up @@ -635,7 +635,7 @@ int __compute_return_epc_for_insn(struct pt_regs *regs,
break;

case bgtzl_op:
if (NO_R6EMU)
if (!insn.i_format.rt && NO_R6EMU)
goto sigill_r6;
case bgtz_op:
/*
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/math-emu/cp1emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
dec_insn.next_pc_inc;
return 1;
case blezl_op:
if (NO_R6EMU)
if (!insn.i_format.rt && NO_R6EMU)
break;
case blez_op:

Expand Down Expand Up @@ -588,7 +588,7 @@ static int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
dec_insn.next_pc_inc;
return 1;
case bgtzl_op:
if (NO_R6EMU)
if (!insn.i_format.rt && NO_R6EMU)
break;
case bgtz_op:
/*
Expand Down

0 comments on commit e9d92d2

Please sign in to comment.