Hi,
I'm Montavista software engineer. Currently I'm working with kdb, and
I've found issue:
I386 Kernel 2.6.18 with kdb patch doesn't enter KDB during boot with
kernel parameter kdb=early and kdb=on.

After investigations I found out that i386 kernel enter KDB during boot
using macros KDB_ENTER() (in init/main.c)

#define KDB_ENTER()     do {if (kdb_on && !KDB_IS_RUNNING()) { asm("\tint
$129\n"); }} while(0)

So, before execution of instruction "int $129", corresponding
handler(kdb_call) should be registered. But in kernel 2.6.18 we
register handler later KDB_ENTER() - in late init call:
static int __init
kdba_late_init(void)
{
#ifdef  CONFIG_SMP
        set_intr_gate(KDB_VECTOR, kdb_interrupt);
#endif
        set_trap_gate(KDBENTER_VECTOR, kdb_call);
        return 0;
}

__initcall(kdba_late_init);


In earlier kernels(2.6.10) registration of kdb_call() occur more
earlier - in trap_init() and kdb early works fine. So I suggest to move
registration of kdb_call from kdba_late_init to trap_init as it used to
be.
Then, I had browsed kdb patches and found out that kdb early doesn't
wing from 2.6.17.
In 2.6.16 we register kdb_call in trap_init - and early kdb works fine
and
In 2.6.17 registration was moved to late init call kdba_late_init().

So here is patch, that fix kdb early for 2.6.17,
thanks.

Index: linux-2.6.17/arch/i386/kernel/traps.c
===================================================================
--- linux-2.6.17.orig/arch/i386/kernel/traps.c
+++ linux-2.6.17/arch/i386/kernel/traps.c
@@ -57,6 +57,7 @@
 #include <asm/kdebug.h>
 
 #include <linux/module.h>
+#include <linux/kdbprivate.h>
 
 #include "mach_traps.h"
 
@@ -1175,6 +1176,9 @@ static void __init set_task_gate(unsigne
        _set_gate(idt_table+n,5,0,0,(gdt_entry<<3));
 }
 
+#ifdef        CONFIG_KDB
+asmlinkage int kdb_call(void);
+#endif        /* CONFIG_KDB */
 
 void __init trap_init(void)
 {
@@ -1237,6 +1241,17 @@ void __init trap_init(void)
 
        set_system_gate(SYSCALL_VECTOR,&system_call);
 
+#ifdef CONFIG_KDB
+       /*
+        * A trap gate, used by the kernel to enter the
+        * debugger, preserving all registers.
+        */
+#ifdef CONFIG_SMP
+       set_intr_gate(KDB_VECTOR, kdb_interrupt);
+#endif
+       set_trap_gate(KDBENTER_VECTOR, kdb_call);
+#endif /* CONFIG_KDB */
+
        /*
         * Should be a barrier for any external CPU state.
         */
Index: linux-2.6.17/arch/i386/kdb/kdbasupport.c
===================================================================
--- linux-2.6.17.orig/arch/i386/kdb/kdbasupport.c
+++ linux-2.6.17/arch/i386/kdb/kdbasupport.c
@@ -1334,11 +1334,6 @@ do { \
         "3" ((char *) (addr)),"2" ((seg) << 16)); \
 } while (0)
 
-static void __init set_trap_gate(unsigned int n, void *addr)
-{
-       _set_gate(idt_table+n,15,0,addr,__KERNEL_CS);
-}
-
 /* End of copy from arch/i386/kernel/traps.c */
 
 asmlinkage int kdb_call(void);
@@ -1479,18 +1474,6 @@ kdba_verify_rw(unsigned long addr, size_
        return(kdba_getarea_size(data, addr, size) || kdba_putarea_size(addr, 
data, size));
 }
 
-static int __init
-kdba_late_init(void)
-{
-#ifdef CONFIG_SMP
-       set_intr_gate(KDB_VECTOR, kdb_interrupt);
-#endif
-       set_trap_gate(KDBENTER_VECTOR, kdb_call);
-       return 0;
-}
-
-__initcall(kdba_late_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