Skip to contentSkip to conversation

kgdb-light-v10: proposed fixes

PATCH New Jason Wessel 1 participant 8 messages Feb 15, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover kgdb-light-v10: proposed fixes

These patches are for kgdb-light-v10 to address some regressions, and further the RFC against kgdb core as a module.

All of these patches are up for consideration to be collapsed into the kgdb-light tree for an upstream merge pending review. The kgdb core as a module patch will be kept separate because the kernel.org community may or may not object to exposing too many low level exports.

The following changes since commit 2680c15446821264fa3c2278e584974f2feb97b4:
Jason Wessel (1):

        Merge branch 'master' of git://git.kernel.org/.../mingo/linux-2.6-kgdb

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb.git for_ingo

Jan Kiszka (1):
kgdb: build core and arch pieces as a kernel module

Jason Wessel (6):
kgdb: fix kgdboc dynamic module configuration
kgdb: fix NMI hangs
kgdb: clocksource watchdog
kgdb: print breakpoint removed on exception
kgdb: x86 HW breakpoints
kgdb: move the kgdb core and arch implementation

 arch/x86/kernel/Makefile               |    4 +-
 arch/x86/kernel/{kgdb.c => kgdb-x86.c} |  167 +++++++++++++++++++++++++++++---
 arch/x86/kernel/reboot.c               |    1 +
 arch/x86/kernel/setup64.c              |   14 +++
 arch/x86/kernel/smp_32.c               |    6 +
 arch/x86/kernel/smp_64.c               |    5 +
 arch/x86/kernel/traps_32.c             |    2 +
 arch/x86/kernel/traps_64.c             |    2 +
 drivers/serial/kgdboc.c                |    7 +-
 include/asm-x86/kdebug.h               |    1 +
 include/asm-x86/smp_32.h               |    5 +
 include/asm-x86/smp_64.h               |    4 +
 include/linux/clocksource.h            |    1 +
 kernel/Makefile                        |    1 -
 kernel/sched.c                         |    1 +
 kernel/time/clocksource.c              |   13 +++
 lib/Kconfig.kgdb                       |    2 +-
 {kernel => lib}/kgdb.c                 |   19 +++-
 18 files changed, 234 insertions(+), 21 deletions(-)
 rename arch/x86/kernel/{kgdb.c => kgdb-x86.c} (78%)
 rename {kernel => lib}/kgdb.c (99%)
#1 lore raw

PATCH 1/7 kgdb-light-v10: fix kgdboc dynamic module configuration

Fix the run time configuration of kgdboc such that it does not default to 9600 baud if you use the "echo" command to configure the sysfs module paramater.

---
 drivers/serial/kgdboc.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/serial/kgdboc.c +6 -1
index 3418307..9cf0332 100644
@@ -106,7 +106,9 @@ static void kgdboc_put_char(u8 chr)
 
 static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
 {
-	if (strlen(kmessage) >= MAX_CONFIG_LEN) {
+	int len = strlen(kmessage);
+
+	if (len >= MAX_CONFIG_LEN) {
 		printk(KERN_ERR "kgdboc: config string too long\n");
 		return -ENOSPC;
 	}
@@ -125,6 +127,9 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
 	}
 
 	strcpy(config, kmessage);
+	/* Chop out \n char as a result of echo */
+	if (config[len - 1] == '\n')
+		config[len - 1] = '\0';
 
 	if (configured == 1)
 		cleanup_kgdboc();
Signature · 1 line
1.5.4
#2 lore raw

PATCH 2/7 kgdb-light-v10: fix NMI hangs

This patch fixes the hang regression with kgdb when the NMI interrupt comes in while the master core is returning from an exception.

Adjust the NMI logic such that KGDB will not stop NMI exceptions from occurring by in general returning NOTIFY_DONE. It is not possible to distinguish the debug NMI sync vs the normal NMI apic interrupt so kgdb needs to catch the unknown NMI if it the debugger was previously active on one of the cpus.

---
 arch/x86/kernel/kgdb.c     |   18 +++++++++++++++---
 arch/x86/kernel/traps_32.c |    2 ++
 arch/x86/kernel/traps_64.c |    2 ++
 include/asm-x86/kdebug.h   |    1 +
 4 files changed, 20 insertions(+), 3 deletions(-)
arch/x86/kernel/kgdb.c +15 -3
index bc762d8..83d97bb 100644
@@ -41,6 +41,7 @@
 #include <linux/kgdb.h>
 #include <linux/init.h>
 #include <linux/smp.h>
+#include <linux/nmi.h>
 
 #include <asm/apicdef.h>
 #include <asm/system.h>
@@ -290,6 +291,8 @@ single_step_cont(struct pt_regs *regs, struct die_args *args)
 	return NOTIFY_STOP;
 }
 
