diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-28 12:52:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-28 12:52:25 -0400 |
commit | e946217e4fdaa67681bbabfa8e6b18641921f750 (patch) | |
tree | 057ad6cb5869e20db7b93f154319560b55cbc725 /arch | |
parent | a1865769254dd4eefbc1e857d17bc2a77d5f8580 (diff) | |
parent | 60063a66236c15f5613f91390631e06718689782 (diff) |
Merge branch 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (31 commits)
ftrace: fix current_tracer error return
tracing: fix a build error on alpha
ftrace: use a real variable for ftrace_nop in x86
tracing/ftrace: make boot tracer select the sched_switch tracer
tracepoint: check if the probe has been registered
asm-generic: define DIE_OOPS in asm-generic
trace: fix printk warning for u64
ftrace: warning in kernel/trace/ftrace.c
ftrace: fix build failure
ftrace, powerpc, sparc64, x86: remove notrace from arch ftrace file
ftrace: remove ftrace hash
ftrace: remove mcount set
ftrace: remove daemon
ftrace: disable dynamic ftrace for all archs that use daemon
ftrace: add ftrace warn on to disable ftrace
ftrace: only have ftrace_kill atomic
ftrace: use probe_kernel
ftrace: comment arch ftrace code
ftrace: return error on failed modified text.
ftrace: dynamic ftrace process only text section
...
Diffstat (limited to 'arch')
29 files changed, 62 insertions, 118 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5021db2217ed..9722f8bb506c 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -16,8 +16,7 @@ config ARM | |||
16 | select HAVE_ARCH_KGDB | 16 | select HAVE_ARCH_KGDB |
17 | select HAVE_KPROBES if (!XIP_KERNEL) | 17 | select HAVE_KPROBES if (!XIP_KERNEL) |
18 | select HAVE_KRETPROBES if (HAVE_KPROBES) | 18 | select HAVE_KRETPROBES if (HAVE_KPROBES) |
19 | select HAVE_FTRACE if (!XIP_KERNEL) | 19 | select HAVE_FUNCTION_TRACER if (!XIP_KERNEL) |
20 | select HAVE_DYNAMIC_FTRACE if (HAVE_FTRACE) | ||
21 | select HAVE_GENERIC_DMA_COHERENT | 20 | select HAVE_GENERIC_DMA_COHERENT |
22 | help | 21 | help |
23 | The ARM series is a line of low-power-consumption RISC chip designs | 22 | The ARM series is a line of low-power-consumption RISC chip designs |
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 7a03f2007882..c47f2a3f8f8f 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile | |||
@@ -70,7 +70,7 @@ SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/ | |||
70 | targets := vmlinux vmlinux.lds piggy.gz piggy.o font.o font.c \ | 70 | targets := vmlinux vmlinux.lds piggy.gz piggy.o font.o font.c \ |
71 | head.o misc.o $(OBJS) | 71 | head.o misc.o $(OBJS) |
72 | 72 | ||
73 | ifeq ($(CONFIG_FTRACE),y) | 73 | ifeq ($(CONFIG_FUNCTION_TRACER),y) |
74 | ORIG_CFLAGS := $(KBUILD_CFLAGS) | 74 | ORIG_CFLAGS := $(KBUILD_CFLAGS) |
75 | KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) | 75 | KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) |
76 | endif | 76 | endif |
diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h index 584ef9a8e5a5..39c8bc1a006a 100644 --- a/arch/arm/include/asm/ftrace.h +++ b/arch/arm/include/asm/ftrace.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef _ASM_ARM_FTRACE | 1 | #ifndef _ASM_ARM_FTRACE |
2 | #define _ASM_ARM_FTRACE | 2 | #define _ASM_ARM_FTRACE |
3 | 3 | ||
4 | #ifdef CONFIG_FTRACE | 4 | #ifdef CONFIG_FUNCTION_TRACER |
5 | #define MCOUNT_ADDR ((long)(mcount)) | 5 | #define MCOUNT_ADDR ((long)(mcount)) |
6 | #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ | 6 | #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ |
7 | 7 | ||
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c index 2357b1cf1cf9..c74f766ffc12 100644 --- a/arch/arm/kernel/armksyms.c +++ b/arch/arm/kernel/armksyms.c | |||
@@ -183,6 +183,6 @@ EXPORT_SYMBOL(_find_next_bit_be); | |||
183 | 183 | ||
184 | EXPORT_SYMBOL(copy_page); | 184 | EXPORT_SYMBOL(copy_page); |
185 | 185 | ||
186 | #ifdef CONFIG_FTRACE | 186 | #ifdef CONFIG_FUNCTION_TRACER |
187 | EXPORT_SYMBOL(mcount); | 187 | EXPORT_SYMBOL(mcount); |
188 | #endif | 188 | #endif |
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 3aa14dcc5bab..06269ea375c5 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S | |||
@@ -101,7 +101,7 @@ ENDPROC(ret_from_fork) | |||
101 | #undef CALL | 101 | #undef CALL |
102 | #define CALL(x) .long x | 102 | #define CALL(x) .long x |
103 | 103 | ||
104 | #ifdef CONFIG_FTRACE | 104 | #ifdef CONFIG_FUNCTION_TRACER |
105 | #ifdef CONFIG_DYNAMIC_FTRACE | 105 | #ifdef CONFIG_DYNAMIC_FTRACE |
106 | ENTRY(mcount) | 106 | ENTRY(mcount) |
107 | stmdb sp!, {r0-r3, lr} | 107 | stmdb sp!, {r0-r3, lr} |
@@ -149,7 +149,7 @@ trace: | |||
149 | ftrace_stub: | 149 | ftrace_stub: |
150 | mov pc, lr | 150 | mov pc, lr |
151 | 151 | ||
152 | #endif /* CONFIG_FTRACE */ | 152 | #endif /* CONFIG_FUNCTION_TRACER */ |
153 | 153 | ||
154 | /*============================================================================= | 154 | /*============================================================================= |
155 | * SWI handler | 155 | * SWI handler |
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index 76d50e6091bc..6c90479e8974 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c | |||
@@ -95,19 +95,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func) | |||
95 | return ret; | 95 | return ret; |
96 | } | 96 | } |
97 | 97 | ||
98 | int ftrace_mcount_set(unsigned long *data) | ||
99 | { | ||
100 | unsigned long pc, old; | ||
101 | unsigned long *addr = data; | ||
102 | unsigned char *new; | ||
103 | |||
104 | pc = (unsigned long)&mcount_call; | ||
105 | memcpy(&old, &mcount_call, MCOUNT_INSN_SIZE); | ||
106 | new = ftrace_call_replace(pc, *addr); | ||
107 | *addr = ftrace_modify_code(pc, (unsigned char *)&old, new); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | /* run from kstop_machine */ | 98 | /* run from kstop_machine */ |
112 | int __init ftrace_dyn_arch_init(void *data) | 99 | int __init ftrace_dyn_arch_init(void *data) |
113 | { | 100 | { |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 5b1527883fcb..525c13a4de93 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -108,8 +108,7 @@ config ARCH_NO_VIRT_TO_BUS | |||
108 | config PPC | 108 | config PPC |
109 | bool | 109 | bool |
110 | default y | 110 | default y |
111 | select HAVE_DYNAMIC_FTRACE | 111 | select HAVE_FUNCTION_TRACER |
112 | select HAVE_FTRACE | ||
113 | select ARCH_WANT_OPTIONAL_GPIOLIB | 112 | select ARCH_WANT_OPTIONAL_GPIOLIB |
114 | select HAVE_IDE | 113 | select HAVE_IDE |
115 | select HAVE_IOREMAP_PROT | 114 | select HAVE_IOREMAP_PROT |
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 24dd1a37f8fb..1f0667069940 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile | |||
@@ -122,7 +122,7 @@ KBUILD_CFLAGS += -mcpu=powerpc | |||
122 | endif | 122 | endif |
123 | 123 | ||
124 | # Work around a gcc code-gen bug with -fno-omit-frame-pointer. | 124 | # Work around a gcc code-gen bug with -fno-omit-frame-pointer. |
125 | ifeq ($(CONFIG_FTRACE),y) | 125 | ifeq ($(CONFIG_FUNCTION_TRACER),y) |
126 | KBUILD_CFLAGS += -mno-sched-epilog | 126 | KBUILD_CFLAGS += -mno-sched-epilog |
127 | endif | 127 | endif |
128 | 128 | ||
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h index de921326cca8..b298f7a631e6 100644 --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef _ASM_POWERPC_FTRACE | 1 | #ifndef _ASM_POWERPC_FTRACE |
2 | #define _ASM_POWERPC_FTRACE | 2 | #define _ASM_POWERPC_FTRACE |
3 | 3 | ||
4 | #ifdef CONFIG_FTRACE | 4 | #ifdef CONFIG_FUNCTION_TRACER |
5 | #define MCOUNT_ADDR ((long)(_mcount)) | 5 | #define MCOUNT_ADDR ((long)(_mcount)) |
6 | #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ | 6 | #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ |
7 | 7 | ||
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index fdb58253fa5b..92673b43858d 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -12,7 +12,7 @@ CFLAGS_prom_init.o += -fPIC | |||
12 | CFLAGS_btext.o += -fPIC | 12 | CFLAGS_btext.o += -fPIC |
13 | endif | 13 | endif |
14 | 14 | ||
15 | ifdef CONFIG_FTRACE | 15 | ifdef CONFIG_FUNCTION_TRACER |
16 | # Do not trace early boot code | 16 | # Do not trace early boot code |
17 | CFLAGS_REMOVE_cputable.o = -pg -mno-sched-epilog | 17 | CFLAGS_REMOVE_cputable.o = -pg -mno-sched-epilog |
18 | CFLAGS_REMOVE_prom_init.o = -pg -mno-sched-epilog | 18 | CFLAGS_REMOVE_prom_init.o = -pg -mno-sched-epilog |
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 1cbbf7033641..7ecc0d1855c3 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S | |||
@@ -1158,7 +1158,7 @@ machine_check_in_rtas: | |||
1158 | 1158 | ||
1159 | #endif /* CONFIG_PPC_RTAS */ | 1159 | #endif /* CONFIG_PPC_RTAS */ |
1160 | 1160 | ||
1161 | #ifdef CONFIG_FTRACE | 1161 | #ifdef CONFIG_FUNCTION_TRACER |
1162 | #ifdef CONFIG_DYNAMIC_FTRACE | 1162 | #ifdef CONFIG_DYNAMIC_FTRACE |
1163 | _GLOBAL(mcount) | 1163 | _GLOBAL(mcount) |
1164 | _GLOBAL(_mcount) | 1164 | _GLOBAL(_mcount) |
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index fd8b4bae9b04..e6d52845854f 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S | |||
@@ -884,7 +884,7 @@ _GLOBAL(enter_prom) | |||
884 | mtlr r0 | 884 | mtlr r0 |
885 | blr | 885 | blr |
886 | 886 | ||
887 | #ifdef CONFIG_FTRACE | 887 | #ifdef CONFIG_FUNCTION_TRACER |
888 | #ifdef CONFIG_DYNAMIC_FTRACE | 888 | #ifdef CONFIG_DYNAMIC_FTRACE |
889 | _GLOBAL(mcount) | 889 | _GLOBAL(mcount) |
890 | _GLOBAL(_mcount) | 890 | _GLOBAL(_mcount) |
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c index 3855ceb937b0..f4b006ed0ab1 100644 --- a/arch/powerpc/kernel/ftrace.c +++ b/arch/powerpc/kernel/ftrace.c | |||
@@ -28,17 +28,17 @@ static unsigned int ftrace_nop = 0x60000000; | |||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | 30 | ||
31 | static unsigned int notrace ftrace_calc_offset(long ip, long addr) | 31 | static unsigned int ftrace_calc_offset(long ip, long addr) |
32 | { | 32 | { |
33 | return (int)(addr - ip); | 33 | return (int)(addr - ip); |
34 | } | 34 | } |
35 | 35 | ||
36 | notrace unsigned char *ftrace_nop_replace(void) | 36 | unsigned char *ftrace_nop_replace(void) |
37 | { | 37 | { |
38 | return (char *)&ftrace_nop; | 38 | return (char *)&ftrace_nop; |
39 | } | 39 | } |
40 | 40 | ||
41 | notrace unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) | 41 | unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) |
42 | { | 42 | { |
43 | static unsigned int op; | 43 | static unsigned int op; |
44 | 44 | ||
@@ -68,7 +68,7 @@ notrace unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) | |||
68 | # define _ASM_PTR " .long " | 68 | # define _ASM_PTR " .long " |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | notrace int | 71 | int |
72 | ftrace_modify_code(unsigned long ip, unsigned char *old_code, | 72 | ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
73 | unsigned char *new_code) | 73 | unsigned char *new_code) |
74 | { | 74 | { |
@@ -113,7 +113,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code, | |||
113 | return faulted; | 113 | return faulted; |
114 | } | 114 | } |
115 | 115 | ||
116 | notrace int ftrace_update_ftrace_func(ftrace_func_t func) | 116 | int ftrace_update_ftrace_func(ftrace_func_t func) |
117 | { | 117 | { |
118 | unsigned long ip = (unsigned long)(&ftrace_call); | 118 | unsigned long ip = (unsigned long)(&ftrace_call); |
119 | unsigned char old[MCOUNT_INSN_SIZE], *new; | 119 | unsigned char old[MCOUNT_INSN_SIZE], *new; |
@@ -126,23 +126,6 @@ notrace int ftrace_update_ftrace_func(ftrace_func_t func) | |||
126 | return ret; | 126 | return ret; |
127 | } | 127 | } |
128 | 128 | ||
129 | notrace int ftrace_mcount_set(unsigned long *data) | ||
130 | { | ||
131 | unsigned long ip = (long)(&mcount_call); | ||
132 | unsigned long *addr = data; | ||
133 | unsigned char old[MCOUNT_INSN_SIZE], *new; | ||
134 | |||
135 | /* | ||
136 | * Replace the mcount stub with a pointer to the | ||
137 | * ip recorder function. | ||
138 | */ | ||
139 | memcpy(old, &mcount_call, MCOUNT_INSN_SIZE); | ||
140 | new = ftrace_call_replace(ip, *addr); | ||
141 | *addr = ftrace_modify_code(ip, old, new); | ||
142 | |||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | int __init ftrace_dyn_arch_init(void *data) | 129 | int __init ftrace_dyn_arch_init(void *data) |
147 | { | 130 | { |
148 | /* This is running in kstop_machine */ | 131 | /* This is running in kstop_machine */ |
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c index 8edc2359c419..260089dccfb0 100644 --- a/arch/powerpc/kernel/ppc_ksyms.c +++ b/arch/powerpc/kernel/ppc_ksyms.c | |||
@@ -68,7 +68,7 @@ EXPORT_SYMBOL(single_step_exception); | |||
68 | EXPORT_SYMBOL(sys_sigreturn); | 68 | EXPORT_SYMBOL(sys_sigreturn); |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #ifdef CONFIG_FTRACE | 71 | #ifdef CONFIG_FUNCTION_TRACER |
72 | EXPORT_SYMBOL(_mcount); | 72 | EXPORT_SYMBOL(_mcount); |
73 | #endif | 73 | #endif |
74 | 74 | ||
diff --git a/arch/powerpc/platforms/powermac/Makefile b/arch/powerpc/platforms/powermac/Makefile index be60d64be7ad..50f169392551 100644 --- a/arch/powerpc/platforms/powermac/Makefile +++ b/arch/powerpc/platforms/powermac/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | CFLAGS_bootx_init.o += -fPIC | 1 | CFLAGS_bootx_init.o += -fPIC |
2 | 2 | ||
3 | ifdef CONFIG_FTRACE | 3 | ifdef CONFIG_FUNCTION_TRACER |
4 | # Do not trace early boot code | 4 | # Do not trace early boot code |
5 | CFLAGS_REMOVE_bootx_init.o = -pg -mno-sched-epilog | 5 | CFLAGS_REMOVE_bootx_init.o = -pg -mno-sched-epilog |
6 | endif | 6 | endif |
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig index 035b15af90d8..3b96e70b4670 100644 --- a/arch/sparc64/Kconfig +++ b/arch/sparc64/Kconfig | |||
@@ -11,8 +11,7 @@ config SPARC | |||
11 | config SPARC64 | 11 | config SPARC64 |
12 | bool | 12 | bool |
13 | default y | 13 | default y |
14 | select HAVE_DYNAMIC_FTRACE | 14 | select HAVE_FUNCTION_TRACER |
15 | select HAVE_FTRACE | ||
16 | select HAVE_IDE | 15 | select HAVE_IDE |
17 | select HAVE_LMB | 16 | select HAVE_LMB |
18 | select HAVE_ARCH_KGDB | 17 | select HAVE_ARCH_KGDB |
diff --git a/arch/sparc64/Kconfig.debug b/arch/sparc64/Kconfig.debug index d6d32d178fc8..c40515c06690 100644 --- a/arch/sparc64/Kconfig.debug +++ b/arch/sparc64/Kconfig.debug | |||
@@ -33,7 +33,7 @@ config DEBUG_PAGEALLOC | |||
33 | 33 | ||
34 | config MCOUNT | 34 | config MCOUNT |
35 | bool | 35 | bool |
36 | depends on STACK_DEBUG || FTRACE | 36 | depends on STACK_DEBUG || FUNCTION_TRACER |
37 | default y | 37 | default y |
38 | 38 | ||
39 | config FRAME_POINTER | 39 | config FRAME_POINTER |
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile index c0b8009ab196..b3e0b986bef8 100644 --- a/arch/sparc64/kernel/Makefile +++ b/arch/sparc64/kernel/Makefile | |||
@@ -5,6 +5,8 @@ | |||
5 | EXTRA_AFLAGS := -ansi | 5 | EXTRA_AFLAGS := -ansi |
6 | EXTRA_CFLAGS := -Werror | 6 | EXTRA_CFLAGS := -Werror |
7 | 7 | ||
8 | CFLAGS_REMOVE_ftrace.o = -pg | ||
9 | |||
8 | extra-y := head.o init_task.o vmlinux.lds | 10 | extra-y := head.o init_task.o vmlinux.lds |
9 | 11 | ||
10 | obj-y := process.o setup.o cpu.o idprom.o reboot.o \ | 12 | obj-y := process.o setup.o cpu.o idprom.o reboot.o \ |
diff --git a/arch/sparc64/kernel/ftrace.c b/arch/sparc64/kernel/ftrace.c index 4298d0aee713..d0218e73f982 100644 --- a/arch/sparc64/kernel/ftrace.c +++ b/arch/sparc64/kernel/ftrace.c | |||
@@ -9,12 +9,12 @@ | |||
9 | 9 | ||
10 | static const u32 ftrace_nop = 0x01000000; | 10 | static const u32 ftrace_nop = 0x01000000; |
11 | 11 | ||
12 | notrace unsigned char *ftrace_nop_replace(void) | 12 | unsigned char *ftrace_nop_replace(void) |
13 | { | 13 | { |
14 | return (char *)&ftrace_nop; | 14 | return (char *)&ftrace_nop; |
15 | } | 15 | } |
16 | 16 | ||
17 | notrace unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) | 17 | unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) |
18 | { | 18 | { |
19 | static u32 call; | 19 | static u32 call; |
20 | s32 off; | 20 | s32 off; |
@@ -25,7 +25,7 @@ notrace unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) | |||
25 | return (unsigned char *) &call; | 25 | return (unsigned char *) &call; |
26 | } | 26 | } |
27 | 27 | ||
28 | notrace int | 28 | int |
29 | ftrace_modify_code(unsigned long ip, unsigned char *old_code, | 29 | ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
30 | unsigned char *new_code) | 30 | unsigned char *new_code) |
31 | { | 31 | { |
@@ -59,7 +59,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code, | |||
59 | return faulted; | 59 | return faulted; |
60 | } | 60 | } |
61 | 61 | ||
62 | notrace int ftrace_update_ftrace_func(ftrace_func_t func) | 62 | int ftrace_update_ftrace_func(ftrace_func_t func) |
63 | { | 63 | { |
64 | unsigned long ip = (unsigned long)(&ftrace_call); | 64 | unsigned long ip = (unsigned long)(&ftrace_call); |
65 | unsigned char old[MCOUNT_INSN_SIZE], *new; | 65 | unsigned char old[MCOUNT_INSN_SIZE], *new; |
@@ -69,24 +69,6 @@ notrace int ftrace_update_ftrace_func(ftrace_func_t func) | |||
69 | return ftrace_modify_code(ip, old, new); | 69 | return ftrace_modify_code(ip, old, new); |
70 | } | 70 | } |
71 | 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) | 72 | int __init ftrace_dyn_arch_init(void *data) |
91 | { | 73 | { |
92 | ftrace_mcount_set(data); | 74 | ftrace_mcount_set(data); |
diff --git a/arch/sparc64/lib/mcount.S b/arch/sparc64/lib/mcount.S index fad90ddb3a28..7ce9c65f3592 100644 --- a/arch/sparc64/lib/mcount.S +++ b/arch/sparc64/lib/mcount.S | |||
@@ -93,7 +93,7 @@ mcount: | |||
93 | nop | 93 | nop |
94 | 1: | 94 | 1: |
95 | #endif | 95 | #endif |
96 | #ifdef CONFIG_FTRACE | 96 | #ifdef CONFIG_FUNCTION_TRACER |
97 | #ifdef CONFIG_DYNAMIC_FTRACE | 97 | #ifdef CONFIG_DYNAMIC_FTRACE |
98 | mov %o7, %o0 | 98 | mov %o7, %o0 |
99 | .globl mcount_call | 99 | .globl mcount_call |
@@ -119,7 +119,7 @@ mcount_call: | |||
119 | .size _mcount,.-_mcount | 119 | .size _mcount,.-_mcount |
120 | .size mcount,.-mcount | 120 | .size mcount,.-mcount |
121 | 121 | ||
122 | #ifdef CONFIG_FTRACE | 122 | #ifdef CONFIG_FUNCTION_TRACER |
123 | .globl ftrace_stub | 123 | .globl ftrace_stub |
124 | .type ftrace_stub,#function | 124 | .type ftrace_stub,#function |
125 | ftrace_stub: | 125 | ftrace_stub: |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 350bee1d54dc..d11d7b513191 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -28,7 +28,7 @@ config X86 | |||
28 | select HAVE_KRETPROBES | 28 | select HAVE_KRETPROBES |
29 | select HAVE_FTRACE_MCOUNT_RECORD | 29 | select HAVE_FTRACE_MCOUNT_RECORD |
30 | select HAVE_DYNAMIC_FTRACE | 30 | select HAVE_DYNAMIC_FTRACE |
31 | select HAVE_FTRACE | 31 | select HAVE_FUNCTION_TRACER |
32 | select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) | 32 | select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) |
33 | select HAVE_ARCH_KGDB if !X86_VOYAGER | 33 | select HAVE_ARCH_KGDB if !X86_VOYAGER |
34 | select HAVE_ARCH_TRACEHOOK | 34 | select HAVE_ARCH_TRACEHOOK |
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h index 47f7e65e6c1d..9e8bc29b8b17 100644 --- a/arch/x86/include/asm/ftrace.h +++ b/arch/x86/include/asm/ftrace.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef _ASM_X86_FTRACE_H | 1 | #ifndef _ASM_X86_FTRACE_H |
2 | #define _ASM_X86_FTRACE_H | 2 | #define _ASM_X86_FTRACE_H |
3 | 3 | ||
4 | #ifdef CONFIG_FTRACE | 4 | #ifdef CONFIG_FUNCTION_TRACER |
5 | #define MCOUNT_ADDR ((long)(mcount)) | 5 | #define MCOUNT_ADDR ((long)(mcount)) |
6 | #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ | 6 | #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ |
7 | 7 | ||
@@ -19,6 +19,6 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) | |||
19 | } | 19 | } |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | #endif /* CONFIG_FTRACE */ | 22 | #endif /* CONFIG_FUNCTION_TRACER */ |
23 | 23 | ||
24 | #endif /* _ASM_X86_FTRACE_H */ | 24 | #endif /* _ASM_X86_FTRACE_H */ |
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index d7e5a58ee22f..e489ff9cb3e2 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile | |||
@@ -6,11 +6,12 @@ extra-y := head_$(BITS).o head$(BITS).o head.o init_task.o vmlinu | |||
6 | 6 | ||
7 | CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE) | 7 | CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE) |
8 | 8 | ||
9 | ifdef CONFIG_FTRACE | 9 | ifdef CONFIG_FUNCTION_TRACER |
10 | # Do not profile debug and lowlevel utilities | 10 | # Do not profile debug and lowlevel utilities |
11 | CFLAGS_REMOVE_tsc.o = -pg | 11 | CFLAGS_REMOVE_tsc.o = -pg |
12 | CFLAGS_REMOVE_rtc.o = -pg | 12 | CFLAGS_REMOVE_rtc.o = -pg |
13 | CFLAGS_REMOVE_paravirt-spinlocks.o = -pg | 13 | CFLAGS_REMOVE_paravirt-spinlocks.o = -pg |
14 | CFLAGS_REMOVE_ftrace.o = -pg | ||
14 | endif | 15 | endif |
15 | 16 | ||
16 | # | 17 | # |
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S index dd65143941a8..28b597ef9ca1 100644 --- a/arch/x86/kernel/entry_32.S +++ b/arch/x86/kernel/entry_32.S | |||
@@ -1149,7 +1149,7 @@ ENDPROC(xen_failsafe_callback) | |||
1149 | 1149 | ||
1150 | #endif /* CONFIG_XEN */ | 1150 | #endif /* CONFIG_XEN */ |
1151 | 1151 | ||
1152 | #ifdef CONFIG_FTRACE | 1152 | #ifdef CONFIG_FUNCTION_TRACER |
1153 | #ifdef CONFIG_DYNAMIC_FTRACE | 1153 | #ifdef CONFIG_DYNAMIC_FTRACE |
1154 | 1154 | ||
1155 | ENTRY(mcount) | 1155 | ENTRY(mcount) |
@@ -1204,7 +1204,7 @@ trace: | |||
1204 | jmp ftrace_stub | 1204 | jmp ftrace_stub |
1205 | END(mcount) | 1205 | END(mcount) |
1206 | #endif /* CONFIG_DYNAMIC_FTRACE */ | 1206 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
1207 | #endif /* CONFIG_FTRACE */ | 1207 | #endif /* CONFIG_FUNCTION_TRACER */ |
1208 | 1208 | ||
1209 | .section .rodata,"a" | 1209 | .section .rodata,"a" |
1210 | #include "syscall_table_32.S" | 1210 | #include "syscall_table_32.S" |
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index 09e7145484c5..b86f332c96a6 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S | |||
@@ -61,7 +61,7 @@ | |||
61 | 61 | ||
62 | .code64 | 62 | .code64 |
63 | 63 | ||
64 | #ifdef CONFIG_FTRACE | 64 | #ifdef CONFIG_FUNCTION_TRACER |
65 | #ifdef CONFIG_DYNAMIC_FTRACE | 65 | #ifdef CONFIG_DYNAMIC_FTRACE |
66 | ENTRY(mcount) | 66 | ENTRY(mcount) |
67 | retq | 67 | retq |
@@ -138,7 +138,7 @@ trace: | |||
138 | jmp ftrace_stub | 138 | jmp ftrace_stub |
139 | END(mcount) | 139 | END(mcount) |
140 | #endif /* CONFIG_DYNAMIC_FTRACE */ | 140 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
141 | #endif /* CONFIG_FTRACE */ | 141 | #endif /* CONFIG_FUNCTION_TRACER */ |
142 | 142 | ||
143 | #ifndef CONFIG_PREEMPT | 143 | #ifndef CONFIG_PREEMPT |
144 | #define retint_kernel retint_restore_args | 144 | #define retint_kernel retint_restore_args |
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index d073d981a730..50ea0ac8c9bf 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c | |||
@@ -21,8 +21,7 @@ | |||
21 | #include <asm/nops.h> | 21 | #include <asm/nops.h> |
22 | 22 | ||
23 | 23 | ||
24 | /* Long is fine, even if it is only 4 bytes ;-) */ | 24 | static unsigned char ftrace_nop[MCOUNT_INSN_SIZE]; |
25 | static unsigned long *ftrace_nop; | ||
26 | 25 | ||
27 | union ftrace_code_union { | 26 | union ftrace_code_union { |
28 | char code[MCOUNT_INSN_SIZE]; | 27 | char code[MCOUNT_INSN_SIZE]; |
@@ -33,17 +32,17 @@ union ftrace_code_union { | |||
33 | }; | 32 | }; |
34 | 33 | ||
35 | 34 | ||
36 | static int notrace ftrace_calc_offset(long ip, long addr) | 35 | static int ftrace_calc_offset(long ip, long addr) |
37 | { | 36 | { |
38 | return (int)(addr - ip); | 37 | return (int)(addr - ip); |
39 | } | 38 | } |
40 | 39 | ||
41 | notrace unsigned char *ftrace_nop_replace(void) | 40 | unsigned char *ftrace_nop_replace(void) |
42 | { | 41 | { |
43 | return (char *)ftrace_nop; | 42 | return ftrace_nop; |
44 | } | 43 | } |
45 | 44 | ||
46 | notrace unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) | 45 | unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) |
47 | { | 46 | { |
48 | static union ftrace_code_union calc; | 47 | static union ftrace_code_union calc; |
49 | 48 | ||
@@ -57,7 +56,7 @@ notrace unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) | |||
57 | return calc.code; | 56 | return calc.code; |
58 | } | 57 | } |
59 | 58 | ||
60 | notrace int | 59 | int |
61 | ftrace_modify_code(unsigned long ip, unsigned char *old_code, | 60 | ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
62 | unsigned char *new_code) | 61 | unsigned char *new_code) |
63 | { | 62 | { |
@@ -66,26 +65,31 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code, | |||
66 | /* | 65 | /* |
67 | * Note: Due to modules and __init, code can | 66 | * Note: Due to modules and __init, code can |
68 | * disappear and change, we need to protect against faulting | 67 | * disappear and change, we need to protect against faulting |
69 | * as well as code changing. | 68 | * as well as code changing. We do this by using the |
69 | * probe_kernel_* functions. | ||
70 | * | 70 | * |
71 | * No real locking needed, this code is run through | 71 | * No real locking needed, this code is run through |
72 | * kstop_machine, or before SMP starts. | 72 | * kstop_machine, or before SMP starts. |
73 | */ | 73 | */ |
74 | if (__copy_from_user_inatomic(replaced, (char __user *)ip, MCOUNT_INSN_SIZE)) | ||
75 | return 1; | ||
76 | 74 | ||
75 | /* read the text we want to modify */ | ||
76 | if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE)) | ||
77 | return -EFAULT; | ||
78 | |||
79 | /* Make sure it is what we expect it to be */ | ||
77 | if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0) | 80 | if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0) |
78 | return 2; | 81 | return -EINVAL; |
79 | 82 | ||
80 | WARN_ON_ONCE(__copy_to_user_inatomic((char __user *)ip, new_code, | 83 | /* replace the text with the new text */ |
81 | MCOUNT_INSN_SIZE)); | 84 | if (probe_kernel_write((void *)ip, new_code, MCOUNT_INSN_SIZE)) |
85 | return -EPERM; | ||
82 | 86 | ||
83 | sync_core(); | 87 | sync_core(); |
84 | 88 | ||
85 | return 0; | 89 | return 0; |
86 | } | 90 | } |
87 | 91 | ||
88 | notrace int ftrace_update_ftrace_func(ftrace_func_t func) | 92 | int ftrace_update_ftrace_func(ftrace_func_t func) |
89 | { | 93 | { |
90 | unsigned long ip = (unsigned long)(&ftrace_call); | 94 | unsigned long ip = (unsigned long)(&ftrace_call); |
91 | unsigned char old[MCOUNT_INSN_SIZE], *new; | 95 | unsigned char old[MCOUNT_INSN_SIZE], *new; |
@@ -98,13 +102,6 @@ notrace int ftrace_update_ftrace_func(ftrace_func_t func) | |||
98 | return ret; | 102 | return ret; |
99 | } | 103 | } |
100 | 104 | ||
101 | notrace int ftrace_mcount_set(unsigned long *data) | ||
102 | { | ||
103 | /* mcount is initialized as a nop */ | ||
104 | *data = 0; | ||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | int __init ftrace_dyn_arch_init(void *data) | 105 | int __init ftrace_dyn_arch_init(void *data) |
109 | { | 106 | { |
110 | extern const unsigned char ftrace_test_p6nop[]; | 107 | extern const unsigned char ftrace_test_p6nop[]; |
@@ -127,9 +124,6 @@ int __init ftrace_dyn_arch_init(void *data) | |||
127 | * TODO: check the cpuid to determine the best nop. | 124 | * TODO: check the cpuid to determine the best nop. |
128 | */ | 125 | */ |
129 | asm volatile ( | 126 | asm volatile ( |
130 | "jmp ftrace_test_jmp\n" | ||
131 | /* This code needs to stay around */ | ||
132 | ".section .text, \"ax\"\n" | ||
133 | "ftrace_test_jmp:" | 127 | "ftrace_test_jmp:" |
134 | "jmp ftrace_test_p6nop\n" | 128 | "jmp ftrace_test_p6nop\n" |
135 | "nop\n" | 129 | "nop\n" |
@@ -140,8 +134,6 @@ int __init ftrace_dyn_arch_init(void *data) | |||
140 | "jmp 1f\n" | 134 | "jmp 1f\n" |
141 | "ftrace_test_nop5:" | 135 | "ftrace_test_nop5:" |
142 | ".byte 0x66,0x66,0x66,0x66,0x90\n" | 136 | ".byte 0x66,0x66,0x66,0x66,0x90\n" |
143 | "jmp 1f\n" | ||
144 | ".previous\n" | ||
145 | "1:" | 137 | "1:" |
146 | ".section .fixup, \"ax\"\n" | 138 | ".section .fixup, \"ax\"\n" |
147 | "2: movl $1, %0\n" | 139 | "2: movl $1, %0\n" |
@@ -156,15 +148,15 @@ int __init ftrace_dyn_arch_init(void *data) | |||
156 | switch (faulted) { | 148 | switch (faulted) { |
157 | case 0: | 149 | case 0: |
158 | pr_info("ftrace: converting mcount calls to 0f 1f 44 00 00\n"); | 150 | pr_info("ftrace: converting mcount calls to 0f 1f 44 00 00\n"); |
159 | ftrace_nop = (unsigned long *)ftrace_test_p6nop; | 151 | memcpy(ftrace_nop, ftrace_test_p6nop, MCOUNT_INSN_SIZE); |
160 | break; | 152 | break; |
161 | case 1: | 153 | case 1: |
162 | pr_info("ftrace: converting mcount calls to 66 66 66 66 90\n"); | 154 | pr_info("ftrace: converting mcount calls to 66 66 66 66 90\n"); |
163 | ftrace_nop = (unsigned long *)ftrace_test_nop5; | 155 | memcpy(ftrace_nop, ftrace_test_nop5, MCOUNT_INSN_SIZE); |
164 | break; | 156 | break; |
165 | case 2: | 157 | case 2: |
166 | pr_info("ftrace: converting mcount calls to jmp . + 5\n"); | 158 | pr_info("ftrace: converting mcount calls to jmp . + 5\n"); |
167 | ftrace_nop = (unsigned long *)ftrace_test_jmp; | 159 | memcpy(ftrace_nop, ftrace_test_jmp, MCOUNT_INSN_SIZE); |
168 | break; | 160 | break; |
169 | } | 161 | } |
170 | 162 | ||
diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c index dd7ebee446af..43cec6bdda63 100644 --- a/arch/x86/kernel/i386_ksyms_32.c +++ b/arch/x86/kernel/i386_ksyms_32.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <asm/desc.h> | 5 | #include <asm/desc.h> |
6 | #include <asm/ftrace.h> | 6 | #include <asm/ftrace.h> |
7 | 7 | ||
8 | #ifdef CONFIG_FTRACE | 8 | #ifdef CONFIG_FUNCTION_TRACER |
9 | /* mcount is defined in assembly */ | 9 | /* mcount is defined in assembly */ |
10 | EXPORT_SYMBOL(mcount); | 10 | EXPORT_SYMBOL(mcount); |
11 | #endif | 11 | #endif |
diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c index b545f371b5f5..695e426aa354 100644 --- a/arch/x86/kernel/x8664_ksyms_64.c +++ b/arch/x86/kernel/x8664_ksyms_64.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <asm/desc.h> | 12 | #include <asm/desc.h> |
13 | #include <asm/ftrace.h> | 13 | #include <asm/ftrace.h> |
14 | 14 | ||
15 | #ifdef CONFIG_FTRACE | 15 | #ifdef CONFIG_FUNCTION_TRACER |
16 | /* mcount is defined in assembly */ | 16 | /* mcount is defined in assembly */ |
17 | EXPORT_SYMBOL(mcount); | 17 | EXPORT_SYMBOL(mcount); |
18 | #endif | 18 | #endif |
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile index 313947940a1a..6dcefba7836f 100644 --- a/arch/x86/xen/Makefile +++ b/arch/x86/xen/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | ifdef CONFIG_FTRACE | 1 | ifdef CONFIG_FUNCTION_TRACER |
2 | # Do not profile debug and lowlevel utilities | 2 | # Do not profile debug and lowlevel utilities |
3 | CFLAGS_REMOVE_spinlock.o = -pg | 3 | CFLAGS_REMOVE_spinlock.o = -pg |
4 | CFLAGS_REMOVE_time.o = -pg | 4 | CFLAGS_REMOVE_time.o = -pg |