Skip to content

Commit 9dbca9e

Browse files
Maciej W. Rozyckigregkh
authored andcommitted
MIPS: Fix unaligned PC interpretation in `compute_return_epc'
commit 11a3799dbeb620bf0400b1fda5cc2c6bea55f20a upstream. Fix a regression introduced with commit fb6883e ("MIPS: microMIPS: Support handling of delay slots.") and defer to `__compute_return_epc' if the ISA bit is set in EPC with non-MIPS16, non-microMIPS hardware, which will then arrange for a SIGBUS due to an unaligned instruction reference. Returning EPC here is never correct as the API defines this function's result to be either a negative error code on failure or one of 0 and BRANCH_LIKELY_TAKEN on success. Fixes: fb6883e ("MIPS: microMIPS: Support handling of delay slots.") Signed-off-by: Maciej W. Rozycki <macro@imgtec.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/16395/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aebb796 commit 9dbca9e

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

arch/mips/include/asm/branch.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ static inline int compute_return_epc(struct pt_regs *regs)
7474
return __microMIPS_compute_return_epc(regs);
7575
if (cpu_has_mips16)
7676
return __MIPS16e_compute_return_epc(regs);
77-
return regs->cp0_epc;
78-
}
79-
80-
if (!delay_slot(regs)) {
77+
} else if (!delay_slot(regs)) {
8178
regs->cp0_epc += 4;
8279
return 0;
8380
}

0 commit comments

Comments
 (0)