linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix Kernel crash for MIPS rel6 in jump label branch function.
@ 2019-03-08  3:29 Archer Yan
  2019-03-11 18:14 ` Paul Burton
  0 siblings, 1 reply; 2+ messages in thread
From: Archer Yan @ 2019-03-08  3:29 UTC (permalink / raw)
  To: linux-mips; +Cc: Archer Yan

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>
---
 arch/mips/include/asm/jump_label.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/mips/include/asm/jump_label.h b/arch/mips/include/asm/jump_label.h
index e77672539e8e..e4456e450f94 100644
--- a/arch/mips/include/asm/jump_label.h
+++ b/arch/mips/include/asm/jump_label.h
@@ -21,15 +21,15 @@
 #endif
 
 #ifdef CONFIG_CPU_MICROMIPS
-#define NOP_INSN "nop32"
+#define B_INSN "b32"
 #else
-#define NOP_INSN "nop"
+#define B_INSN "b"
 #endif
 
 static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
 {
-	asm_volatile_goto("1:\t" NOP_INSN "\n\t"
-		"nop\n\t"
+	asm_volatile_goto("1:\t" B_INSN " 2f\n\t"
+		"2:\tnop\n\t"
 		".pushsection __jump_table,  \"aw\"\n\t"
 		WORD_INSN " 1b, %l[l_yes], %0\n\t"
 		".popsection\n\t"
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix Kernel crash for MIPS rel6 in jump label branch function.
  2019-03-08  3:29 [PATCH] Fix Kernel crash for MIPS rel6 in jump label branch function Archer Yan
@ 2019-03-11 18:14 ` Paul Burton
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Burton @ 2019-03-11 18:14 UTC (permalink / raw)
  To: Archer Yan; +Cc: linux-mips, Archer Yan, linux-mips

Hello,

Archer Yan wrote:
> 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>

Applied to mips-fixes.

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paul.burton@mips.com to report it. ]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-11 18:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-08  3:29 [PATCH] Fix Kernel crash for MIPS rel6 in jump label branch function Archer Yan
2019-03-11 18:14 ` Paul Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).