+static int was_in_debug_nmi[NR_CPUS];
+
 static int __kgdb_notify(struct die_args *args, unsigned long cmd)
 {
 	struct pt_regs *regs = args->regs;
@@ -299,15 +302,24 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
 		if (atomic_read(&kgdb_active) != -1) {
 			/* KGDB CPU roundup */
 			kgdb_nmicallback(raw_smp_processor_id(), regs);
+			was_in_debug_nmi[raw_smp_processor_id()] = 1;
+			touch_nmi_watchdog();
 			return NOTIFY_STOP;
 		}
 		return NOTIFY_DONE;
 
 	case DIE_NMI_IPI:
 		if (atomic_read(&kgdb_active) != -1) {
-			/* KGDB CPU roundup: */
-			if (kgdb_nmicallback(raw_smp_processor_id(), regs))
-				return NOTIFY_DONE;
+			/* KGDB CPU roundup */
+			kgdb_nmicallback(raw_smp_processor_id(), regs);
+			was_in_debug_nmi[raw_smp_processor_id()] = 1;
+			touch_nmi_watchdog();
+		}
+		return NOTIFY_DONE;
+
+	case DIE_NMIUNKNOWN:
+		if (was_in_debug_nmi[raw_smp_processor_id()]) {
+			was_in_debug_nmi[raw_smp_processor_id()] = 0;
 			return NOTIFY_STOP;
 		}
 		return NOTIFY_DONE;
arch/x86/kernel/traps_32.c +2 -0
index b22c01e..c5421f3 100644
@@ -708,6 +708,8 @@ io_check_error(unsigned char reason, struct pt_regs * regs)
 static __kprobes void
 unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
 {
+	if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
+		return;
 #ifdef CONFIG_MCA
 	/* Might actually be able to figure out what the guilty party
 	* is. */
arch/x86/kernel/traps_64.c +2 -0
index efc66df..de786e0 100644
@@ -806,6 +806,8 @@ io_check_error(unsigned char reason, struct pt_regs * regs)
 static __kprobes void
 unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
 {
+	if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
+		return;
 	printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
 		reason);
 	printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
include/asm-x86/kdebug.h +1 -0
index dd442a1..ae687ce 100644
@@ -20,6 +20,7 @@ enum die_val {
 	DIE_CALL,
 	DIE_NMI_IPI,
 	DIE_PAGE_FAULT,
+	DIE_NMIUNKNOWN,
 };
 
 extern void printk_address(unsigned long address, int reliable);
Signature · 1 line
1.5.4
#3 lore raw

PATCH 3/7 kgdb-light-v10: clocksource watchdog

In order to not trip the clocksource watchdog, kgdb must touch the clocksource watchdog on the return to normal system run state.

---
 include/linux/clocksource.h |    1 +
 kernel/kgdb.c               |    4 ++++
 kernel/time/clocksource.c   |   12 ++++++++++++
 3 files changed, 17 insertions(+), 0 deletions(-)
include/linux/clocksource.h +1 -0
index 85778a4..3509447 100644
@@ -216,6 +216,7 @@ static inline void clocksource_calculate_interval(struct clocksource *c,
 /* used to install a new clocksource */
 extern int clocksource_register(struct clocksource*);
 extern void clocksource_unregister(struct clocksource*);
+extern void clocksource_touch_watchdog(void);
 extern struct clocksource* clocksource_get_next(void);
 extern void clocksource_change_rating(struct clocksource *cs, int rating);
 extern void clocksource_resume(void);
kernel/kgdb.c +4 -0
index 21d30cf..9d42e0a 100644
@@ -28,6 +28,7 @@
  * kind, whether express or implied.
  */
 #include <linux/pid_namespace.h>
+#include <linux/clocksource.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/console.h>
@@ -556,6 +557,7 @@ static void kgdb_wait(struct pt_regs *regs)
 
 	/* Signal the primary CPU that we are done: */
 	atomic_set(&cpu_in_kgdb[cpu], 0);
+	clocksource_touch_watchdog();
 	local_irq_restore(flags);
 }
 #endif
@@ -1378,6 +1380,7 @@ acquirelock:
 	    atomic_read(&kgdb_cpu_doing_single_step) != cpu) {
 
 		atomic_set(&kgdb_active, -1);
+		clocksource_touch_watchdog();
 		local_irq_restore(flags);
 
 		goto acquirelock;
@@ -1469,6 +1472,7 @@ acquirelock:
 kgdb_restore:
 	/* Free kgdb_active */
 	atomic_set(&kgdb_active, -1);
+	clocksource_touch_watchdog();
 	local_irq_restore(flags);
 
 	return error;
kernel/time/clocksource.c +12 -0
index 548c436..ace23d3 100644
@@ -228,6 +228,18 @@ void clocksource_resume(void)
 }
 
 /**
+ * clocksource_touch_watchdog - Update watchdog
+ *
+ * Update the watchdog after exception contexts such as kgdb so as not
+ * to incorrectly trip the watchdog.
+ *
+ */
+void clocksource_touch_watchdog(void)
+{
+	clocksource_resume_watchdog();
+}
+
+/**
  * clocksource_get_next - Returns the selected clocksource
  *
  */
Signature · 1 line
1.5.4
#4 lore raw

PATCH 4/7 kgdb-light-v10: print breakpoint removed on exception

If kgdb does remove a breakpoint that had a problem on the recursion check, it should also print the address of the breakpoint.

---
 kernel/kgdb.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/kgdb.c +2 -1
index 9d42e0a..b516de0 100644
@@ -1309,7 +1309,8 @@ static int kgdb_reenter_check(struct kgdb_state *ks)
 		exception_level = 0;
 		kgdb_skipexception(ks->ex_vector, ks->linux_regs);
 		kgdb_activate_sw_breakpoints();
-		printk(KERN_CRIT "KGDB: re-enter error: breakpoint removed\n");
+		printk(KERN_CRIT "KGDB: re-enter error: breakpoint removed %lx\n",
+			addr);
 		WARN_ON_ONCE(1);
 
 		return 1;
Signature · 1 line
1.5.4
#5 lore raw

PATCH 5/7 kgdb-light-v10: x86 HW breakpoints

Add HW breakpoints into the arch specific portion of x86 kgdb. In the current x86 kernel.org kernels HW breakpoints are changed out in lazy fashion because there is no infrastructure around changing them when changing to a kernel task or entering the kernel mode via a system call. This lazy approach means that if a user process uses HW breakpoints the kgdb will loose out. This is an acceptable trade off because the developer debugging the kernel is assumed to know what is going on system wide and would be aware of this trade off.

There is a minor bug fix to the kgdb core so as to correctly call the hw breakpoint functions with a valid value from the enum.

There is also a minor change to the x86_64 startup code when using early HW breakpoints. When the debugger is connected, the cpu startup code must not zero out the HW breakpoint registers or you cannot hit the breakpoints you are interested in, in the first place.

---
 arch/x86/kernel/kgdb.c    |  138 +++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/setup64.c |   14 +++++
 kernel/kgdb.c             |    4 +-
 3 files changed, 154 insertions(+), 2 deletions(-)
arch/x86/kernel/kgdb.c +138 -0
index 83d97bb..88bfa45 100644
@@ -182,6 +182,122 @@ void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs)
 #endif
 }
 
