]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
MIPS: Fix unaligned PC interpretation in `compute_return_epc'
authorMaciej W. Rozycki <macro@imgtec.com>
Thu, 15 Jun 2017 23:07:34 +0000 (00:07 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 29 Jun 2017 00:42:26 +0000 (02:42 +0200)
Fix a regression introduced with commit fb6883e5809c ("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: fb6883e5809c ("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
Cc: stable@vger.kernel.org # 3.9+
Patchwork: https://patchwork.linux-mips.org/patch/16395/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/branch.h

index de781cf54bc7a22b4ae81f506ff1a869c6b1cc32..da80878f2c0dcdda24a0c7348585f831fd4f68a4 100644 (file)
@@ -74,10 +74,7 @@ static inline int compute_return_epc(struct pt_regs *regs)
                        return __microMIPS_compute_return_epc(regs);
                if (cpu_has_mips16)
                        return __MIPS16e_compute_return_epc(regs);
-               return regs->cp0_epc;
-       }
-
-       if (!delay_slot(regs)) {
+       } else if (!delay_slot(regs)) {
                regs->cp0_epc += 4;
                return 0;
        }