aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/Makefile3
-rw-r--r--arch/x86/kernel/entry_32.S4
-rw-r--r--arch/x86/kernel/entry_64.S4
-rw-r--r--arch/x86/kernel/ftrace.c34
-rw-r--r--arch/x86/kernel/i386_ksyms_32.c2
-rw-r--r--arch/x86/kernel/x8664_ksyms_64.c2
6 files changed, 24 insertions, 25 deletions
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
7CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE) 7CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE)
8 8
9ifdef CONFIG_FTRACE 9ifdef CONFIG_FUNCTION_TRACER
10# Do not profile debug and lowlevel utilities 10# Do not profile debug and lowlevel utilities
11CFLAGS_REMOVE_tsc.o = -pg 11CFLAGS_REMOVE_tsc.o = -pg
12CFLAGS_REMOVE_rtc.o = -pg 12CFLAGS_REMOVE_rtc.o = -pg
13CFLAGS_REMOVE_paravirt-spinlocks.o = -pg 13CFLAGS_REMOVE_paravirt-spinlocks.o = -pg
14CFLAGS_REMOVE_ftrace.o = -pg
14endif 15endif
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
1155ENTRY(mcount) 1155ENTRY(mcount)
@@ -1204,7 +1204,7 @@ trace:
1204 jmp ftrace_stub 1204 jmp ftrace_stub
1205END(mcount) 1205END(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
66ENTRY(mcount) 66ENTRY(mcount)
67 retq 67 retq
@@ -138,7 +138,7 @@ trace:
138 jmp ftrace_stub 138 jmp ftrace_stub
139END(mcount) 139END(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..b1e5e2244eca 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -33,17 +33,17 @@ union ftrace_code_union {
33}; 33};
34 34
35 35
36static int notrace ftrace_calc_offset(long ip, long addr) 36static int ftrace_calc_offset(long ip, long addr)
37{ 37{
38 return (int)(addr - ip); 38 return (int)(addr - ip);
39} 39}
40 40
41notrace unsigned char *ftrace_nop_replace(void) 41unsigned char *ftrace_nop_replace(void)
42{ 42{
43 return (char *)ftrace_nop; 43 return (char *)ftrace_nop;
44} 44}
45 45
46notrace unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) 46unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
47{ 47{
48 static union ftrace_code_union calc; 48 static union ftrace_code_union calc;
49 49
@@ -57,7 +57,7 @@ notrace unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
57 return calc.code; 57 return calc.code;
58} 58}
59 59
60notrace int 60int
61ftrace_modify_code(unsigned long ip, unsigned char *old_code, 61ftrace_modify_code(unsigned long ip, unsigned char *old_code,
62 unsigned char *new_code) 62 unsigned char *new_code)
63{ 63{
@@ -66,26 +66,31 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
66 /* 66 /*
67 * Note: Due to modules and __init, code can 67 * Note: Due to modules and __init, code can
68 * disappear and change, we need to protect against faulting 68 * disappear and change, we need to protect against faulting
69 * as well as code changing. 69 * as well as code changing. We do this by using the
70 * probe_kernel_* functions.
70 * 71 *
71 * No real locking needed, this code is run through 72 * No real locking needed, this code is run through
72 * kstop_machine, or before SMP starts. 73 * kstop_machine, or before SMP starts.
73 */ 74 */
74 if (__copy_from_user_inatomic(replaced, (char __user *)ip, MCOUNT_INSN_SIZE))
75 return 1;
76 75
76 /* read the text we want to modify */
77 if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
78 return -EFAULT;
79
80 /* Make sure it is what we expect it to be */
77 if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0) 81 if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0)
78 return 2; 82 return -EINVAL;
79 83
80 WARN_ON_ONCE(__copy_to_user_inatomic((char __user *)ip, new_code, 84 /* replace the text with the new text */
81 MCOUNT_INSN_SIZE)); 85 if (probe_kernel_write((void *)ip, new_code, MCOUNT_INSN_SIZE))
86 return -EPERM;
82 87
83 sync_core(); 88 sync_core();
84 89
85 return 0; 90 return 0;
86} 91}
87 92
88notrace int ftrace_update_ftrace_func(ftrace_func_t func) 93int ftrace_update_ftrace_func(ftrace_func_t func)
89{ 94{
90 unsigned long ip = (unsigned long)(&ftrace_call); 95 unsigned long ip = (unsigned long)(&ftrace_call);
91 unsigned char old[MCOUNT_INSN_SIZE], *new; 96 unsigned char old[MCOUNT_INSN_SIZE], *new;
@@ -98,13 +103,6 @@ notrace int ftrace_update_ftrace_func(ftrace_func_t func)
98 return ret; 103 return ret;
99} 104}
100 105
101notrace int ftrace_mcount_set(unsigned long *data)
102{
103 /* mcount is initialized as a nop */
104 *data = 0;
105 return 0;
106}
107
108int __init ftrace_dyn_arch_init(void *data) 106int __init ftrace_dyn_arch_init(void *data)
109{ 107{
110 extern const unsigned char ftrace_test_p6nop[]; 108 extern const unsigned char ftrace_test_p6nop[];
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 */
10EXPORT_SYMBOL(mcount); 10EXPORT_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 */
17EXPORT_SYMBOL(mcount); 17EXPORT_SYMBOL(mcount);
18#endif 18#endif