forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 10ebd8556b7990499c896a550e3d416b444211e6
kernel/arch/arm/kernel/kgdb.c
....@@ -154,33 +154,37 @@
154154 return 0;
155155 }
156156
157
-static struct undef_hook kgdb_brkpt_hook = {
157
+static struct undef_hook kgdb_brkpt_arm_hook = {
158158 .instr_mask = 0xffffffff,
159159 .instr_val = KGDB_BREAKINST,
160
- .cpsr_mask = MODE_MASK,
160
+ .cpsr_mask = PSR_T_BIT | MODE_MASK,
161161 .cpsr_val = SVC_MODE,
162162 .fn = kgdb_brk_fn
163163 };
164164
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 = {
166174 .instr_mask = 0xffffffff,
167175 .instr_val = KGDB_COMPILED_BREAK,
168
- .cpsr_mask = MODE_MASK,
176
+ .cpsr_mask = PSR_T_BIT | MODE_MASK,
169177 .cpsr_val = SVC_MODE,
170178 .fn = kgdb_compiled_brk_fn
171179 };
172180
173
-static void kgdb_call_nmi_hook(void *ignored)
174
-{
175
- kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
176
-}
177
-
178
-void kgdb_roundup_cpus(unsigned long flags)
179
-{
180
- local_irq_enable();
181
- smp_call_function(kgdb_call_nmi_hook, NULL, 0);
182
- local_irq_disable();
183
-}
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,
186
+ .fn = kgdb_compiled_brk_fn
187
+};
184188
185189 static int __kgdb_notify(struct die_args *args, unsigned long cmd)
186190 {
....@@ -222,8 +226,10 @@
222226 if (ret != 0)
223227 return ret;
224228
225
- register_undef_hook(&kgdb_brkpt_hook);
226
- register_undef_hook(&kgdb_compiled_brkpt_hook);
229
+ register_undef_hook(&kgdb_brkpt_arm_hook);
230
+ register_undef_hook(&kgdb_brkpt_thumb_hook);
231
+ register_undef_hook(&kgdb_compiled_brkpt_arm_hook);
232
+ register_undef_hook(&kgdb_compiled_brkpt_thumb_hook);
227233
228234 return 0;
229235 }
....@@ -236,8 +242,10 @@
236242 */
237243 void kgdb_arch_exit(void)
238244 {
239
- unregister_undef_hook(&kgdb_brkpt_hook);
240
- unregister_undef_hook(&kgdb_compiled_brkpt_hook);
245
+ unregister_undef_hook(&kgdb_brkpt_arm_hook);
246
+ unregister_undef_hook(&kgdb_brkpt_thumb_hook);
247
+ unregister_undef_hook(&kgdb_compiled_brkpt_arm_hook);
248
+ unregister_undef_hook(&kgdb_compiled_brkpt_thumb_hook);
241249 unregister_die_notifier(&kgdb_notifier);
242250 }
243251
....@@ -248,7 +256,7 @@
248256 /* patch_text() only supports int-sized breakpoints */
249257 BUILD_BUG_ON(sizeof(int) != BREAK_INSTR_SIZE);
250258
251
- err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
259
+ err = copy_from_kernel_nofault(bpt->saved_instr, (char *)bpt->bpt_addr,
252260 BREAK_INSTR_SIZE);
253261 if (err)
254262 return err;
....@@ -274,7 +282,7 @@
274282 * and we handle the normal undef case within the do_undefinstr
275283 * handler.
276284 */
277
-struct kgdb_arch arch_kgdb_ops = {
285
+const struct kgdb_arch arch_kgdb_ops = {
278286 #ifndef __ARMEB__
279287 .gdb_bpt_instr = {0xfe, 0xde, 0xff, 0xe7}
280288 #else /* ! __ARMEB__ */