Konstantin Baydarov (on Fri, 18 May 2007 18:40:50 +0400) wrote:
>  KDB early doesn't work. Can't get kdb console during boot.
>Investigations:
>  KDB tries to stop kernel very early (in star_kernel() function) executing 
> KDB_ENTER().
>  To stop kernel kdb have to register trap kdb_call() in IDT before 
> KDB_ENTER() call.
>  But KDB set gate traps later using initcall.
>How Solved:
>  Patch set KDBENTER_VECTOR trap gate before KDB_ENTER call - in the end of 
> init_IRQ().
>  I set KDBENTER_VECTOR trap gate in init_IRQ, not in init_traps(), because in 
> SMP
>  case init_IRQ() can reset KDBENTER_VECTOR trap gate to default handler.
>  I set KDB_VECTOR SMP trap gate in smp_intr_init() - also before KDB_ENTER() 
> call.
>  Another issue: kernel can reset KDB trap gates in setup_IO_APIC_irqs(),
>  so I've added extra check in setup_IO_APIC_irqs() to prevent KDB trap gates 
> reset.

The patch below is a bit simpler and does the same job.
KDBENTER_VECTOR gets registered twice on the boot cpu, once very early
and again after setup_IO_APIC_irqs() has been run, no need to change
setup_IO_APIC_irqs.  The patch is included in
kdb-v4.4-2.6.22-rc2-i386-2, with a corresponding x86_64-2 update.

Unfortunately Linus's 2.6.22-rc1 patch has changed the order of console
initialization, serial consoles now get intialized much later.  AFAICT
this is an unexpected side effect of Bjorn Helgaas's patch to only
initialize UARTs once.  The effect of the new console initialization
order is that when kdb=early is issued, only the tty console has been
created.  Consoles for serial lines (ttyS0) get created much later, too
late for early debugging.

This change affects _all_ early kernel debugging, not just kdb.  There
is no output on the serial console until ACPI is initialized, any
kernel errors before that point cannot be diagnosed over a serial line.
Not good.

diff -u linux/arch/i386/kdb/kdbasupport.c linux/arch/i386/kdb/kdbasupport.c
--- linux/arch/i386/kdb/kdbasupport.c
+++ linux/arch/i386/kdb/kdbasupport.c
@@ -878,6 +878,18 @@
 {
 }
 
+static int __init
+kdba_arch_init(void)
+{
+#ifdef CONFIG_SMP
+       set_intr_gate(KDB_VECTOR, kdb_interrupt);
+#endif
+       set_intr_gate(KDBENTER_VECTOR, kdb_call);
+       return 0;
+}
+
+arch_initcall(kdba_arch_init);
+
 /*
  * kdba_init
  *
@@ -896,6 +908,7 @@
 void __init
 kdba_init(void)
 {
+       kdba_arch_init();       /* Need to register KDBENTER_VECTOR early */
        kdb_register("pt_regs", kdba_pt_regs, "address", "Format struct 
pt_regs", 0);
        kdb_register("stackdepth", kdba_stackdepth, "[percentage]", "Print 
processes using >= stack percentage", 0);
 
@@ -1008,18 +1021,6 @@
        return(kdba_getarea_size(data, addr, size) || kdba_putarea_size(addr, 
data, size));
 }
 
-static int __init
-kdba_arch_init(void)
-{
-#ifdef CONFIG_SMP
-       set_intr_gate(KDB_VECTOR, kdb_interrupt);
-#endif
-       set_intr_gate(KDBENTER_VECTOR, kdb_call);
-       return 0;
-}
-
-arch_initcall(kdba_arch_init);
-
 #ifdef CONFIG_SMP
 
 #include <mach_ipi.h>

---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.

Reply via email to