hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/arch/powerpc/kernel/kgdb.c
....@@ -26,6 +26,7 @@
2626 #include <asm/debug.h>
2727 #include <asm/code-patching.h>
2828 #include <linux/slab.h>
29
+#include <asm/inst.h>
2930
3031 /*
3132 * This table contains the mapping between PowerPC hardware trap types, and
....@@ -117,14 +118,14 @@
117118 return kgdb_isremovedbreak(regs->nip);
118119 }
119120
120
-static int kgdb_call_nmi_hook(struct pt_regs *regs)
121
+static int kgdb_debugger_ipi(struct pt_regs *regs)
121122 {
122123 kgdb_nmicallback(raw_smp_processor_id(), regs);
123124 return 0;
124125 }
125126
126127 #ifdef CONFIG_SMP
127
-void kgdb_roundup_cpus(unsigned long flags)
128
+void kgdb_roundup_cpus(void)
128129 {
129130 smp_send_debugger_break();
130131 }
....@@ -151,40 +152,12 @@
151152 return 1;
152153 }
153154
154
-static DEFINE_PER_CPU(struct thread_info, kgdb_thread_info);
155155 static int kgdb_singlestep(struct pt_regs *regs)
156156 {
157
- struct thread_info *thread_info, *exception_thread_info;
158
- struct thread_info *backup_current_thread_info =
159
- this_cpu_ptr(&kgdb_thread_info);
160
-
161157 if (user_mode(regs))
162158 return 0;
163159
164
- /*
165
- * On Book E and perhaps other processors, singlestep is handled on
166
- * the critical exception stack. This causes current_thread_info()
167
- * to fail, since it it locates the thread_info by masking off
168
- * the low bits of the current stack pointer. We work around
169
- * this issue by copying the thread_info from the kernel stack
170
- * before calling kgdb_handle_exception, and copying it back
171
- * afterwards. On most processors the copy is avoided since
172
- * exception_thread_info == thread_info.
173
- */
174
- thread_info = (struct thread_info *)(regs->gpr[1] & ~(THREAD_SIZE-1));
175
- exception_thread_info = current_thread_info();
176
-
177
- if (thread_info != exception_thread_info) {
178
- /* Save the original current_thread_info. */
179
- memcpy(backup_current_thread_info, exception_thread_info, sizeof *thread_info);
180
- memcpy(exception_thread_info, thread_info, sizeof *thread_info);
181
- }
182
-
183160 kgdb_handle_exception(0, SIGTRAP, 0, regs);
184
-
185
- if (thread_info != exception_thread_info)
186
- /* Restore current_thread_info lastly. */
187
- memcpy(exception_thread_info, backup_current_thread_info, sizeof *thread_info);
188161
189162 return 1;
190163 }
....@@ -446,13 +419,13 @@
446419 {
447420 int err;
448421 unsigned int instr;
449
- unsigned int *addr = (unsigned int *)bpt->bpt_addr;
422
+ struct ppc_inst *addr = (struct ppc_inst *)bpt->bpt_addr;
450423
451
- err = probe_kernel_address(addr, instr);
424
+ err = get_kernel_nofault(instr, (unsigned *) addr);
452425 if (err)
453426 return err;
454427
455
- err = patch_instruction(addr, BREAK_INSTR);
428
+ err = patch_instruction(addr, ppc_inst(BREAK_INSTR));
456429 if (err)
457430 return -EFAULT;
458431
....@@ -465,9 +438,9 @@
465438 {
466439 int err;
467440 unsigned int instr = *(unsigned int *)bpt->saved_instr;
468
- unsigned int *addr = (unsigned int *)bpt->bpt_addr;
441
+ struct ppc_inst *addr = (struct ppc_inst *)bpt->bpt_addr;
469442
470
- err = patch_instruction(addr, instr);
443
+ err = patch_instruction(addr, ppc_inst(instr));
471444 if (err)
472445 return -EFAULT;
473446
....@@ -477,7 +450,7 @@
477450 /*
478451 * Global data
479452 */
480
-struct kgdb_arch arch_kgdb_ops;
453
+const struct kgdb_arch arch_kgdb_ops;
481454
482455 static int kgdb_not_implemented(struct pt_regs *regs)
483456 {
....@@ -502,7 +475,7 @@
502475 old__debugger_break_match = __debugger_break_match;
503476 old__debugger_fault_handler = __debugger_fault_handler;
504477
505
- __debugger_ipi = kgdb_call_nmi_hook;
478
+ __debugger_ipi = kgdb_debugger_ipi;
506479 __debugger = kgdb_debugger;
507480 __debugger_bpt = kgdb_handle_breakpoint;
508481 __debugger_sstep = kgdb_singlestep;