diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-14 17:49:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-14 17:49:54 -0400 |
commit | e18425a0abc8eafa8e98ecffac517bb0c0904f4b (patch) | |
tree | 5eb743e7201850de19496183554bb34c766948c4 /arch/sparc64/kernel | |
parent | d1794f2c5b5817eb79ccc5e00701ca748d1b073a (diff) | |
parent | 5806b81ac1c0c52665b91723fd4146a4f86e386b (diff) |
Merge branch 'tracing/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'tracing/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (228 commits)
ftrace: build fix for ftraced_suspend
ftrace: separate out the function enabled variable
ftrace: add ftrace_kill_atomic
ftrace: use current CPU for function startup
ftrace: start wakeup tracing after setting function tracer
ftrace: check proper config for preempt type
ftrace: trace schedule
ftrace: define function trace nop
ftrace: move sched_switch enable after markers
ftrace: prevent ftrace modifications while being kprobe'd, v2
fix "ftrace: store mcount address in rec->ip"
mmiotrace broken in linux-next (8-bit writes only)
ftrace: avoid modifying kprobe'd records
ftrace: freeze kprobe'd records
kprobes: enable clean usage of get_kprobe
ftrace: store mcount address in rec->ip
ftrace: build fix with gcc 4.3
namespacecheck: fixes
ftrace: fix "notrace" filtering priority
ftrace: fix printout
...
Diffstat (limited to 'arch/sparc64/kernel')
-rw-r--r-- | arch/sparc64/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/sparc64/kernel/ftrace.c | 94 | ||||
-rw-r--r-- | arch/sparc64/kernel/sparc64_ksyms.c | 4 |
3 files changed, 97 insertions, 2 deletions
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile index ec4f5ebb1ca6..418b5782096e 100644 --- a/arch/sparc64/kernel/Makefile +++ b/arch/sparc64/kernel/Makefile | |||
@@ -14,6 +14,7 @@ obj-y := process.o setup.o cpu.o idprom.o \ | |||
14 | power.o sbus.o sparc64_ksyms.o chmc.o \ | 14 | power.o sbus.o sparc64_ksyms.o chmc.o \ |
15 | visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o | 15 | visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o |
16 | 16 | ||
17 | obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o | ||
17 | obj-$(CONFIG_STACKTRACE) += stacktrace.o | 18 | obj-$(CONFIG_STACKTRACE) += stacktrace.o |
18 | obj-$(CONFIG_PCI) += ebus.o pci_common.o \ | 19 | obj-$(CONFIG_PCI) += ebus.o pci_common.o \ |
19 | pci_psycho.o pci_sabre.o pci_schizo.o \ | 20 | pci_psycho.o pci_sabre.o pci_schizo.o \ |
diff --git a/arch/sparc64/kernel/ftrace.c b/arch/sparc64/kernel/ftrace.c new file mode 100644 index 000000000000..4298d0aee713 --- /dev/null +++ b/arch/sparc64/kernel/ftrace.c | |||
@@ -0,0 +1,94 @@ | |||
1 | #include <linux/spinlock.h> | ||
2 | #include <linux/hardirq.h> | ||
3 | #include <linux/ftrace.h> | ||
4 | #include <linux/percpu.h> | ||
5 | #include <linux/init.h> | ||
6 | #include <linux/list.h> | ||
7 | |||
8 | #include <asm/ftrace.h> | ||
9 | |||
10 | static const u32 ftrace_nop = 0x01000000; | ||
11 | |||
12 | notrace unsigned char *ftrace_nop_replace(void) | ||
13 | { | ||
14 | return (char *)&ftrace_nop; | ||
15 | } | ||
16 | |||
17 | notrace unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) | ||
18 | { | ||
19 | static u32 call; | ||
20 | s32 off; | ||
21 | |||
22 | off = ((s32)addr - (s32)ip); | ||
23 | call = 0x40000000 | ((u32)off >> 2); | ||
24 | |||
25 | return (unsigned char *) &call; | ||
26 | } | ||
27 | |||
28 | notrace int | ||
29 | ftrace_modify_code(unsigned long ip, unsigned char *old_code, | ||
30 | unsigned char *new_code) | ||
31 | { | ||
32 | u32 old = *(u32 *)old_code; | ||
33 | u32 new = *(u32 *)new_code; | ||
34 | u32 replaced; | ||
35 | int faulted; | ||
36 | |||
37 | __asm__ __volatile__( | ||
38 | "1: cas [%[ip]], %[old], %[new]\n" | ||
39 | " flush %[ip]\n" | ||
40 | " mov 0, %[faulted]\n" | ||
41 | "2:\n" | ||
42 | " .section .fixup,#alloc,#execinstr\n" | ||
43 | " .align 4\n" | ||
44 | "3: sethi %%hi(2b), %[faulted]\n" | ||
45 | " jmpl %[faulted] + %%lo(2b), %%g0\n" | ||
46 | " mov 1, %[faulted]\n" | ||
47 | " .previous\n" | ||
48 | " .section __ex_table,\"a\"\n" | ||
49 | " .align 4\n" | ||
50 | " .word 1b, 3b\n" | ||
51 | " .previous\n" | ||
52 | : "=r" (replaced), [faulted] "=r" (faulted) | ||
53 | : [new] "0" (new), [old] "r" (old), [ip] "r" (ip) | ||
54 | : "memory"); | ||
55 | |||
56 | if (replaced != old && replaced != new) | ||
57 | faulted = 2; | ||
58 | |||
59 | return faulted; | ||
60 | } | ||
61 | |||
62 | notrace int ftrace_update_ftrace_func(ftrace_func_t func) | ||
63 | { | ||
64 | unsigned long ip = (unsigned long)(&ftrace_call); | ||
65 | unsigned char old[MCOUNT_INSN_SIZE], *new; | ||
66 | |||
67 | memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE); | ||
68 | new = ftrace_call_replace(ip, (unsigned long)func); | ||
69 | return ftrace_modify_code(ip, old, new); | ||
70 | } | ||
71 | |||
72 | notrace int ftrace_mcount_set(unsigned long *data) | ||
73 | { | ||
74 | unsigned long ip = (long)(&mcount_call); | ||
75 | unsigned long *addr = data; | ||
76 | unsigned char old[MCOUNT_INSN_SIZE], *new; | ||
77 | |||
78 | /* | ||
79 | * Replace the mcount stub with a pointer to the | ||
80 | * ip recorder function. | ||
81 | */ | ||
82 | memcpy(old, &mcount_call, MCOUNT_INSN_SIZE); | ||
83 | new = ftrace_call_replace(ip, *addr); | ||
84 | *addr = ftrace_modify_code(ip, old, new); | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | |||
90 | int __init ftrace_dyn_arch_init(void *data) | ||
91 | { | ||
92 | ftrace_mcount_set(data); | ||
93 | return 0; | ||
94 | } | ||
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c index 8ac0b99f2c55..49d3ea50c247 100644 --- a/arch/sparc64/kernel/sparc64_ksyms.c +++ b/arch/sparc64/kernel/sparc64_ksyms.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include <asm/ns87303.h> | 53 | #include <asm/ns87303.h> |
54 | #include <asm/timer.h> | 54 | #include <asm/timer.h> |
55 | #include <asm/cpudata.h> | 55 | #include <asm/cpudata.h> |
56 | #include <asm/ftrace.h> | ||
56 | 57 | ||
57 | struct poll { | 58 | struct poll { |
58 | int fd; | 59 | int fd; |
@@ -111,8 +112,7 @@ EXPORT_SYMBOL(__write_trylock); | |||
111 | EXPORT_SYMBOL(smp_call_function); | 112 | EXPORT_SYMBOL(smp_call_function); |
112 | #endif /* CONFIG_SMP */ | 113 | #endif /* CONFIG_SMP */ |
113 | 114 | ||
114 | #if defined(CONFIG_MCOUNT) | 115 | #ifdef CONFIG_MCOUNT |
115 | extern void _mcount(void); | ||
116 | EXPORT_SYMBOL(_mcount); | 116 | EXPORT_SYMBOL(_mcount); |
117 | #endif | 117 | #endif |
118 | 118 | ||