Patch "MIPS: Send SIGILL for R6 branches in `__compute_return_epc_for_insn'" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
MIPS: Send SIGILL for R6 branches in `__compute_return_epc_for_insn'
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mips-send-sigill-for-r6-branches-in-__compute_return_epc_for_insn.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
a60b1a5bf88a250f1a77977c0224e502c901c77bMon Sep 17 00:00:00 2001
From: "Maciej W. Rozycki" <[email protected]>
Date: Fri, 16 Jun 2017 00:14:12 +0100
Subject: MIPS: Send SIGILL for R6 branches in `__compute_return_epc_for_insn'
From: Maciej W. Rozycki <[email protected]>
commit a60b1a5bf88a250f1a77977c0224e502c901c77b upstream.
Fix:
* commit 8467ca0122e2 ("MIPS: Emulate the new MIPS R6 branch compact (BC) instruction"),
* commit 84fef630127a ("MIPS: Emulate the new MIPS R6 BALC instruction"),
* commit 69b9a2fd05a3 ("MIPS: Emulate the new MIPS R6 BEQZC and JIC instructions"),
* commit 28d6f93d201d ("MIPS: Emulate the new MIPS R6 BNEZC and JIALC instructions"),
* commit c893ce38b265 ("MIPS: Emulate the new MIPS R6 BOVC, BEQC and BEQZALC instructions")
and send SIGILL rather than returning -SIGILL for R6 branch and jump instructions. Returning -SIGILL is never correct as the API defines this function's result upon error to be -EFAULT and a signal actually issued.
Patchwork: https://patchwork.linux-mips.org/patch/16399/
--- arch/mips/kernel/branch.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-)
arch/mips/kernel/branch.c +15 -20
@@ -771,35 +771,27 @@ int __compute_return_epc_for_insn(struct#else case bc6_op:/* Only valid for MIPS R6 */ -if (!cpu_has_mips_r6) { - ret = -SIGILL ; -break ; - } +if (!cpu_has_mips_r6) + goto sigill_r6; regs->cp0_epc +=8 ;break ;case balc6_op: -if (!cpu_has_mips_r6) { - ret = -SIGILL ; -break ; - } +if (!cpu_has_mips_r6) + goto sigill_r6;/* Compact branch: BALC */ regs->regs[31 ] = epc +4 ; epc +=4 + (insn.i_format.simmediate <<2 ); regs->cp0_epc = epc;break ;case pop66_op: -if (!cpu_has_mips_r6) { - ret = -SIGILL ; -break ; - } +if (!cpu_has_mips_r6) + goto sigill_r6;/* Compact branch: BEQZC || JIC */ regs->cp0_epc +=8 ;break ;case pop76_op: -if (!cpu_has_mips_r6) { - ret = -SIGILL ; -break ; - } +if (!cpu_has_mips_r6) + goto sigill_r6;/* Compact branch: BNEZC || JIALC */ if (!insn.i_format.rs) {/* JIALC: set $31/ra */
@@ -811,10 +803,8 @@ int __compute_return_epc_for_insn(structcase pop10_op:case pop30_op:/* Only valid for MIPS R6 */ -if (!cpu_has_mips_r6) { - ret = -SIGILL ; -break ; - } +if (!cpu_has_mips_r6) + goto sigill_r6;/* * Compact branches: * bovc, beqc, beqzalc, bnvc, bnec, bnezlac
@@ -837,6 +827,11 @@ sigill_r2r6: current->comm);force_sig (SIGILL , current);return -EFAULT ; +sigill_r6: +pr_info ("%s: R6 branch but no MIPSr6 ISA support - sending SIGILL.\n" , + current->comm); +force_sig (SIGILL , current); +return -EFAULT ; }EXPORT_SYMBOL_GPL (__compute_return_epc_for_insn);
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/mips-send-sigill-for-bposge32-in-__compute_return_epc_for_insn.patch queue-4.9/mips-actually-decode-jalx-in-__compute_return_epc_for_insn.patch queue-4.9/mips-fix-a-typo-s-preset-present-in-r2-to-r6-emulation-error-message.patch queue-4.9/mips-fix-unaligned-pc-interpretation-in-compute_return_epc.patch queue-4.9/mips-rename-sigill_r6-to-sigill_r2r6-in-__compute_return_epc_for_insn.patch queue-4.9/mips-send-sigill-for-r6-branches-in-__compute_return_epc_for_insn.patch queue-4.9/mips-send-sigill-for-linked-branches-in-__compute_return_epc_for_insn.patch queue-4.9/mips-math-emu-prevent-wrong-isa-mode-instruction-emulation.patch