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 <js@sig21.net>
Tested-by: Johannes Stezenbach <js@sig21.net>
Fixes: 5cbad0ebf45c ("kgdb: support for ARCH=arm")
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

+28 -8
+28 -8
arch/arm/kernel/kgdb.c
··· 154 154 return 0; 155 155 } 156 156 157 - static struct undef_hook kgdb_brkpt_hook = { 157 + static struct undef_hook kgdb_brkpt_arm_hook = { 158 158 .instr_mask = 0xffffffff, 159 159 .instr_val = KGDB_BREAKINST, 160 - .cpsr_mask = MODE_MASK, 160 + .cpsr_mask = PSR_T_BIT | MODE_MASK, 161 161 .cpsr_val = SVC_MODE, 162 162 .fn = kgdb_brk_fn 163 163 }; 164 164 165 - static struct undef_hook kgdb_compiled_brkpt_hook = { 165 + static struct undef_hook kgdb_brkpt_thumb_hook = { 166 + .instr_mask = 0xffff, 167 + .instr_val = KGDB_BREAKINST & 0xffff, 168 + .cpsr_mask = PSR_T_BIT | MODE_MASK, 169 + .cpsr_val = PSR_T_BIT | SVC_MODE, 170 + .fn = kgdb_brk_fn 171 + }; 172 + 173 + static struct undef_hook kgdb_compiled_brkpt_arm_hook = { 166 174 .instr_mask = 0xffffffff, 167 175 .instr_val = KGDB_COMPILED_BREAK, 168 - .cpsr_mask = MODE_MASK, 176 + .cpsr_mask = PSR_T_BIT | MODE_MASK, 169 177 .cpsr_val = SVC_MODE, 178 + .fn = kgdb_compiled_brk_fn 179 + }; 180 + 181 + static struct undef_hook kgdb_compiled_brkpt_thumb_hook = { 182 + .instr_mask = 0xffff, 183 + .instr_val = KGDB_COMPILED_BREAK & 0xffff, 184 + .cpsr_mask = PSR_T_BIT | MODE_MASK, 185 + .cpsr_val = PSR_T_BIT | SVC_MODE, 170 186 .fn = kgdb_compiled_brk_fn 171 187 }; 172 188 ··· 226 210 if (ret != 0) 227 211 return ret; 228 212 229 - register_undef_hook(&kgdb_brkpt_hook); 230 - register_undef_hook(&kgdb_compiled_brkpt_hook); 213 + register_undef_hook(&kgdb_brkpt_arm_hook); 214 + register_undef_hook(&kgdb_brkpt_thumb_hook); 215 + register_undef_hook(&kgdb_compiled_brkpt_arm_hook); 216 + register_undef_hook(&kgdb_compiled_brkpt_thumb_hook); 231 217 232 218 return 0; 233 219 } ··· 242 224 */ 243 225 void kgdb_arch_exit(void) 244 226 { 245 - unregister_undef_hook(&kgdb_brkpt_hook); 246 - unregister_undef_hook(&kgdb_compiled_brkpt_hook); 227 + unregister_undef_hook(&kgdb_brkpt_arm_hook); 228 + unregister_undef_hook(&kgdb_brkpt_thumb_hook); 229 + unregister_undef_hook(&kgdb_compiled_brkpt_arm_hook); 230 + unregister_undef_hook(&kgdb_compiled_brkpt_thumb_hook); 247 231 unregister_die_notifier(&kgdb_notifier); 248 232 } 249 233