hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/include/linux/kgdb.h
....@@ -16,6 +16,7 @@
1616 #include <linux/linkage.h>
1717 #include <linux/init.h>
1818 #include <linux/atomic.h>
19
+#include <linux/kprobes.h>
1920 #ifdef CONFIG_HAVE_ARCH_KGDB
2021 #include <asm/kgdb.h>
2122 #endif
....@@ -177,22 +178,39 @@
177178 struct pt_regs *regs);
178179
179180 /**
181
+ * kgdb_arch_handle_qxfer_pkt - Handle architecture specific GDB XML
182
+ * packets.
183
+ * @remcom_in_buffer: The buffer of the packet we have read.
184
+ * @remcom_out_buffer: The buffer of %BUFMAX bytes to write a packet into.
185
+ */
186
+
187
+extern void
188
+kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer,
189
+ char *remcom_out_buffer);
190
+
191
+/**
192
+ * kgdb_call_nmi_hook - Call kgdb_nmicallback() on the current CPU
193
+ * @ignored: This parameter is only here to match the prototype.
194
+ *
195
+ * If you're using the default implementation of kgdb_roundup_cpus()
196
+ * this function will be called per CPU. If you don't implement
197
+ * kgdb_call_nmi_hook() a default will be used.
198
+ */
199
+
200
+extern void kgdb_call_nmi_hook(void *ignored);
201
+
202
+/**
180203 * kgdb_roundup_cpus - Get other CPUs into a holding pattern
181
- * @flags: Current IRQ state
182204 *
183205 * On SMP systems, we need to get the attention of the other CPUs
184206 * and get them into a known state. This should do what is needed
185207 * to get the other CPUs to call kgdb_wait(). Note that on some arches,
186
- * the NMI approach is not used for rounding up all the CPUs. For example,
187
- * in case of MIPS, smp_call_function() is used to roundup CPUs. In
188
- * this case, we have to make sure that interrupts are enabled before
189
- * calling smp_call_function(). The argument to this function is
190
- * the flags that will be used when restoring the interrupts. There is
191
- * local_irq_save() call before kgdb_roundup_cpus().
208
+ * the NMI approach is not used for rounding up all the CPUs. Normally
209
+ * those architectures can just not implement this and get the default.
192210 *
193211 * On non-SMP systems, this is not called.
194212 */
195
-extern void kgdb_roundup_cpus(unsigned long flags);
213
+extern void kgdb_roundup_cpus(void);
196214
197215 /**
198216 * kgdb_arch_set_pc - Generic call back to the program counter
....@@ -263,12 +281,14 @@
263281 * @write_char: Pointer to a function that will write one char.
264282 * @flush: Pointer to a function that will flush any pending writes.
265283 * @init: Pointer to a function that will initialize the device.
284
+ * @deinit: Pointer to a function that will deinit the device. Implies that
285
+ * this I/O driver is temporary and expects to be replaced. Called when
286
+ * an I/O driver is replaced or explicitly unregistered.
266287 * @pre_exception: Pointer to a function that will do any prep work for
267288 * the I/O driver.
268289 * @post_exception: Pointer to a function that will do any cleanup work
269290 * for the I/O driver.
270
- * @is_console: 1 if the end device is a console 0 if the I/O device is
271
- * not a console
291
+ * @cons: valid if the I/O device is a console; else NULL.
272292 */
273293 struct kgdb_io {
274294 const char *name;
....@@ -276,12 +296,13 @@
276296 void (*write_char) (u8);
277297 void (*flush) (void);
278298 int (*init) (void);
299
+ void (*deinit) (void);
279300 void (*pre_exception) (void);
280301 void (*post_exception) (void);
281
- int is_console;
302
+ struct console *cons;
282303 };
283304
284
-extern struct kgdb_arch arch_kgdb_ops;
305
+extern const struct kgdb_arch arch_kgdb_ops;
285306
286307 extern unsigned long kgdb_arch_pc(int exception, struct pt_regs *regs);
287308
....@@ -292,7 +313,7 @@
292313 #else
293314 static inline int kgdb_register_nmi_console(void) { return 0; }
294315 static inline int kgdb_unregister_nmi_console(void) { return 0; }
295
-static inline bool kgdb_nmi_poll_knock(void) { return 1; }
316
+static inline bool kgdb_nmi_poll_knock(void) { return true; }
296317 #endif
297318
298319 extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops);
....@@ -305,6 +326,7 @@
305326
306327 extern int kgdb_isremovedbreak(unsigned long addr);
307328 extern void kgdb_schedule_breakpoint(void);
329
+extern int kgdb_has_hit_break(unsigned long addr);
308330
309331 extern int
310332 kgdb_handle_exception(int ex_vector, int signo, int err_code,
....@@ -314,14 +336,35 @@
314336 atomic_t *snd_rdy);
315337 extern void gdbstub_exit(int status);
316338
339
+/*
340
+ * kgdb and kprobes both use the same (kprobe) blocklist (which makes sense
341
+ * given they are both typically hooked up to the same trap meaning on most
342
+ * architectures one cannot be used to debug the other)
343
+ *
344
+ * However on architectures where kprobes is not (yet) implemented we permit
345
+ * breakpoints everywhere rather than blocking everything by default.
346
+ */
347
+static inline bool kgdb_within_blocklist(unsigned long addr)
348
+{
349
+#ifdef CONFIG_KGDB_HONOUR_BLOCKLIST
350
+ return within_kprobe_blacklist(addr);
351
+#else
352
+ return false;
353
+#endif
354
+}
355
+
317356 extern int kgdb_single_step;
318357 extern atomic_t kgdb_active;
319358 #define in_dbg_master() \
320359 (irqs_disabled() && (smp_processor_id() == atomic_read(&kgdb_active)))
321360 extern bool dbg_is_early;
322361 extern void __init dbg_late_init(void);
362
+extern void kgdb_panic(const char *msg);
363
+extern void kgdb_free_init_mem(void);
323364 #else /* ! CONFIG_KGDB */
324365 #define in_dbg_master() (0)
325366 #define dbg_late_init()
367
+static inline void kgdb_panic(const char *msg) {}
368
+static inline void kgdb_free_init_mem(void) { }
326369 #endif /* ! CONFIG_KGDB */
327370 #endif /* _KGDB_H_ */