Skip to content

Commit 47c2503

Browse files
Archer Yanpaulburton
authored andcommitted
MIPS: Fix kernel crash for R6 in jump label branch function
Insert Branch instruction instead of NOP to make sure assembler don't patch code in forbidden slot. In jump label function, it might be possible to patch Control Transfer Instructions(CTIs) into forbidden slot, which will generate Reserved Instruction exception in MIPS release 6. Signed-off-by: Archer Yan <ayan@wavecomp.com> Reviewed-by: Paul Burton <paul.burton@mips.com> [paul.burton@mips.com: - Add MIPS prefix to subject. - Mark for stable from v4.0, which introduced r6 support, onwards.] Signed-off-by: Paul Burton <paul.burton@mips.com> Cc: linux-mips@vger.kernel.org Cc: stable@vger.kernel.org # v4.0+
1 parent 3f0a53b commit 47c2503

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/mips/include/asm/jump_label.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
#endif
2222

2323
#ifdef CONFIG_CPU_MICROMIPS
24-
#define NOP_INSN "nop32"
24+
#define B_INSN "b32"
2525
#else
26-
#define NOP_INSN "nop"
26+
#define B_INSN "b"
2727
#endif
2828

2929
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
3030
{
31-
asm_volatile_goto("1:\t" NOP_INSN "\n\t"
32-
"nop\n\t"
31+
asm_volatile_goto("1:\t" B_INSN " 2f\n\t"
32+
"2:\tnop\n\t"
3333
".pushsection __jump_table, \"aw\"\n\t"
3434
WORD_INSN " 1b, %l[l_yes], %0\n\t"
3535
".popsection\n\t"

0 commit comments

Comments
 (0)