ARM: Fix kgdb breakpoint for Thumb2
PATCH 1/1 ARM: Fix kgdb breakpoint for Thumb2
The kgdb code needs to register an undef hook for the Thumb UDF instruction that will fault in order to be functional on Thumb2 platforms.
Reported-by Johannes Stezenbach <[email protected]>
Signed-off-by Russell King (Oracle) <[email protected]>
---
This has the kgdb_arch_exit() problems fixed. Please check and supply tested-by etc attributations. Thanks.
arch/arm/kernel/kgdb.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
arch/arm/kernel/kgdb.c +28 -8
@@ -154,22 +154,38 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int instr)return 0 ; } -static struct undef_hook kgdb_brkpt_hook = { +static struct undef_hook kgdb_brkpt_arm_hook = { .instr_mask =0xffffffff , .instr_val =KGDB_BREAKINST , - .cpsr_mask =MODE_MASK , + .cpsr_mask =PSR_T_BIT |MODE_MASK , .cpsr_val =SVC_MODE , .fn = kgdb_brk_fn }; -static struct undef_hook kgdb_compiled_brkpt_hook = { +static struct undef_hook kgdb_brkpt_thumb_hook = { + .instr_mask =0xffff , + .instr_val =KGDB_BREAKINST &0xffff , + .cpsr_mask =PSR_T_BIT |MODE_MASK , + .cpsr_val =PSR_T_BIT |SVC_MODE , + .fn = kgdb_brk_fn +}; + +static struct undef_hook kgdb_compiled_brkpt_arm_hook = { .instr_mask =0xffffffff , .instr_val =KGDB_COMPILED_BREAK , - .cpsr_mask =MODE_MASK , + .cpsr_mask =PSR_T_BIT |MODE_MASK , .cpsr_val =SVC_MODE , .fn = kgdb_compiled_brk_fn }; +static struct undef_hook kgdb_compiled_brkpt_thumb_hook = { + .instr_mask =0xffff , + .instr_val =KGDB_COMPILED_BREAK &0xffff , + .cpsr_mask =PSR_T_BIT |MODE_MASK , + .cpsr_val =PSR_T_BIT |SVC_MODE , + .fn = kgdb_compiled_brk_fn +}; +static int __kgdb_notify (struct die_args *args,unsigned long cmd) {struct pt_regs *regs = args->regs;
@@ -210,8 +226,10 @@ int kgdb_arch_init(void)if (ret !=0 )return ret; -register_undef_hook (&kgdb_brkpt_hook); -register_undef_hook (&kgdb_compiled_brkpt_hook); +register_undef_hook (&kgdb_brkpt_arm_hook); +register_undef_hook (&kgdb_brkpt_thumb_hook); +register_undef_hook (&kgdb_compiled_brkpt_arm_hook); +register_undef_hook (&kgdb_compiled_brkpt_thumb_hook);return 0 ; }
@@ -224,8 +242,10 @@ int kgdb_arch_init(void)*/ void kgdb_arch_exit (void ) { -unregister_undef_hook (&kgdb_brkpt_hook); -unregister_undef_hook (&kgdb_compiled_brkpt_hook); +unregister_undef_hook (&kgdb_brkpt_arm_hook); +unregister_undef_hook (&kgdb_brkpt_thumb_hook); +unregister_undef_hook (&kgdb_compiled_brkpt_arm_hook); +unregister_undef_hook (&kgdb_compiled_brkpt_thumb_hook);unregister_die_notifier (&kgdb_notifier); }
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Russell King (Oracle)
The kgdb code needs to register an undef hook for the Thumb UDF instruction that will fault in order to be functional on Thumb2 platforms.
Reported-by Johannes Stezenbach <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>---
This has thekgdb_arch_exit()problems fixed. Please check and supply tested-by etc attributations. Thanks.
Compiles cleanly and works.
Tested-by Johannes Stezenbach <[email protected]>
Thanks,
Johannes
Quoted 80 lines
arch/arm/kernel/kgdb.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)arch/arm/kernel/kgdb.c +28
-8@@ -154,22 +154,38 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int instr)return 0 ; } -static struct undef_hook kgdb_brkpt_hook = { +static struct undef_hook kgdb_brkpt_arm_hook = { .instr_mask =0xffffffff , .instr_val =KGDB_BREAKINST , - .cpsr_mask =MODE_MASK , + .cpsr_mask =PSR_T_BIT |MODE_MASK , .cpsr_val =SVC_MODE , .fn = kgdb_brk_fn }; -static struct undef_hook kgdb_compiled_brkpt_hook = { +static struct undef_hook kgdb_brkpt_thumb_hook = { + .instr_mask =0xffff , + .instr_val =KGDB_BREAKINST &0xffff , + .cpsr_mask =PSR_T_BIT |MODE_MASK , + .cpsr_val =PSR_T_BIT |SVC_MODE , + .fn = kgdb_brk_fn +}; + +static struct undef_hook kgdb_compiled_brkpt_arm_hook = { .instr_mask =0xffffffff , .instr_val =KGDB_COMPILED_BREAK , - .cpsr_mask =MODE_MASK , + .cpsr_mask =PSR_T_BIT |MODE_MASK , .cpsr_val =SVC_MODE , .fn = kgdb_compiled_brk_fn }; +static struct undef_hook kgdb_compiled_brkpt_thumb_hook = { + .instr_mask =0xffff , + .instr_val =KGDB_COMPILED_BREAK &0xffff , + .cpsr_mask =PSR_T_BIT |MODE_MASK , + .cpsr_val =PSR_T_BIT |SVC_MODE , + .fn = kgdb_compiled_brk_fn +}; +static int __kgdb_notify (struct die_args *args,unsigned long cmd) {struct pt_regs *regs = args->regs;@@ -210,8 +226,10 @@ int kgdb_arch_init(void)if (ret !=0 )return ret; -register_undef_hook (&kgdb_brkpt_hook); -register_undef_hook (&kgdb_compiled_brkpt_hook); +register_undef_hook (&kgdb_brkpt_arm_hook); +register_undef_hook (&kgdb_brkpt_thumb_hook); +register_undef_hook (&kgdb_compiled_brkpt_arm_hook); +register_undef_hook (&kgdb_compiled_brkpt_thumb_hook);return 0 ; }@@ -224,8 +242,10 @@ int kgdb_arch_init(void)*/ void kgdb_arch_exit (void ) { -unregister_undef_hook (&kgdb_brkpt_hook); -unregister_undef_hook (&kgdb_compiled_brkpt_hook); +unregister_undef_hook (&kgdb_brkpt_arm_hook); +unregister_undef_hook (&kgdb_brkpt_thumb_hook); +unregister_undef_hook (&kgdb_compiled_brkpt_arm_hook); +unregister_undef_hook (&kgdb_compiled_brkpt_thumb_hook);unregister_die_notifier (&kgdb_notifier); }Signature · 1 line
2.30.2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel