diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-23 14:59:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-23 14:59:37 -0400 |
commit | 0f6e38a6381446eff5175b77d1094834a633a90f (patch) | |
tree | e5295c372b6a73fa84b4d14b86ea9fa626d3f030 /arch | |
parent | e669e8179d364bb11ed51504e1a1c60830bff4c5 (diff) | |
parent | 3b216c9ed347924efb5e7a66b3257c40a5596d30 (diff) |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb:
kgdb: kgdboc console poll hooks for mpsc uart
kgdb: kgdboc console poll hooks for cpm uart
kgdb, powerpc: arch specific powerpc kgdb support
kgdb: support for ARCH=arm
kgdb: remove unused HAVE_ARCH_KGDB_SHADOW_INFO config variable
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/kernel/kgdb.c | 201 | ||||
-rw-r--r-- | arch/arm/kernel/setup.c | 2 | ||||
-rw-r--r-- | arch/arm/kernel/traps.c | 5 | ||||
-rw-r--r-- | arch/powerpc/Kconfig | 1 | ||||
-rw-r--r-- | arch/powerpc/Kconfig.debug | 50 | ||||
-rw-r--r-- | arch/powerpc/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/kgdb.c | 410 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup_32.c | 16 | ||||
-rw-r--r-- | arch/powerpc/platforms/powermac/setup.c | 6 |
11 files changed, 628 insertions, 66 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index c7ad324ddf2c..d048f6887d0b 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -12,6 +12,7 @@ config ARM | |||
12 | select RTC_LIB | 12 | select RTC_LIB |
13 | select SYS_SUPPORTS_APM_EMULATION | 13 | select SYS_SUPPORTS_APM_EMULATION |
14 | select HAVE_OPROFILE | 14 | select HAVE_OPROFILE |
15 | select HAVE_ARCH_KGDB | ||
15 | select HAVE_KPROBES if (!XIP_KERNEL) | 16 | select HAVE_KPROBES if (!XIP_KERNEL) |
16 | select HAVE_KRETPROBES if (HAVE_KPROBES) | 17 | select HAVE_KRETPROBES if (HAVE_KPROBES) |
17 | select HAVE_FTRACE if (!XIP_KERNEL) | 18 | select HAVE_FTRACE if (!XIP_KERNEL) |
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index eb9092ca8008..1d296fc8494e 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile | |||
@@ -28,6 +28,7 @@ obj-$(CONFIG_KPROBES) += kprobes.o kprobes-decode.o | |||
28 | obj-$(CONFIG_ATAGS_PROC) += atags.o | 28 | obj-$(CONFIG_ATAGS_PROC) += atags.o |
29 | obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o | 29 | obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o |
30 | obj-$(CONFIG_ARM_THUMBEE) += thumbee.o | 30 | obj-$(CONFIG_ARM_THUMBEE) += thumbee.o |
31 | obj-$(CONFIG_KGDB) += kgdb.o | ||
31 | 32 | ||
32 | obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o | 33 | obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o |
33 | AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 | 34 | AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 |
diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c new file mode 100644 index 000000000000..aaffaecffcd1 --- /dev/null +++ b/arch/arm/kernel/kgdb.c | |||
@@ -0,0 +1,201 @@ | |||
1 | /* | ||
2 | * arch/arm/kernel/kgdb.c | ||
3 | * | ||
4 | * ARM KGDB support | ||
5 | * | ||
6 | * Copyright (c) 2002-2004 MontaVista Software, Inc | ||
7 | * Copyright (c) 2008 Wind River Systems, Inc. | ||
8 | * | ||
9 | * Authors: George Davis <davis_g@mvista.com> | ||
10 | * Deepak Saxena <dsaxena@plexity.net> | ||
11 | */ | ||
12 | #include <linux/kgdb.h> | ||
13 | #include <asm/traps.h> | ||
14 | |||
15 | /* Make a local copy of the registers passed into the handler (bletch) */ | ||
16 | void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *kernel_regs) | ||
17 | { | ||
18 | int regno; | ||
19 | |||
20 | /* Initialize all to zero. */ | ||
21 | for (regno = 0; regno < GDB_MAX_REGS; regno++) | ||
22 | gdb_regs[regno] = 0; | ||
23 | |||
24 | gdb_regs[_R0] = kernel_regs->ARM_r0; | ||
25 | gdb_regs[_R1] = kernel_regs->ARM_r1; | ||
26 | gdb_regs[_R2] = kernel_regs->ARM_r2; | ||
27 | gdb_regs[_R3] = kernel_regs->ARM_r3; | ||
28 | gdb_regs[_R4] = kernel_regs->ARM_r4; | ||
29 | gdb_regs[_R5] = kernel_regs->ARM_r5; | ||
30 | gdb_regs[_R6] = kernel_regs->ARM_r6; | ||
31 | gdb_regs[_R7] = kernel_regs->ARM_r7; | ||
32 | gdb_regs[_R8] = kernel_regs->ARM_r8; | ||
33 | gdb_regs[_R9] = kernel_regs->ARM_r9; | ||
34 | gdb_regs[_R10] = kernel_regs->ARM_r10; | ||
35 | gdb_regs[_FP] = kernel_regs->ARM_fp; | ||
36 | gdb_regs[_IP] = kernel_regs->ARM_ip; | ||
37 | gdb_regs[_SPT] = kernel_regs->ARM_sp; | ||
38 | gdb_regs[_LR] = kernel_regs->ARM_lr; | ||
39 | gdb_regs[_PC] = kernel_regs->ARM_pc; | ||
40 | gdb_regs[_CPSR] = kernel_regs->ARM_cpsr; | ||
41 | } | ||
42 | |||
43 | /* Copy local gdb registers back to kgdb regs, for later copy to kernel */ | ||
44 | void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *kernel_regs) | ||
45 | { | ||
46 | kernel_regs->ARM_r0 = gdb_regs[_R0]; | ||
47 | kernel_regs->ARM_r1 = gdb_regs[_R1]; | ||
48 | kernel_regs->ARM_r2 = gdb_regs[_R2]; | ||
49 | kernel_regs->ARM_r3 = gdb_regs[_R3]; | ||
50 | kernel_regs->ARM_r4 = gdb_regs[_R4]; | ||
51 | kernel_regs->ARM_r5 = gdb_regs[_R5]; | ||
52 | kernel_regs->ARM_r6 = gdb_regs[_R6]; | ||
53 | kernel_regs->ARM_r7 = gdb_regs[_R7]; | ||
54 | kernel_regs->ARM_r8 = gdb_regs[_R8]; | ||
55 | kernel_regs->ARM_r9 = gdb_regs[_R9]; | ||
56 | kernel_regs->ARM_r10 = gdb_regs[_R10]; | ||
57 | kernel_regs->ARM_fp = gdb_regs[_FP]; | ||
58 | kernel_regs->ARM_ip = gdb_regs[_IP]; | ||
59 | kernel_regs->ARM_sp = gdb_regs[_SPT]; | ||
60 | kernel_regs->ARM_lr = gdb_regs[_LR]; | ||
61 | kernel_regs->ARM_pc = gdb_regs[_PC]; | ||
62 | kernel_regs->ARM_cpsr = gdb_regs[_CPSR]; | ||
63 | } | ||
64 | |||
65 | void | ||
66 | sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task) | ||
67 | { | ||
68 | struct pt_regs *thread_regs; | ||
69 | int regno; | ||
70 | |||
71 | /* Just making sure... */ | ||
72 | if (task == NULL) | ||
73 | return; | ||
74 | |||
75 | /* Initialize to zero */ | ||
76 | for (regno = 0; regno < GDB_MAX_REGS; regno++) | ||
77 | gdb_regs[regno] = 0; | ||
78 | |||
79 | /* Otherwise, we have only some registers from switch_to() */ | ||
80 | thread_regs = task_pt_regs(task); | ||
81 | gdb_regs[_R0] = thread_regs->ARM_r0; | ||
82 | gdb_regs[_R1] = thread_regs->ARM_r1; | ||
83 | gdb_regs[_R2] = thread_regs->ARM_r2; | ||
84 | gdb_regs[_R3] = thread_regs->ARM_r3; | ||
85 | gdb_regs[_R4] = thread_regs->ARM_r4; | ||
86 | gdb_regs[_R5] = thread_regs->ARM_r5; | ||
87 | gdb_regs[_R6] = thread_regs->ARM_r6; | ||
88 | gdb_regs[_R7] = thread_regs->ARM_r7; | ||
89 | gdb_regs[_R8] = thread_regs->ARM_r8; | ||
90 | gdb_regs[_R9] = thread_regs->ARM_r9; | ||
91 | gdb_regs[_R10] = thread_regs->ARM_r10; | ||
92 | gdb_regs[_FP] = thread_regs->ARM_fp; | ||
93 | gdb_regs[_IP] = thread_regs->ARM_ip; | ||
94 | gdb_regs[_SPT] = thread_regs->ARM_sp; | ||
95 | gdb_regs[_LR] = thread_regs->ARM_lr; | ||
96 | gdb_regs[_PC] = thread_regs->ARM_pc; | ||
97 | gdb_regs[_CPSR] = thread_regs->ARM_cpsr; | ||
98 | } | ||
99 | |||
100 | static int compiled_break; | ||
101 | |||
102 | int kgdb_arch_handle_exception(int exception_vector, int signo, | ||
103 | int err_code, char *remcom_in_buffer, | ||
104 | char *remcom_out_buffer, | ||
105 | struct pt_regs *linux_regs) | ||
106 | { | ||
107 | unsigned long addr; | ||
108 | char *ptr; | ||
109 | |||
110 | switch (remcom_in_buffer[0]) { | ||
111 | case 'D': | ||
112 | case 'k': | ||
113 | case 'c': | ||
114 | kgdb_contthread = NULL; | ||
115 | |||
116 | /* | ||
117 | * Try to read optional parameter, pc unchanged if no parm. | ||
118 | * If this was a compiled breakpoint, we need to move | ||
119 | * to the next instruction or we will just breakpoint | ||
120 | * over and over again. | ||
121 | */ | ||
122 | ptr = &remcom_in_buffer[1]; | ||
123 | if (kgdb_hex2long(&ptr, &addr)) | ||
124 | linux_regs->ARM_pc = addr; | ||
125 | else if (compiled_break == 1) | ||
126 | linux_regs->ARM_pc += 4; | ||
127 | |||
128 | compiled_break = 0; | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | return -1; | ||
134 | } | ||
135 | |||
136 | static int kgdb_brk_fn(struct pt_regs *regs, unsigned int instr) | ||
137 | { | ||
138 | kgdb_handle_exception(1, SIGTRAP, 0, regs); | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int instr) | ||
144 | { | ||
145 | compiled_break = 1; | ||
146 | kgdb_handle_exception(1, SIGTRAP, 0, regs); | ||
147 | |||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static struct undef_hook kgdb_brkpt_hook = { | ||
152 | .instr_mask = 0xffffffff, | ||
153 | .instr_val = KGDB_BREAKINST, | ||
154 | .fn = kgdb_brk_fn | ||
155 | }; | ||
156 | |||
157 | static struct undef_hook kgdb_compiled_brkpt_hook = { | ||
158 | .instr_mask = 0xffffffff, | ||
159 | .instr_val = KGDB_COMPILED_BREAK, | ||
160 | .fn = kgdb_compiled_brk_fn | ||
161 | }; | ||
162 | |||
163 | /** | ||
164 | * kgdb_arch_init - Perform any architecture specific initalization. | ||
165 | * | ||
166 | * This function will handle the initalization of any architecture | ||
167 | * specific callbacks. | ||
168 | */ | ||
169 | int kgdb_arch_init(void) | ||
170 | { | ||
171 | register_undef_hook(&kgdb_brkpt_hook); | ||
172 | register_undef_hook(&kgdb_compiled_brkpt_hook); | ||
173 | |||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * kgdb_arch_exit - Perform any architecture specific uninitalization. | ||
179 | * | ||
180 | * This function will handle the uninitalization of any architecture | ||
181 | * specific callbacks, for dynamic registration and unregistration. | ||
182 | */ | ||
183 | void kgdb_arch_exit(void) | ||
184 | { | ||
185 | unregister_undef_hook(&kgdb_brkpt_hook); | ||
186 | unregister_undef_hook(&kgdb_compiled_brkpt_hook); | ||
187 | } | ||
188 | |||
189 | /* | ||
190 | * Register our undef instruction hooks with ARM undef core. | ||
191 | * We regsiter a hook specifically looking for the KGB break inst | ||
192 | * and we handle the normal undef case within the do_undefinstr | ||
193 | * handler. | ||
194 | */ | ||
195 | struct kgdb_arch arch_kgdb_ops = { | ||
196 | #ifndef __ARMEB__ | ||
197 | .gdb_bpt_instr = {0xfe, 0xde, 0xff, 0xe7} | ||
198 | #else /* ! __ARMEB__ */ | ||
199 | .gdb_bpt_instr = {0xe7, 0xff, 0xde, 0xfe} | ||
200 | #endif | ||
201 | }; | ||
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index b7b0720bc1bb..38f0e7940a13 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <asm/mach/arch.h> | 36 | #include <asm/mach/arch.h> |
37 | #include <asm/mach/irq.h> | 37 | #include <asm/mach/irq.h> |
38 | #include <asm/mach/time.h> | 38 | #include <asm/mach/time.h> |
39 | #include <asm/traps.h> | ||
39 | 40 | ||
40 | #include "compat.h" | 41 | #include "compat.h" |
41 | #include "atags.h" | 42 | #include "atags.h" |
@@ -853,6 +854,7 @@ void __init setup_arch(char **cmdline_p) | |||
853 | conswitchp = &dummy_con; | 854 | conswitchp = &dummy_con; |
854 | #endif | 855 | #endif |
855 | #endif | 856 | #endif |
857 | early_trap_init(); | ||
856 | } | 858 | } |
857 | 859 | ||
858 | 860 | ||
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 5595fdd75e82..7277aef83098 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c | |||
@@ -708,6 +708,11 @@ EXPORT_SYMBOL(abort); | |||
708 | 708 | ||
709 | void __init trap_init(void) | 709 | void __init trap_init(void) |
710 | { | 710 | { |
711 | return; | ||
712 | } | ||
713 | |||
714 | void __init early_trap_init(void) | ||
715 | { | ||
711 | unsigned long vectors = CONFIG_VECTORS_BASE; | 716 | unsigned long vectors = CONFIG_VECTORS_BASE; |
712 | extern char __stubs_start[], __stubs_end[]; | 717 | extern char __stubs_start[], __stubs_end[]; |
713 | extern char __vectors_start[], __vectors_end[]; | 718 | extern char __vectors_start[], __vectors_end[]; |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 4c22242b396f..737ebf9d12bb 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -112,6 +112,7 @@ config PPC | |||
112 | select HAVE_FTRACE | 112 | select HAVE_FTRACE |
113 | select HAVE_IDE | 113 | select HAVE_IDE |
114 | select HAVE_KPROBES | 114 | select HAVE_KPROBES |
115 | select HAVE_ARCH_KGDB | ||
115 | select HAVE_KRETPROBES | 116 | select HAVE_KRETPROBES |
116 | select HAVE_LMB | 117 | select HAVE_LMB |
117 | select HAVE_DMA_ATTRS if PPC64 | 118 | select HAVE_DMA_ATTRS if PPC64 |
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug index 2840ab69ef4e..8c8aadbe9563 100644 --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug | |||
@@ -41,22 +41,6 @@ config HCALL_STATS | |||
41 | This option will add a small amount of overhead to all hypervisor | 41 | This option will add a small amount of overhead to all hypervisor |
42 | calls. | 42 | calls. |
43 | 43 | ||
44 | config DEBUGGER | ||
45 | bool "Enable debugger hooks" | ||
46 | depends on DEBUG_KERNEL | ||
47 | help | ||
48 | Include in-kernel hooks for kernel debuggers. Unless you are | ||
49 | intending to debug the kernel, say N here. | ||
50 | |||
51 | config KGDB | ||
52 | bool "Include kgdb kernel debugger" | ||
53 | depends on DEBUGGER && (BROKEN || PPC_GEN550 || 4xx) | ||
54 | select DEBUG_INFO | ||
55 | help | ||
56 | Include in-kernel hooks for kgdb, the Linux kernel source level | ||
57 | debugger. See <http://kgdb.sourceforge.net/> for more information. | ||
58 | Unless you are intending to debug the kernel, say N here. | ||
59 | |||
60 | config CODE_PATCHING_SELFTEST | 44 | config CODE_PATCHING_SELFTEST |
61 | bool "Run self-tests of the code-patching code." | 45 | bool "Run self-tests of the code-patching code." |
62 | depends on DEBUG_KERNEL | 46 | depends on DEBUG_KERNEL |
@@ -67,36 +51,9 @@ config FTR_FIXUP_SELFTEST | |||
67 | depends on DEBUG_KERNEL | 51 | depends on DEBUG_KERNEL |
68 | default n | 52 | default n |
69 | 53 | ||
70 | choice | ||
71 | prompt "Serial Port" | ||
72 | depends on KGDB | ||
73 | default KGDB_TTYS1 | ||
74 | |||
75 | config KGDB_TTYS0 | ||
76 | bool "ttyS0" | ||
77 | |||
78 | config KGDB_TTYS1 | ||
79 | bool "ttyS1" | ||
80 | |||
81 | config KGDB_TTYS2 | ||
82 | bool "ttyS2" | ||
83 | |||
84 | config KGDB_TTYS3 | ||
85 | bool "ttyS3" | ||
86 | |||
87 | endchoice | ||
88 | |||
89 | config KGDB_CONSOLE | ||
90 | bool "Enable serial console thru kgdb port" | ||
91 | depends on KGDB && 8xx || CPM2 | ||
92 | help | ||
93 | If you enable this, all serial console messages will be sent | ||
94 | over the gdb stub. | ||
95 | If unsure, say N. | ||
96 | |||
97 | config XMON | 54 | config XMON |
98 | bool "Include xmon kernel debugger" | 55 | bool "Include xmon kernel debugger" |
99 | depends on DEBUGGER | 56 | depends on DEBUG_KERNEL |
100 | help | 57 | help |
101 | Include in-kernel hooks for the xmon kernel monitor/debugger. | 58 | Include in-kernel hooks for the xmon kernel monitor/debugger. |
102 | Unless you are intending to debug the kernel, say N here. | 59 | Unless you are intending to debug the kernel, say N here. |
@@ -126,6 +83,11 @@ config XMON_DISASSEMBLY | |||
126 | to say Y here, unless you're building for a memory-constrained | 83 | to say Y here, unless you're building for a memory-constrained |
127 | system. | 84 | system. |
128 | 85 | ||
86 | config DEBUGGER | ||
87 | bool | ||
88 | depends on KGDB || XMON | ||
89 | default y | ||
90 | |||
129 | config IRQSTACKS | 91 | config IRQSTACKS |
130 | bool "Use separate kernel stacks when processing interrupts" | 92 | bool "Use separate kernel stacks when processing interrupts" |
131 | help | 93 | help |
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index bf0b1fd0ec34..1a4094704b1f 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -74,6 +74,7 @@ obj-y += time.o prom.o traps.o setup-common.o \ | |||
74 | misc_$(CONFIG_WORD_SIZE).o | 74 | misc_$(CONFIG_WORD_SIZE).o |
75 | obj-$(CONFIG_PPC32) += entry_32.o setup_32.o | 75 | obj-$(CONFIG_PPC32) += entry_32.o setup_32.o |
76 | obj-$(CONFIG_PPC64) += dma_64.o iommu.o | 76 | obj-$(CONFIG_PPC64) += dma_64.o iommu.o |
77 | obj-$(CONFIG_KGDB) += kgdb.o | ||
77 | obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o | 78 | obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o |
78 | obj-$(CONFIG_MODULES) += ppc_ksyms.o | 79 | obj-$(CONFIG_MODULES) += ppc_ksyms.o |
79 | obj-$(CONFIG_BOOTX_TEXT) += btext.o | 80 | obj-$(CONFIG_BOOTX_TEXT) += btext.o |
diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c new file mode 100644 index 000000000000..b4fdf2f2743c --- /dev/null +++ b/arch/powerpc/kernel/kgdb.c | |||
@@ -0,0 +1,410 @@ | |||
1 | /* | ||
2 | * PowerPC backend to the KGDB stub. | ||
3 | * | ||
4 | * 1998 (c) Michael AK Tesch (tesch@cs.wisc.edu) | ||
5 | * Copyright (C) 2003 Timesys Corporation. | ||
6 | * Copyright (C) 2004-2006 MontaVista Software, Inc. | ||
7 | * PPC64 Mods (C) 2005 Frank Rowand (frowand@mvista.com) | ||
8 | * PPC32 support restored by Vitaly Wool <vwool@ru.mvista.com> and | ||
9 | * Sergei Shtylyov <sshtylyov@ru.mvista.com> | ||
10 | * Copyright (C) 2007-2008 Wind River Systems, Inc. | ||
11 | * | ||
12 | * This file is licensed under the terms of the GNU General Public License | ||
13 | * version 2. This program as licensed "as is" without any warranty of any | ||
14 | * kind, whether express or implied. | ||
15 | */ | ||
16 | |||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/kgdb.h> | ||
20 | #include <linux/smp.h> | ||
21 | #include <linux/signal.h> | ||
22 | #include <linux/ptrace.h> | ||
23 | #include <asm/current.h> | ||
24 | #include <asm/processor.h> | ||
25 | #include <asm/machdep.h> | ||
26 | |||
27 | /* | ||
28 | * This table contains the mapping between PowerPC hardware trap types, and | ||
29 | * signals, which are primarily what GDB understands. GDB and the kernel | ||
30 | * don't always agree on values, so we use constants taken from gdb-6.2. | ||
31 | */ | ||
32 | static struct hard_trap_info | ||
33 | { | ||
34 | unsigned int tt; /* Trap type code for powerpc */ | ||
35 | unsigned char signo; /* Signal that we map this trap into */ | ||
36 | } hard_trap_info[] = { | ||
37 | { 0x0100, 0x02 /* SIGINT */ }, /* system reset */ | ||
38 | { 0x0200, 0x0b /* SIGSEGV */ }, /* machine check */ | ||
39 | { 0x0300, 0x0b /* SIGSEGV */ }, /* data access */ | ||
40 | { 0x0400, 0x0b /* SIGSEGV */ }, /* instruction access */ | ||
41 | { 0x0500, 0x02 /* SIGINT */ }, /* external interrupt */ | ||
42 | { 0x0600, 0x0a /* SIGBUS */ }, /* alignment */ | ||
43 | { 0x0700, 0x05 /* SIGTRAP */ }, /* program check */ | ||
44 | { 0x0800, 0x08 /* SIGFPE */ }, /* fp unavailable */ | ||
45 | { 0x0900, 0x0e /* SIGALRM */ }, /* decrementer */ | ||
46 | { 0x0c00, 0x14 /* SIGCHLD */ }, /* system call */ | ||
47 | #if defined(CONFIG_40x) || defined(CONFIG_BOOKE) | ||
48 | { 0x2002, 0x05 /* SIGTRAP */ }, /* debug */ | ||
49 | #if defined(CONFIG_FSL_BOOKE) | ||
50 | { 0x2010, 0x08 /* SIGFPE */ }, /* spe unavailable */ | ||
51 | { 0x2020, 0x08 /* SIGFPE */ }, /* spe unavailable */ | ||
52 | { 0x2030, 0x08 /* SIGFPE */ }, /* spe fp data */ | ||
53 | { 0x2040, 0x08 /* SIGFPE */ }, /* spe fp data */ | ||
54 | { 0x2050, 0x08 /* SIGFPE */ }, /* spe fp round */ | ||
55 | { 0x2060, 0x0e /* SIGILL */ }, /* performace monitor */ | ||
56 | { 0x2900, 0x08 /* SIGFPE */ }, /* apu unavailable */ | ||
57 | { 0x3100, 0x0e /* SIGALRM */ }, /* fixed interval timer */ | ||
58 | { 0x3200, 0x02 /* SIGINT */ }, /* watchdog */ | ||
59 | #else /* ! CONFIG_FSL_BOOKE */ | ||
60 | { 0x1000, 0x0e /* SIGALRM */ }, /* prog interval timer */ | ||
61 | { 0x1010, 0x0e /* SIGALRM */ }, /* fixed interval timer */ | ||
62 | { 0x1020, 0x02 /* SIGINT */ }, /* watchdog */ | ||
63 | { 0x2010, 0x08 /* SIGFPE */ }, /* fp unavailable */ | ||
64 | { 0x2020, 0x08 /* SIGFPE */ }, /* ap unavailable */ | ||
65 | #endif | ||
66 | #else /* ! (defined(CONFIG_40x) || defined(CONFIG_BOOKE)) */ | ||
67 | { 0x0d00, 0x05 /* SIGTRAP */ }, /* single-step */ | ||
68 | #if defined(CONFIG_8xx) | ||
69 | { 0x1000, 0x04 /* SIGILL */ }, /* software emulation */ | ||
70 | #else /* ! CONFIG_8xx */ | ||
71 | { 0x0f00, 0x04 /* SIGILL */ }, /* performance monitor */ | ||
72 | { 0x0f20, 0x08 /* SIGFPE */ }, /* altivec unavailable */ | ||
73 | { 0x1300, 0x05 /* SIGTRAP */ }, /* instruction address break */ | ||
74 | #if defined(CONFIG_PPC64) | ||
75 | { 0x1200, 0x05 /* SIGILL */ }, /* system error */ | ||
76 | { 0x1500, 0x04 /* SIGILL */ }, /* soft patch */ | ||
77 | { 0x1600, 0x04 /* SIGILL */ }, /* maintenance */ | ||
78 | { 0x1700, 0x08 /* SIGFPE */ }, /* altivec assist */ | ||
79 | { 0x1800, 0x04 /* SIGILL */ }, /* thermal */ | ||
80 | #else /* ! CONFIG_PPC64 */ | ||
81 | { 0x1400, 0x02 /* SIGINT */ }, /* SMI */ | ||
82 | { 0x1600, 0x08 /* SIGFPE */ }, /* altivec assist */ | ||
83 | { 0x1700, 0x04 /* SIGILL */ }, /* TAU */ | ||
84 | { 0x2000, 0x05 /* SIGTRAP */ }, /* run mode */ | ||
85 | #endif | ||
86 | #endif | ||
87 | #endif | ||
88 | { 0x0000, 0x00 } /* Must be last */ | ||
89 | }; | ||
90 | |||
91 | static int computeSignal(unsigned int tt) | ||
92 | { | ||
93 | struct hard_trap_info *ht; | ||
94 | |||
95 | for (ht = hard_trap_info; ht->tt && ht->signo; ht++) | ||
96 | if (ht->tt == tt) | ||
97 | return ht->signo; | ||
98 | |||
99 | return SIGHUP; /* default for things we don't know about */ | ||
100 | } | ||
101 | |||
102 | static int kgdb_call_nmi_hook(struct pt_regs *regs) | ||
103 | { | ||
104 | kgdb_nmicallback(raw_smp_processor_id(), regs); | ||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | #ifdef CONFIG_SMP | ||
109 | void kgdb_roundup_cpus(unsigned long flags) | ||
110 | { | ||
111 | smp_send_debugger_break(MSG_ALL_BUT_SELF); | ||
112 | } | ||
113 | #endif | ||
114 | |||
115 | /* KGDB functions to use existing PowerPC64 hooks. */ | ||
116 | static int kgdb_debugger(struct pt_regs *regs) | ||
117 | { | ||
118 | return kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs); | ||
119 | } | ||
120 | |||
121 | static int kgdb_handle_breakpoint(struct pt_regs *regs) | ||
122 | { | ||
123 | if (user_mode(regs)) | ||
124 | return 0; | ||
125 | |||
126 | if (kgdb_handle_exception(0, SIGTRAP, 0, regs) != 0) | ||
127 | return 0; | ||
128 | |||
129 | if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr)) | ||
130 | regs->nip += 4; | ||
131 | |||
132 | return 1; | ||
133 | } | ||
134 | |||
135 | static int kgdb_singlestep(struct pt_regs *regs) | ||
136 | { | ||
137 | struct thread_info *thread_info, *exception_thread_info; | ||
138 | |||
139 | if (user_mode(regs)) | ||
140 | return 0; | ||
141 | |||
142 | /* | ||
143 | * On Book E and perhaps other processsors, singlestep is handled on | ||
144 | * the critical exception stack. This causes current_thread_info() | ||
145 | * to fail, since it it locates the thread_info by masking off | ||
146 | * the low bits of the current stack pointer. We work around | ||
147 | * this issue by copying the thread_info from the kernel stack | ||
148 | * before calling kgdb_handle_exception, and copying it back | ||
149 | * afterwards. On most processors the copy is avoided since | ||
150 | * exception_thread_info == thread_info. | ||
151 | */ | ||
152 | thread_info = (struct thread_info *)(regs->gpr[1] & ~(THREAD_SIZE-1)); | ||
153 | exception_thread_info = current_thread_info(); | ||
154 | |||
155 | if (thread_info != exception_thread_info) | ||
156 | memcpy(exception_thread_info, thread_info, sizeof *thread_info); | ||
157 | |||
158 | kgdb_handle_exception(0, SIGTRAP, 0, regs); | ||
159 | |||
160 | if (thread_info != exception_thread_info) | ||
161 | memcpy(thread_info, exception_thread_info, sizeof *thread_info); | ||
162 | |||
163 | return 1; | ||
164 | } | ||
165 | |||
166 | static int kgdb_iabr_match(struct pt_regs *regs) | ||
167 | { | ||
168 | if (user_mode(regs)) | ||
169 | return 0; | ||
170 | |||
171 | if (kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs) != 0) | ||
172 | return 0; | ||
173 | return 1; | ||
174 | } | ||
175 | |||
176 | static int kgdb_dabr_match(struct pt_regs *regs) | ||
177 | { | ||
178 | if (user_mode(regs)) | ||
179 | return 0; | ||
180 | |||
181 | if (kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs) != 0) | ||
182 | return 0; | ||
183 | return 1; | ||
184 | } | ||
185 | |||
186 | #define PACK64(ptr, src) do { *(ptr++) = (src); } while (0) | ||
187 | |||
188 | #define PACK32(ptr, src) do { \ | ||
189 | u32 *ptr32; \ | ||
190 | ptr32 = (u32 *)ptr; \ | ||
191 | *(ptr32++) = (src); \ | ||
192 | ptr = (unsigned long *)ptr32; \ | ||
193 | } while (0) | ||
194 | |||
195 | |||
196 | void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs) | ||
197 | { | ||
198 | unsigned long *ptr = gdb_regs; | ||
199 | int reg; | ||
200 | |||
201 | memset(gdb_regs, 0, NUMREGBYTES); | ||
202 | |||
203 | for (reg = 0; reg < 32; reg++) | ||
204 | PACK64(ptr, regs->gpr[reg]); | ||
205 | |||
206 | #ifdef CONFIG_FSL_BOOKE | ||
207 | #ifdef CONFIG_SPE | ||
208 | for (reg = 0; reg < 32; reg++) | ||
209 | PACK64(ptr, current->thread.evr[reg]); | ||
210 | #else | ||
211 | ptr += 32; | ||
212 | #endif | ||
213 | #else | ||
214 | /* fp registers not used by kernel, leave zero */ | ||
215 | ptr += 32 * 8 / sizeof(long); | ||
216 | #endif | ||
217 | |||
218 | PACK64(ptr, regs->nip); | ||
219 | PACK64(ptr, regs->msr); | ||
220 | PACK32(ptr, regs->ccr); | ||
221 | PACK64(ptr, regs->link); | ||
222 | PACK64(ptr, regs->ctr); | ||
223 | PACK32(ptr, regs->xer); | ||
224 | |||
225 | BUG_ON((unsigned long)ptr > | ||
226 | (unsigned long)(((void *)gdb_regs) + NUMREGBYTES)); | ||
227 | } | ||
228 | |||
229 | void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) | ||
230 | { | ||
231 | struct pt_regs *regs = (struct pt_regs *)(p->thread.ksp + | ||
232 | STACK_FRAME_OVERHEAD); | ||
233 | unsigned long *ptr = gdb_regs; | ||
234 | int reg; | ||
235 | |||
236 | memset(gdb_regs, 0, NUMREGBYTES); | ||
237 | |||
238 | /* Regs GPR0-2 */ | ||
239 | for (reg = 0; reg < 3; reg++) | ||
240 | PACK64(ptr, regs->gpr[reg]); | ||
241 | |||
242 | /* Regs GPR3-13 are caller saved, not in regs->gpr[] */ | ||
243 | ptr += 11; | ||
244 | |||
245 | /* Regs GPR14-31 */ | ||
246 | for (reg = 14; reg < 32; reg++) | ||
247 | PACK64(ptr, regs->gpr[reg]); | ||
248 | |||
249 | #ifdef CONFIG_FSL_BOOKE | ||
250 | #ifdef CONFIG_SPE | ||
251 | for (reg = 0; reg < 32; reg++) | ||
252 | PACK64(ptr, p->thread.evr[reg]); | ||
253 | #else | ||
254 | ptr += 32; | ||
255 | #endif | ||
256 | #else | ||
257 | /* fp registers not used by kernel, leave zero */ | ||
258 | ptr += 32 * 8 / sizeof(long); | ||
259 | #endif | ||
260 | |||
261 | PACK64(ptr, regs->nip); | ||
262 | PACK64(ptr, regs->msr); | ||
263 | PACK32(ptr, regs->ccr); | ||
264 | PACK64(ptr, regs->link); | ||
265 | PACK64(ptr, regs->ctr); | ||
266 | PACK32(ptr, regs->xer); | ||
267 | |||
268 | BUG_ON((unsigned long)ptr > | ||
269 | (unsigned long)(((void *)gdb_regs) + NUMREGBYTES)); | ||
270 | } | ||
271 | |||
272 | #define UNPACK64(dest, ptr) do { dest = *(ptr++); } while (0) | ||
273 | |||
274 | #define UNPACK32(dest, ptr) do { \ | ||
275 | u32 *ptr32; \ | ||
276 | ptr32 = (u32 *)ptr; \ | ||
277 | dest = *(ptr32++); \ | ||
278 | ptr = (unsigned long *)ptr32; \ | ||
279 | } while (0) | ||
280 | |||
281 | void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs) | ||
282 | { | ||
283 | unsigned long *ptr = gdb_regs; | ||
284 | int reg; | ||
285 | #ifdef CONFIG_SPE | ||
286 | union { | ||
287 | u32 v32[2]; | ||
288 | u64 v64; | ||
289 | } acc; | ||
290 | #endif | ||
291 | |||
292 | for (reg = 0; reg < 32; reg++) | ||
293 | UNPACK64(regs->gpr[reg], ptr); | ||
294 | |||
295 | #ifdef CONFIG_FSL_BOOKE | ||
296 | #ifdef CONFIG_SPE | ||
297 | for (reg = 0; reg < 32; reg++) | ||
298 | UNPACK64(current->thread.evr[reg], ptr); | ||
299 | #else | ||
300 | ptr += 32; | ||
301 | #endif | ||
302 | #else | ||
303 | /* fp registers not used by kernel, leave zero */ | ||
304 | ptr += 32 * 8 / sizeof(int); | ||
305 | #endif | ||
306 | |||
307 | UNPACK64(regs->nip, ptr); | ||
308 | UNPACK64(regs->msr, ptr); | ||
309 | UNPACK32(regs->ccr, ptr); | ||
310 | UNPACK64(regs->link, ptr); | ||
311 | UNPACK64(regs->ctr, ptr); | ||
312 | UNPACK32(regs->xer, ptr); | ||
313 | |||
314 | BUG_ON((unsigned long)ptr > | ||
315 | (unsigned long)(((void *)gdb_regs) + NUMREGBYTES)); | ||
316 | } | ||
317 | |||
318 | /* | ||
319 | * This function does PowerPC specific procesing for interfacing to gdb. | ||
320 | */ | ||
321 | int kgdb_arch_handle_exception(int vector, int signo, int err_code, | ||
322 | char *remcom_in_buffer, char *remcom_out_buffer, | ||
323 | struct pt_regs *linux_regs) | ||
324 | { | ||
325 | char *ptr = &remcom_in_buffer[1]; | ||
326 | unsigned long addr; | ||
327 | |||
328 | switch (remcom_in_buffer[0]) { | ||
329 | /* | ||
330 | * sAA..AA Step one instruction from AA..AA | ||
331 | * This will return an error to gdb .. | ||
332 | */ | ||
333 | case 's': | ||
334 | case 'c': | ||
335 | /* handle the optional parameter */ | ||
336 | if (kgdb_hex2long(&ptr, &addr)) | ||
337 | linux_regs->nip = addr; | ||
338 | |||
339 | atomic_set(&kgdb_cpu_doing_single_step, -1); | ||
340 | /* set the trace bit if we're stepping */ | ||
341 | if (remcom_in_buffer[0] == 's') { | ||
342 | #if defined(CONFIG_40x) || defined(CONFIG_BOOKE) | ||
343 | mtspr(SPRN_DBCR0, | ||
344 | mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM); | ||
345 | linux_regs->msr |= MSR_DE; | ||
346 | #else | ||
347 | linux_regs->msr |= MSR_SE; | ||
348 | #endif | ||
349 | kgdb_single_step = 1; | ||
350 | if (kgdb_contthread) | ||
351 | atomic_set(&kgdb_cpu_doing_single_step, | ||
352 | raw_smp_processor_id()); | ||
353 | } | ||
354 | return 0; | ||
355 | } | ||
356 | |||
357 | return -1; | ||
358 | } | ||
359 | |||
360 | /* | ||
361 | * Global data | ||
362 | */ | ||
363 | struct kgdb_arch arch_kgdb_ops = { | ||
364 | .gdb_bpt_instr = {0x7d, 0x82, 0x10, 0x08}, | ||
365 | }; | ||
366 | |||
367 | static int kgdb_not_implemented(struct pt_regs *regs) | ||
368 | { | ||
369 | return 0; | ||
370 | } | ||
371 | |||
372 | static void *old__debugger_ipi; | ||
373 | static void *old__debugger; | ||
374 | static void *old__debugger_bpt; | ||
375 | static void *old__debugger_sstep; | ||
376 | static void *old__debugger_iabr_match; | ||
377 | static void *old__debugger_dabr_match; | ||
378 | static void *old__debugger_fault_handler; | ||
379 | |||
380 | int kgdb_arch_init(void) | ||
381 | { | ||
382 | old__debugger_ipi = __debugger_ipi; | ||
383 | old__debugger = __debugger; | ||
384 | old__debugger_bpt = __debugger_bpt; | ||
385 | old__debugger_sstep = __debugger_sstep; | ||
386 | old__debugger_iabr_match = __debugger_iabr_match; | ||
387 | old__debugger_dabr_match = __debugger_dabr_match; | ||
388 | old__debugger_fault_handler = __debugger_fault_handler; | ||
389 | |||
390 | __debugger_ipi = kgdb_call_nmi_hook; | ||
391 | __debugger = kgdb_debugger; | ||
392 | __debugger_bpt = kgdb_handle_breakpoint; | ||
393 | __debugger_sstep = kgdb_singlestep; | ||
394 | __debugger_iabr_match = kgdb_iabr_match; | ||
395 | __debugger_dabr_match = kgdb_dabr_match; | ||
396 | __debugger_fault_handler = kgdb_not_implemented; | ||
397 | |||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | void kgdb_arch_exit(void) | ||
402 | { | ||
403 | __debugger_ipi = old__debugger_ipi; | ||
404 | __debugger = old__debugger; | ||
405 | __debugger_bpt = old__debugger_bpt; | ||
406 | __debugger_sstep = old__debugger_sstep; | ||
407 | __debugger_iabr_match = old__debugger_iabr_match; | ||
408 | __debugger_dabr_match = old__debugger_dabr_match; | ||
409 | __debugger_fault_handler = old__debugger_fault_handler; | ||
410 | } | ||
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 4efebe88e64a..066e65c59b58 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c | |||
@@ -43,10 +43,6 @@ | |||
43 | 43 | ||
44 | #define DBG(fmt...) | 44 | #define DBG(fmt...) |
45 | 45 | ||
46 | #if defined CONFIG_KGDB | ||
47 | #include <asm/kgdb.h> | ||
48 | #endif | ||
49 | |||
50 | extern void bootx_init(unsigned long r4, unsigned long phys); | 46 | extern void bootx_init(unsigned long r4, unsigned long phys); |
51 | 47 | ||
52 | int boot_cpuid; | 48 | int boot_cpuid; |
@@ -302,18 +298,6 @@ void __init setup_arch(char **cmdline_p) | |||
302 | 298 | ||
303 | xmon_setup(); | 299 | xmon_setup(); |
304 | 300 | ||
305 | #if defined(CONFIG_KGDB) | ||
306 | if (ppc_md.kgdb_map_scc) | ||
307 | ppc_md.kgdb_map_scc(); | ||
308 | set_debug_traps(); | ||
309 | if (strstr(cmd_line, "gdb")) { | ||
310 | if (ppc_md.progress) | ||
311 | ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000); | ||
312 | printk("kgdb breakpoint activated\n"); | ||
313 | breakpoint(); | ||
314 | } | ||
315 | #endif | ||
316 | |||
317 | /* | 301 | /* |
318 | * Set cache line size based on type of cpu as a default. | 302 | * Set cache line size based on type of cpu as a default. |
319 | * Systems with OF can look in the properties on the cpu node(s) | 303 | * Systems with OF can look in the properties on the cpu node(s) |
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c index 00bd0166d07f..31635446901a 100644 --- a/arch/powerpc/platforms/powermac/setup.c +++ b/arch/powerpc/platforms/powermac/setup.c | |||
@@ -97,8 +97,6 @@ extern struct machdep_calls pmac_md; | |||
97 | int sccdbg; | 97 | int sccdbg; |
98 | #endif | 98 | #endif |
99 | 99 | ||
100 | extern void zs_kgdb_hook(int tty_num); | ||
101 | |||
102 | sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN; | 100 | sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN; |
103 | EXPORT_SYMBOL(sys_ctrler); | 101 | EXPORT_SYMBOL(sys_ctrler); |
104 | 102 | ||
@@ -329,10 +327,6 @@ static void __init pmac_setup_arch(void) | |||
329 | l2cr_init(); | 327 | l2cr_init(); |
330 | #endif /* CONFIG_PPC32 */ | 328 | #endif /* CONFIG_PPC32 */ |
331 | 329 | ||
332 | #ifdef CONFIG_KGDB | ||
333 | zs_kgdb_hook(0); | ||
334 | #endif | ||
335 | |||
336 | find_via_cuda(); | 330 | find_via_cuda(); |
337 | find_via_pmu(); | 331 | find_via_pmu(); |
338 | smu_init(); | 332 | smu_init(); |