+static struct hw_breakpoint {
+	unsigned		enabled;
+	unsigned		type;
+	unsigned		len;
+	unsigned long		addr;
+} breakinfo[4];
+
+static void kgdb_correct_hw_break(void)
+{
+	unsigned long dr7;
+	int correctit = 0;
+	int breakbit;
+	int breakno;
+
+	get_debugreg(dr7, 7);
+	for (breakno = 0; breakno < 4; breakno++) {
+		breakbit = 2 << (breakno << 1);
+		if (!(dr7 & breakbit) && breakinfo[breakno].enabled) {
+			correctit = 1;
+			dr7 |= breakbit;
+			dr7 &= ~(0xf0000 << (breakno << 2));
+			dr7 |= ((breakinfo[breakno].len << 2) |
+				 breakinfo[breakno].type) <<
+			       ((breakno << 2) + 16);
+			if (breakno >= 0 && breakno <= 3)
+				set_debugreg(breakinfo[breakno].addr, breakno);
+
+		} else {
+			if ((dr7 & breakbit) && !breakinfo[breakno].enabled) {
+				correctit = 1;
+				dr7 &= ~breakbit;
+				dr7 &= ~(0xf0000 << (breakno << 2));
+			}
+		}
+	}
+	if (correctit)
+		set_debugreg(dr7, 7);
+}
+
+static int
+kgdb_remove_hw_break(unsigned long addr, int len, enum kgdb_bptype bptype)
+{
+	int i;
+
+	for (i = 0; i < 4; i++)
+		if (breakinfo[i].addr == addr && breakinfo[i].enabled)
+			break;
+	if (i == 4)
+		return -1;
+
+	breakinfo[i].enabled = 0;
+
+	return 0;
+}
+
+static void kgdb_remove_all_hw_break(void)
+{
+	int i;
+
+	for (i = 0; i < 4; i++)
+		memset(&breakinfo[i], 0, sizeof(struct hw_breakpoint));
+}
+
+static int
+kgdb_set_hw_break(unsigned long addr, int len, enum kgdb_bptype bptype)
+{
+	unsigned type;
+	int i;
+
+	for (i = 0; i < 4; i++)
+		if (!breakinfo[i].enabled)
+			break;
+	if (i == 4)
+		return -1;
+
+	switch (bptype) {
+	case BP_HARDWARE_BREAKPOINT:
+		type = 0;
+		len  = 1;
+		break;
+	case BP_WRITE_WATCHPOINT:
+		type = 1;
+		break;
+	case BP_ACCESS_WATCHPOINT:
+		type = 3;
+		break;
+	default:
+		return -1;
+	}
+
+	if (len == 1 || len == 2 || len == 4)
+		breakinfo[i].len  = len - 1;
+	else
+		return -1;
+
+	breakinfo[i].enabled = 1;
+	breakinfo[i].addr = addr;
+	breakinfo[i].type = type;
+
+	return 0;
+}
+
+/**
+ *	kgdb_disable_hw_debug - Disable hardware debugging while we in kgdb.
+ *	@regs: Current &struct pt_regs.
+ *
+ *	This function will be called if the particular architecture must
+ *	disable hardware debugging while it is processing gdb packets or
+ *	handling exception.
+ */
+void kgdb_disable_hw_debug(struct pt_regs *regs)
+{
+	/* Disable hardware debugging while we are in kgdb: */
+	set_debugreg(0UL, 7);
+}
+
 /**
  *	kgdb_post_primary_code - Save error vector/code numbers.
  *	@regs: Original pt_regs.
@@ -243,6 +359,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
 			       struct pt_regs *linux_regs)
 {
 	unsigned long addr;
+	unsigned long dr6;
 	char *ptr;
 	int newPC;
 
@@ -269,6 +386,22 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
 			}
 		}
 
+		get_debugreg(dr6, 6);
+		if (!(dr6 & 0x4000)) {
+			int breakno;
+
+			for (breakno = 0; breakno < 4; breakno++) {
+				if (dr6 & (1 << breakno) &&
+				    breakinfo[breakno].type == 0) {
+					/* Set restore flag: */
+					linux_regs->flags |= X86_EFLAGS_RF;
+					break;
+				}
+			}
+		}
+		set_debugreg(0UL, 6);
+		kgdb_correct_hw_break();
+
 		return 0;
 	}
 
