KGDB: This adds the basic support for i386.
Subsystems (3)
PATCH 7/21 KGDB: This adds the basic support for i386.
i386-lite.patch
From: Jason Wessel <[email protected]>
CC: [email protected]
Subject: [PATCH] This adds the basic support for i386.
In order to support early debugginer with kgdb when used with kgdb via rs232 some traps must be initialized sooner rather than later, but it is safe to always do this. The arch i386 now calls parse_early_param() to explicitly look at anything marked early_param(). KGDB also adds a few more notify_die() calls in areas where KGDB needs to take a peek sometimes. To achieve better back trace results from the debugger some labels were added to the switch_to macros.
--- arch/x86/kernel/Makefile_32 | 1 arch/x86/kernel/kgdb-jmp_32.S | 74 ++++++++++ arch/x86/kernel/kgdb_32.c | 300 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/setup_32.c | 2 arch/x86/kernel/traps_32.c | 12 + arch/x86/mm/fault_32.c | 4 include/asm-x86/kdebug_32.h | 1 include/asm-x86/kgdb_32.h | 51 +++++++ lib/Kconfig.kgdb | 2 9 files changed, 442 insertions(+), 5 deletions(-) create mode 100644 arch/x86/kernel/kgdb-jmp.S create mode 100644 arch/x86/kernel/kgdb.c create mode 100644 include/asm-x86/kgdb.h
arch/x86/kernel/Makefile_32 +1 -0
@@ -35,6 +35,7 @@ obj-y += sysenter_32.o vsyscall_32.o obj-$(CONFIG_ACPI_SRAT) += srat_32.o obj-$(CONFIG_EFI) += efi_32.o efi_stub_32.o obj-$(CONFIG_DOUBLEFAULT) += doublefault_32.o +obj-$(CONFIG_KGDB) += kgdb_32.o kgdb-jmp_32.o obj-$(CONFIG_VM86) += vm86_32.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_HPET_TIMER) += hpet.o
arch/x86/kernel/kgdb-jmp_32.S new file +74 -0
74 lines not on this page · raw message
arch/x86/kernel/kgdb_32.c new file +300 -0
300 lines not on this page · raw message
arch/x86/kernel/setup_32.c +2 -0
@@ -113,6 +113,7 @@ EXPORT_SYMBOL(ist_info);#endif extern void early_cpu_init (void ); +extern void early_trap_init (void );extern int root_mountflags;unsigned long saved_videomode;
@@ -503,6 +504,7 @@ void __init setup_arch(char **cmdline_p)memcpy (&boot_cpu_data, &new_cpu_data,sizeof (new_cpu_data));pre_setup_arch_hook ();early_cpu_init (); +early_trap_init ();/* * FIXME: This isn't an official loader_type right
arch/x86/kernel/traps_32.c +8 -4
@@ -895,6 +895,7 @@ fastcall void __kprobes do_debug(struct*/ clear_dr7:set_debugreg (0 ,7 ); +notify_die (DIE_DEBUG ,"debug2" , regs, condition, error_code,SIGTRAP );return ; debug_vm86:
@@ -1160,6 +1161,12 @@ static void __init set_task_gate(unsigne_set_gate (n,DESCTYPE_TASK , (void *)0 , (gdt_entry<<3 )); } +/* Some traps need to be set early. */ +void __init early_trap_init (void ) { +set_intr_gate (1 , &debug); +set_system_intr_gate (3 , &int3);/* int3 can be called from all */ +set_intr_gate (14 , &page_fault); +}void __init trap_init (void ) {
@@ -1176,10 +1183,8 @@ void __init trap_init(void)#endif set_trap_gate (0 ,÷_error); -set_intr_gate (1 ,&debug);set_intr_gate (2 ,&nmi); -set_system_intr_gate (3 , &int3);/* int3/4 can be called from all */ -set_system_gate (4 ,&overflow); +set_system_gate (4 , &overflow);/* int4/5 can be called from all */ set_trap_gate (5 ,&bounds);set_trap_gate (6 ,&invalid_op);set_trap_gate (7 ,&device_not_available);
@@ -1189,7 +1194,6 @@ void __init trap_init(void)set_trap_gate (11 ,&segment_not_present);set_trap_gate (12 ,&stack_segment);set_trap_gate (13 ,&general_protection); -set_intr_gate (14 ,&page_fault);set_trap_gate (15 ,&spurious_interrupt_bug);set_trap_gate (16 ,&coprocessor_error);set_trap_gate (17 ,&alignment_check);
arch/x86/mm/fault_32.c +4 -0
@@ -517,6 +517,10 @@ no_context:if (is_prefetch (regs, address, error_code))return ; +if (notify_die (DIE_PAGE_FAULT_NO_CONTEXT ,"no context" , regs, + error_code,14 ,SIGSEGV ) ==NOTIFY_STOP ) +return ; +/* * Oops. The kernel tried to access some bad page. We'll have to * terminate things with extreme prejudice.
include/asm-x86/kdebug_32.h +1 -0
@@ -28,6 +28,7 @@ enum die_val {DIE_CALL ,DIE_NMI_IPI ,DIE_PAGE_FAULT , + DIE_PAGE_FAULT_NO_CONTEXT, };#endif
include/asm-x86/kgdb_32.h new file +51 -0
51 lines not on this page · raw message
lib/Kconfig.kgdb +1 -1
@@ -13,7 +13,7 @@ config UNWIND_INFO config KGDB bool "KGDB: kernel debugging with remote gdb" select WANT_EXTRA_DEBUG_INFORMATION - depends on DEBUG_KERNEL + depends on DEBUG_KERNEL && (X86) help If you say Y here, it will be possible to remotely debug the kernel using gdb. Documentation of kernel debugger is available