Add 16b breakpoint instructions for thumb2 kernel. This repairs the following
error:

  SysRq : DEBUG
  Internal error: Oops - undefined instruction: 0 [#1] SMP THUMB2

...and allows to enter kdb properly under thumb2 kernel for example.

Signed-off-by: Vincent Stehlé <[email protected]>
Cc: Jason Wessel <[email protected]>
Cc: [email protected]

---

Hi,

Here is an RFC on a patch, to repair kdb when running on thumb2 kernel. Could
you please let me know what you think of it?

I have yet to understand whether it is needed to implement both 16b and 32b
breakpoints when in thumb2, as kprobe seems to do. In practice "poking" only
the first 16b of a 32b instruction does work, which makes this version of the
patch kind of useful already.

This has been lightly tested on OMAP5 Cortex-A15 with both thumb2 and ARM
kernel; entering kdb works, breaking in sys_sync works.

Best regards,

V.

 arch/arm/include/asm/kgdb.h | 8 ++++++++
 arch/arm/kernel/kgdb.c      | 6 ++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/kgdb.h b/arch/arm/include/asm/kgdb.h
index 62e3d0a..d3ef9a0 100644
--- a/arch/arm/include/asm/kgdb.h
+++ b/arch/arm/include/asm/kgdb.h
@@ -31,9 +31,17 @@
  * Note to ARM HW designers: Add real trap support like SH && PPC to
  * make our lives much much simpler. :)
  */
+
+#ifdef CONFIG_THUMB2_KERNEL
+#define BREAK_INSTR_SIZE       2
+#define KGDB_BREAKINST         0xdefe
+#define KGDB_COMPILED_BREAK    0xdeff
+#else
 #define BREAK_INSTR_SIZE       4
 #define KGDB_BREAKINST         0xe7ffdefe
 #define KGDB_COMPILED_BREAK    0xe7ffdeff
+#endif
+
 #define CACHE_FLUSH_IS_SAFE    1
 
 #ifndef        __ASSEMBLY__
diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c
index 778c2f7..1b69efb 100644
--- a/arch/arm/kernel/kgdb.c
+++ b/arch/arm/kernel/kgdb.c
@@ -157,14 +157,16 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, 
unsigned int instr)
        return 0;
 }
 
+#define INSTR_MASK     ((1ULL<<(BREAK_INSTR_SIZE * 8))-1)
+
 static struct undef_hook kgdb_brkpt_hook = {
-       .instr_mask             = 0xffffffff,
+       .instr_mask             = INSTR_MASK,
        .instr_val              = KGDB_BREAKINST,
        .fn                     = kgdb_brk_fn
 };
 
 static struct undef_hook kgdb_compiled_brkpt_hook = {
-       .instr_mask             = 0xffffffff,
+       .instr_mask             = INSTR_MASK,
        .instr_val              = KGDB_COMPILED_BREAK,
        .fn                     = kgdb_compiled_brk_fn
 };
-- 
1.8.1.2


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to