@@ -426,4 +559,9 @@ unsigned long kgdb_arch_pc(int exception, struct pt_regs *regs)
 struct kgdb_arch arch_kgdb_ops = {
 	/* Breakpoint instruction: */
 	.gdb_bpt_instr		= { 0xcc },
+	.flags			= KGDB_HW_BREAKPOINT,
+	.set_hw_breakpoint	= kgdb_set_hw_break,
+	.remove_hw_breakpoint	= kgdb_remove_hw_break,
+	.remove_all_hw_break	= kgdb_remove_all_hw_break,
+	.correct_hw_break	= kgdb_correct_hw_break,
 };
arch/x86/kernel/setup64.c +14 -0
index 309366f..d5a146a 100644
@@ -11,6 +11,7 @@
 #include <linux/bootmem.h>
 #include <linux/bitops.h>
 #include <linux/module.h>
+#include <linux/kgdb.h>
 #include <asm/pda.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
@@ -325,6 +326,15 @@ void __cpuinit cpu_init (void)
 	load_TR_desc();
 	load_LDT(&init_mm.context);
 
+#ifdef CONFIG_KGDB
+	/*
+	 * If the kgdb is connected no debug regs should be altered.  This
+	 * is only applicable when KGDB and a KGDB I/O module are built
+	 * into the kernel and you are using early debugging with
+	 * kgdbwait. KGDB will control the kernel HW breakpoint registers.
+	 */
+	if (kgdb_connected) {
+#endif
 	/*
 	 * Clear all 6 debug registers:
 	 */
@@ -335,6 +345,10 @@ void __cpuinit cpu_init (void)
 	set_debugreg(0UL, 3);
 	set_debugreg(0UL, 6);
 	set_debugreg(0UL, 7);
+#ifdef CONFIG_KGDB
+	/* If the kgdb is connected no debug regs should be altered. */
+	}
+#endif
 
 	fpu_init(); 
 
