linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm kgdb: fix breakpoint for thumb2
@ 2022-02-14  9:59 Johannes Stezenbach
  2022-02-14 10:13 ` Russell King (Oracle)
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Stezenbach @ 2022-02-14  9:59 UTC (permalink / raw)
  To: Russell King; +Cc: linux-arm-kernel

Entering kdb via SysRq-G with CONFIG_THUMB2_KERNEL=y
on Cortex-A7 in Qemu results in an Ooops, and it is
not possible to continue because of "Catastrophic error detected".
The root cause is using an arm breakpoint instruction in
thumb code.

For the breakpoint instruction I used this reference:
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdbserver/linux-aarch32-low.cc#l31
0xf7fxaxxx are UDF encoding T2 instructions
(32bit, permanently undefined).

Signed-off-by: Johannes Stezenbach <js@sig21.net>
---

Wrt arm GDB_BREAKINST maybe it is also needed to use something like

#ifdef CONFIG_AEABI
#define GDB_BREAKINST		0xe7f001f0
#else
#define GDB_BREAKINST		0xef9f0001
#endif

but I could not test if it makes a difference

diff --git a/arch/arm/include/asm/kgdb.h b/arch/arm/include/asm/kgdb.h
index 8de1100d1067..7e6ed3171b54 100644
--- a/arch/arm/include/asm/kgdb.h
+++ b/arch/arm/include/asm/kgdb.h
@@ -34,16 +34,22 @@
  * make our lives much much simpler. :)
  */
 #define BREAK_INSTR_SIZE	4
+#ifdef CONFIG_THUMB2_KERNEL
+#define GDB_BREAKINST		0xf7f0a000
+#define KGDB_BREAKINST		0xf7f0a001
+#define KGDB_COMPILED_BREAK	0xf7f0a002
+#else
 #define GDB_BREAKINST		0xef9f0001
 #define KGDB_BREAKINST		0xe7ffdefe
 #define KGDB_COMPILED_BREAK	0xe7ffdeff
+#endif
 #define CACHE_FLUSH_IS_SAFE	1
 
 #ifndef	__ASSEMBLY__
 
 static inline void arch_kgdb_breakpoint(void)
 {
-	asm(__inst_arm(0xe7ffdeff));
+	asm(__inst_arm_thumb32(KGDB_COMPILED_BREAK, KGDB_COMPILED_BREAK));
 }
 
 extern void kgdb_handle_bus_error(void);

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-02-14 18:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-14  9:59 [PATCH] arm kgdb: fix breakpoint for thumb2 Johannes Stezenbach
2022-02-14 10:13 ` Russell King (Oracle)
2022-02-14 11:05   ` Johannes Stezenbach
2022-02-14 12:56     ` Russell King (Oracle)
2022-02-14 18:33       ` Johannes Stezenbach

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).