[PATCH v2 03/10] MIPS: Fix unaligned PC interpretation in `compute_return_epc'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Cc: stable@xxxxxxxxxxxxxxx # 3.9+
Fixes: fb6883e5809c ("MIPS: microMIPS: Support handling of delay slots.")
Signed-off-by: Maciej W. Rozycki <macro@xxxxxxxxxx>
---
Unchanged from v1.

linux-mips-compute-return-epc-unaligned.diff
Index: linux-sfr-test/arch/mips/include/asm/branch.h
===================================================================
--- linux-sfr-test.orig/arch/mips/include/asm/branch.h	2016-10-22 10:43:21.000000000 +0100
+++ linux-sfr-test/arch/mips/include/asm/branch.h	2016-11-08 04:55:33.724746000 +0000
@@ -74,10 +74,7 @@ static inline int compute_return_epc(str
 			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;
 	}




[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux