aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2008-04-17 00:35:00 -0400
committerPaul Mackerras <paulus@samba.org>2008-04-18 01:37:19 -0400
commitfd3e0bbc6052ca9747a5332b382584ece83aab6d (patch)
tree259ede52b1955bb2d6f592612526cb6d31c0bae2 /arch/powerpc/kernel
parentec2b36b9f23cfbbe94d89724b796b44fd57d5221 (diff)
[POWERPC] Stacktrace support for lockdep
This adds stacktrace support for powerpc, which will be needed for lockdep. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/Makefile1
-rw-r--r--arch/powerpc/kernel/stacktrace.c47
2 files changed, 48 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index c1baf9d5903f..5183a9012a08 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_BOOTX_TEXT) += btext.o
67obj-$(CONFIG_SMP) += smp.o 67obj-$(CONFIG_SMP) += smp.o
68obj-$(CONFIG_KPROBES) += kprobes.o 68obj-$(CONFIG_KPROBES) += kprobes.o
69obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o 69obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o
70obj-$(CONFIG_STACKTRACE) += stacktrace.o
70 71
71pci64-$(CONFIG_PPC64) += pci_dn.o isa-bridge.o 72pci64-$(CONFIG_PPC64) += pci_dn.o isa-bridge.o
72obj-$(CONFIG_PCI) += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \ 73obj-$(CONFIG_PCI) += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
new file mode 100644
index 000000000000..e3638eeaaae7
--- /dev/null
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -0,0 +1,47 @@
1/*
2 * Stack trace utility
3 *
4 * Copyright 2008 Christoph Hellwig, IBM Corp.
5 *
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/sched.h>
14#include <linux/stacktrace.h>
15#include <asm/ptrace.h>
16#include <asm/asm-offsets.h>
17
18/*
19 * Save stack-backtrace addresses into a stack_trace buffer.
20 */
21void save_stack_trace(struct stack_trace *trace)
22{
23 unsigned long sp;
24
25 asm("mr %0,1" : "=r" (sp));
26
27 for (;;) {
28 unsigned long *stack = (unsigned long *) sp;
29 unsigned long newsp, ip;
30
31 if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD))
32 return;
33
34 newsp = stack[0];
35 ip = stack[STACK_FRAME_LR_SAVE];
36
37 if (!trace->skip)
38 trace->entries[trace->nr_entries++] = ip;
39 else
40 trace->skip--;
41
42 if (trace->nr_entries >= trace->max_entries)
43 return;
44
45 sp = newsp;
46 }
47}