kernel/kgdb.c +2 -2
index b516de0..a453764 100644
@@ -1121,10 +1121,10 @@ static void gdb_cmd_break(struct kgdb_state *ks)
 		error = kgdb_remove_sw_break(addr);
 	else if (remcom_in_buffer[0] == 'Z')
 		error = arch_kgdb_ops.set_hw_breakpoint(addr,
-			(int)length, *bpt_type);
+			(int)length, *bpt_type - '0');
 	else if (remcom_in_buffer[0] == 'z')
 		error = arch_kgdb_ops.remove_hw_breakpoint(addr,
-			(int) length, *bpt_type);
+			(int) length, *bpt_type - '0');
 
 	if (error == 0)
 		strcpy(remcom_out_buffer, "OK");
Signature · 1 line
1.5.4
#6 lore raw

PATCH 6/7 kgdb-light-v10: move the kgdb core and arch implementation

Simply relocate the arch specific and kgdb core implementation files so as to build as a module in a future patch.

---
 arch/x86/kernel/Makefile   |    4 +-
 arch/x86/kernel/kgdb-x86.c |  567 +++++++++++++++
 arch/x86/kernel/kgdb.c     |  567 ---------------
 kernel/Makefile            |    1 -
 kernel/kgdb.c              | 1680 --------------------------------------------
 lib/kgdb.c                 | 1680 ++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 2250 insertions(+), 2249 deletions(-)
 create mode 100644 arch/x86/kernel/kgdb-x86.c
 delete mode 100644 arch/x86/kernel/kgdb.c
 delete mode 100644 kernel/kgdb.c
 create mode 100644 lib/kgdb.c
arch/x86/kernel/Makefile +3 -1
index 4cd39cd..2e733b1 100644
@@ -58,7 +58,6 @@ obj-$(CONFIG_MODULES)		+= module_$(BITS).o
 obj-$(CONFIG_ACPI_SRAT) 	+= srat_32.o
 obj-$(CONFIG_EFI) 		+= efi.o efi_$(BITS).o efi_stub_$(BITS).o
 obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault_32.o
-obj-$(CONFIG_KGDB)		+= kgdb.o
 obj-$(CONFIG_VM86)		+= vm86_32.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 
@@ -79,6 +78,9 @@ endif
 obj-$(CONFIG_SCx200)		+= scx200.o
 scx200-y			+= scx200_32.o
 
+kgdb-objs			:= ../../../lib/kgdb.o kgdb-x86.o
+obj-$(CONFIG_KGDB)		+= kgdb.o
+
 ###
 # 64 bit specific files
 ifeq ($(CONFIG_X86_64),y)
arch/x86/kernel/kgdb-x86.c new file +567 -0

567 lines not on this page · raw message

arch/x86/kernel/kgdb.c deleted +0 -567

