A different KGDB stub
PATCH 6/6 A different KGDB stub
The following is the x86_64-specific bits to this KGDB stub (Pavel, can you give this a try please? Thanks).
arch/x86_64/Kconfig | 5 arch/x86_64/kernel/Makefile | 1 arch/x86_64/kernel/entry.S | 41 ++ arch/x86_64/kernel/irq.c | 2 arch/x86_64/kernel/nmi.c | 14 arch/x86_64/kernel/traps.c | 3 arch/x86_64/kernel/x86_64-stub.c | 551 +++++++++++++++++++++++++++++++++++++++ arch/x86_64/mm/fault.c | 6 include/asm-x86_64/kgdb.h | 57 ++++ include/asm-x86_64/processor.h | 1 include/asm-x86_64/system.h | 50 +++ 11 files changed, 722 insertions(+), 9 deletions(-)
arch/x86_64/Kconfig +1 -4
@@ -465,10 +465,7 @@ config IOMMU_LEAK Add a simple leak tracer to the IOMMU code. This is useful when you are debugging a buggy device driver that leaks IOMMU mappings. -#config X86_REMOTE_DEBUG -# bool "kgdb debugging stub" - -endmenu +source "kernel/Kconfig.kgdb" source "security/Kconfig"
arch/x86_64/kernel/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_GART_IOMMU) += pci-gart.o a obj-$(CONFIG_DUMMY_IOMMU) += pci-nommu.o pci-dma.o obj-$(CONFIG_MODULES) += module.o +obj-$(CONFIG_KGDB) += x86_64-stub.o obj-y += topology.o
arch/x86_64/kernel/entry.S +38 -3
62 lines not on this page · raw message
arch/x86_64/kernel/irq.c +2 -0
@@ -405,6 +405,8 @@ out:spin_unlock (&desc->lock);irq_exit (); + +kgdb_process_breakpoint ();return 1 ; }
arch/x86_64/kernel/nmi.c +13 -1
@@ -24,6 +24,7 @@#include <linux/module.h> #include <linux/sysdev.h> #include <linux/nmi.h> +#include <linux/debugger.h> #include <asm/smp.h> #include <asm/mtrr.h>
@@ -317,13 +318,24 @@ void nmi_watchdog_tick (struct pt_regs *return ; sum =read_pda (apic_timer_irqs); -if (last_irq_sums[cpu] == sum) { +if (atomic_read (&debugger_active)) { + +/* +* The machine is in debugger, hold this cpu if already +* not held. +*/ +debugger_nmihook (cpu, regs); + alert_counter[cpu] =0 ; + + }else if (last_irq_sums[cpu] == sum) { +/* * Ayiee, looks like this CPU is stuck ... * wait a few IRQs (5 seconds) before doing the oops ... */ alert_counter[cpu]++;if (alert_counter[cpu] ==5 *nmi_hz) { +if (notify_die (DIE_NMI ,"nmi" , regs, reason,2 ,SIGINT ) ==NOTIFY_BAD ) { alert_counter[cpu] =0 ;return ;
arch/x86_64/kernel/traps.c +2 -1
@@ -28,6 +28,7 @@#include <linux/interrupt.h> #include <linux/module.h> #include <linux/moduleparam.h> +#include <linux/debugger.h> #include <asm/system.h> #include <asm/uaccess.h>
@@ -614,7 +615,7 @@ asmlinkage void do_debug(struct pt_regs tsk->thread.debugreg6 = condition;/* Mask out spurious TF errors due to lazy TF clearing */ -if (condition &DR_STEP ) { +if (condition &DR_STEP && !debugger_step) {/* * The TF error should be masked out only if the current * process is not traced and if the TRAP flag has been set
arch/x86_64/kernel/x86_64-stub.c +551 -0
551 lines not on this page · raw message
arch/x86_64/mm/fault.c +6 -0
@@ -23,6 +23,7 @@#include <linux/vt_kern.h> /* For unblank_screen() */ #include <linux/compiler.h> #include <linux/module.h> +#include <linux/debugger.h> #include <asm/system.h> #include <asm/uaccess.h>
@@ -290,6 +291,11 @@ asmlinkage void do_page_fault(struct pt_return ; again: +if (debugger_memerr_expected) { +/* This fault was caused by memory access through a debugger. +* Don't handle it like user accesses */ + goto no_context; + }down_read (&mm->mmap_sem); vma =find_vma (mm, address);
include/asm-x86_64/kgdb.h +57 -0
57 lines not on this page · raw message
include/asm-x86_64/processor.h +1 -0
@@ -252,6 +252,7 @@ struct thread_struct {unsigned long *io_bitmap_ptr;/* cached TLS descriptors. */ u64 tls_array[GDT_ENTRY_TLS_ENTRIES ]; +void *debuggerinfo; };#define INIT_THREAD {}
include/asm-x86_64/system.h +50 -0
56 lines not on this page · raw message
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi!
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
The following is the x86_64-specific bits to this KGDB stub (Pavel, can you give this a try please? Thanks).
I can only see [0/6],[1/6] and [6/6] on l-k. Could you perhaps mail me complete diff against 2.6.2 to try? [Or against some other version I can get from kernel.org...)
I'll blame the slow mailserver and hope they all get through eventually.
Yes, now only #2 is missing :-))).
Quoted 2 lines
The following is the patch before I split it up. Against 2.6.3-rc4 + bk-netdev from 2.6.3-rc3-mm1 (otherwise kgdboe won't work at all):
I'll try without kgdboe, first.
I'm getting some compile errors, stay tuned.
Meanwhile: [and taking this public]
arch/x86_64/kernel/x86_64-stub.c: this is really horrible name for a file. Can we have arch/x86_64/kernel/kgdb.c? or kgdb-stub.c at worst..
also kernel/kgdb.c sounds better than kernel/kgdbstub.c.
Pavel
Signature · 2 lines
When do you have a heart between your knees? [Johanka's followup: and *two* hearts?]
Quoted 12 lines · Pavel Machek
Hi!
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
The following is the x86_64-specific bits to this KGDB stub (Pavel, can you give this a try please? Thanks).
I can only see [0/6],[1/6] and [6/6] on l-k. Could you perhaps mail me complete diff against 2.6.2 to try? [Or against some other version I can get from kernel.org...)
I'll blame the slow mailserver and hope they all get through eventually.
Quoted 8 lines
Yes, now only #2 is missing :-))).
Quoted 2 lines
The following is the patch before I split it up. Against 2.6.3-rc4 + bk-netdev from 2.6.3-rc3-mm1 (otherwise kgdboe won't work at all):
I'll try without kgdboe, first.
I'm getting some compile errors, stay tuned.
I'm not surprised, sadly.
Quoted 6 lines
Meanwhile: [and taking this public]
arch/x86_64/kernel/x86_64-stub.c: this is really horrible name for a file. Can we havearch/x86_64/kernel/kgdb.c? orkgdb-stub.cat worst..also
kernel/kgdb.csounds better thankernel/kgdbstub.c.
Don't look at me for naming, when in doubt I call stuff 'simple' (see arch/ppc/boot/simple, or CONFIG_PPC_SIMPLE_SERIAL, and I'm sure I'll do it again). If people like kernel/kgdb.c (and arch/$(ARCH)/kernel/kgdb.c or kgdb-stub.c) that's fine with me, so long as they're all consistent.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/