Skip to content

Commit c24159a

Browse files
paulburtongregkh
authored andcommitted
MIPS: Fix bnezc/jialc return address calculation
commit 1a73d9310e093fc3adffba4d0a67b9fab2ee3f63 upstream. The code handling the pop76 opcode (ie. bnezc & jialc instructions) in __compute_return_epc_for_insn() needs to set the value of $31 in the jialc case, which is encoded with rs = 0. However its check to differentiate bnezc (rs != 0) from jialc (rs = 0) was unfortunately backwards, meaning that if we emulate a bnezc instruction we clobber $31 & if we emulate a jialc instruction it actually behaves like a jic instruction. Fix this by inverting the check of rs to match the way the instructions are actually encoded. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Fixes: 28d6f93 ("MIPS: Emulate the new MIPS R6 BNEZC and JIALC instructions") Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/16178/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9469538 commit c24159a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

arch/mips/kernel/branch.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,10 @@ int __compute_return_epc_for_insn(struct pt_regs *regs,
816816
break;
817817
}
818818
/* Compact branch: BNEZC || JIALC */
819-
if (insn.i_format.rs)
819+
if (!insn.i_format.rs) {
820+
/* JIALC: set $31/ra */
820821
regs->regs[31] = epc + 4;
822+
}
821823
regs->cp0_epc += 8;
822824
break;
823825
#endif

0 commit comments

Comments
 (0)