567 lines not on this page · raw message

kernel/Makefile +0 -1
index 05c8003..6c584c5 100644
@@ -53,7 +53,6 @@ obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
 obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
 obj-$(CONFIG_AUDIT_TREE) += audit_tree.o
 obj-$(CONFIG_KPROBES) += kprobes.o
-obj-$(CONFIG_KGDB) += kgdb.o
 obj-$(CONFIG_DETECT_SOFTLOCKUP) += softlockup.o
 obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
 obj-$(CONFIG_SECCOMP) += seccomp.o
kernel/kgdb.c deleted +0 -1680

1,680 lines not on this page · raw message

lib/kgdb.c new file +1680 -0

163 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.4

Part of the diff is not shown here. View the raw message.

#7 lore raw

PATCH 7/7 kgdb-light-v10: build core and arch pieces as a kernel module

From: Jan Kiszka <[email protected]>

The patch nicely demonstrates what deeper dependencies on kernel services currently exist in kgdb-light. The following symbols were unresolvable:

o send_IPI_allbutself(APIC_DM_NMI)
This required a new exported function so as not to export really low level APIC functions and variables The new one is: smp_debugger_sync
o machine_emergency_restart - for implementing "R0" gdb packet
o idle_task - kgdb tells the per-cpu idle tasks apart
o clocksource_touch_watchdog - obvious as to what it does

For simplicity reasons I just gpl-exported all of them. The result is a fully modular kgdb that may help to reduce concerns regarding its intrusiveness.

---
 arch/x86/kernel/kgdb-x86.c |   11 ++---------
 arch/x86/kernel/reboot.c   |    1 +
 arch/x86/kernel/smp_32.c   |    6 ++++++
 arch/x86/kernel/smp_64.c   |    5 +++++
 include/asm-x86/smp_32.h   |    5 +++++
 include/asm-x86/smp_64.h   |    4 ++++
 kernel/sched.c             |    1 +
 kernel/time/clocksource.c  |    1 +
 lib/Kconfig.kgdb           |    2 +-
 lib/kgdb.c                 |    8 ++++++--
 10 files changed, 32 insertions(+), 12 deletions(-)
arch/x86/kernel/kgdb-x86.c +2 -9
index 88bfa45..c36740c 100644
@@ -46,12 +46,6 @@
 #include <asm/apicdef.h>
 #include <asm/system.h>
 
-#ifdef CONFIG_X86_32
-# include <mach_ipi.h>
-#else
-# include <asm/mach_apic.h>
-#endif
-
 /*
  * Put the error code here just in case the user cares:
  */
@@ -315,7 +309,6 @@ void kgdb_post_primary_code(struct pt_regs *regs, int e_vector, int err_code)
 	gdb_x86errcode = err_code;
 }
 
-#ifdef CONFIG_SMP
 /**
  *	kgdb_roundup_cpus - Get other CPUs into a holding pattern
  *	@flags: Current IRQ state
@@ -334,9 +327,8 @@ void kgdb_post_primary_code(struct pt_regs *regs, int e_vector, int err_code)
  */
 void kgdb_roundup_cpus(unsigned long flags)
 {
-	send_IPI_allbutself(APIC_DM_NMI);
+	smp_debugger_sync();
 }
