]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.32/mips-fix-kernel-crash-for-r6-in-jump-label-branch-function.patch
Linux 4.19.32
[thirdparty/kernel/stable-queue.git] / releases / 4.19.32 / mips-fix-kernel-crash-for-r6-in-jump-label-branch-function.patch
1 From 47c25036b60f27b86ab44b66a8861bcf81cde39b Mon Sep 17 00:00:00 2001
2 From: Archer Yan <ayan@wavecomp.com>
3 Date: Fri, 8 Mar 2019 03:29:19 +0000
4 Subject: MIPS: Fix kernel crash for R6 in jump label branch function
5
6 From: Archer Yan <ayan@wavecomp.com>
7
8 commit 47c25036b60f27b86ab44b66a8861bcf81cde39b upstream.
9
10 Insert Branch instruction instead of NOP to make sure assembler don't
11 patch code in forbidden slot. In jump label function, it might
12 be possible to patch Control Transfer Instructions(CTIs) into
13 forbidden slot, which will generate Reserved Instruction exception
14 in MIPS release 6.
15
16 Signed-off-by: Archer Yan <ayan@wavecomp.com>
17 Reviewed-by: Paul Burton <paul.burton@mips.com>
18 [paul.burton@mips.com:
19 - Add MIPS prefix to subject.
20 - Mark for stable from v4.0, which introduced r6 support, onwards.]
21 Signed-off-by: Paul Burton <paul.burton@mips.com>
22 Cc: linux-mips@vger.kernel.org
23 Cc: stable@vger.kernel.org # v4.0+
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 arch/mips/include/asm/jump_label.h | 8 ++++----
28 1 file changed, 4 insertions(+), 4 deletions(-)
29
30 --- a/arch/mips/include/asm/jump_label.h
31 +++ b/arch/mips/include/asm/jump_label.h
32 @@ -21,15 +21,15 @@
33 #endif
34
35 #ifdef CONFIG_CPU_MICROMIPS
36 -#define NOP_INSN "nop32"
37 +#define B_INSN "b32"
38 #else
39 -#define NOP_INSN "nop"
40 +#define B_INSN "b"
41 #endif
42
43 static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
44 {
45 - asm_volatile_goto("1:\t" NOP_INSN "\n\t"
46 - "nop\n\t"
47 + asm_volatile_goto("1:\t" B_INSN " 2f\n\t"
48 + "2:\tnop\n\t"
49 ".pushsection __jump_table, \"aw\"\n\t"
50 WORD_INSN " 1b, %l[l_yes], %0\n\t"
51 ".popsection\n\t"