-#endif
 
 /**
  *	kgdb_arch_handle_exception - Handle architecture specific GDB packets.
@@ -565,3 +557,4 @@ struct kgdb_arch arch_kgdb_ops = {
 	.remove_all_hw_break	= kgdb_remove_all_hw_break,
 	.correct_hw_break	= kgdb_correct_hw_break,
 };
+
arch/x86/kernel/reboot.c +1 -0
index 5818dc2..66d7c27 100644
@@ -375,6 +375,7 @@ void machine_emergency_restart(void)
 		}
 	}
 }
+EXPORT_SYMBOL_GPL(machine_emergency_restart);
 
 void machine_shutdown(void)
 {
arch/x86/kernel/smp_32.c +6 -0
index dc0cde9..2f35238 100644
@@ -710,3 +710,9 @@ struct smp_ops smp_ops = {
 	.smp_call_function_mask = native_smp_call_function_mask,
 };
 EXPORT_SYMBOL_GPL(smp_ops);
+
+void smp_debugger_sync(void)
+{
+	send_IPI_allbutself(APIC_DM_NMI);
+}
+EXPORT_SYMBOL_GPL(smp_debugger_sync);
arch/x86/kernel/smp_64.c +5 -0
index 2fd74b0..f5f419f 100644
@@ -528,3 +528,8 @@ asmlinkage void smp_call_function_interrupt(void)
 	}
 }
 
+void smp_debugger_sync(void)
+{
+	send_IPI_allbutself(APIC_DM_NMI);
+}
+EXPORT_SYMBOL_GPL(smp_debugger_sync);
include/asm-x86/smp_32.h +5 -0
index 56152e3..19a1aa7 100644
@@ -127,11 +127,16 @@ static inline int num_booting_cpus(void)
 	return cpus_weight(cpu_callout_map);
 }
 
+extern void smp_debugger_sync(void);
+
 #else /* CONFIG_SMP */
 
 #define safe_smp_processor_id()		0
 #define cpu_physical_id(cpu)		boot_cpu_physical_apicid
 
+static inline void smp_debugger_sync(void)
+{}
+
 #endif /* !CONFIG_SMP */
 
 #ifdef CONFIG_X86_LOCAL_APIC
include/asm-x86/smp_64.h +4 -0
index e0a7551..c52f46a 100644
@@ -74,6 +74,7 @@ static inline int num_booting_cpus(void)
 }
 
 extern void smp_send_reschedule(int cpu);
+extern void smp_debugger_sync(void);
 
 #else /* CONFIG_SMP */
 
@@ -81,6 +82,9 @@ extern unsigned int boot_cpu_id;
 #define cpu_physical_id(cpu)	boot_cpu_id
 #define stack_smp_processor_id() 0
 
+static inline void smp_debugger_sync(void)
+{}
+
 #endif /* !CONFIG_SMP */
 
 #define safe_smp_processor_id()		smp_processor_id()
kernel/sched.c +1 -0
index 3eedd52..e2ffff4 100644
@@ -4463,6 +4463,7 @@ struct task_struct *idle_task(int cpu)
 {
 	return cpu_rq(cpu)->idle;
 }
+EXPORT_SYMBOL_GPL(idle_task);
 
 /**
  * find_process_by_pid - find a process with a matching PID value.
kernel/time/clocksource.c +1 -0
index ace23d3..e83dc5d 100644
@@ -238,6 +238,7 @@ void clocksource_touch_watchdog(void)
 {
 	clocksource_resume_watchdog();
 }
+EXPORT_SYMBOL_GPL(clocksource_touch_watchdog);
 
 /**
  * clocksource_get_next - Returns the selected clocksource
lib/Kconfig.kgdb +1 -1
index 9631ba3..413e3b8 100644
@@ -1,6 +1,6 @@
 
 menuconfig KGDB
-	bool "KGDB: kernel debugging with remote gdb"
+	tristate "KGDB: kernel debugging with remote gdb"
 	select FRAME_POINTER
 	depends on HAVE_ARCH_KGDB
 	depends on DEBUG_KERNEL && EXPERIMENTAL
lib/kgdb.c +6 -2
index a453764..7a39853 100644
@@ -91,13 +91,14 @@ static int kgdb_con_registered;
 /* determine if kgdb console output should be used */
 static int kgdb_use_con;
 
+#ifdef CONFIG_KGDB
 static int __init opt_kgdb_con(char *str)
 {
 	kgdb_use_con = 1;
 	return 0;
 }
-
 early_param("kgdbcon", opt_kgdb_con);
+#endif
 
 module_param(kgdb_use_con, int, 0644);
 
@@ -1667,6 +1668,7 @@ void kgdb_breakpoint(void)
 }
 EXPORT_SYMBOL_GPL(kgdb_breakpoint);
 
+#ifdef CONFIG_KGDB
 static int __init opt_kgdb_wait(char *str)
 {
 	kgdb_break_asap = 1;
@@ -1676,5 +1678,7 @@ static int __init opt_kgdb_wait(char *str)
 
 	return 0;
 }
-
 early_param("kgdbwait", opt_kgdb_wait);
+#endif
+
+MODULE_LICENSE("GPL");
Signature · 1 line
1.5.4