diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/alpha/include/asm/hardirq.h | 13 | ||||
-rw-r--r-- | arch/avr32/include/asm/hardirq.h | 11 | ||||
-rw-r--r-- | arch/ia64/Kconfig | 3 | ||||
-rw-r--r-- | arch/ia64/include/asm/ftrace.h | 28 | ||||
-rw-r--r-- | arch/ia64/include/asm/hardirq.h | 10 | ||||
-rw-r--r-- | arch/ia64/kernel/Makefile | 5 | ||||
-rw-r--r-- | arch/ia64/kernel/entry.S | 100 | ||||
-rw-r--r-- | arch/ia64/kernel/ftrace.c | 206 | ||||
-rw-r--r-- | arch/ia64/kernel/ia64_ksyms.c | 6 | ||||
-rw-r--r-- | arch/x86/Kconfig | 1 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/dumpstack.c | 6 | ||||
-rw-r--r-- | arch/x86/kernel/ftrace.c | 49 | ||||
-rw-r--r-- | arch/x86/kernel/process.c | 5 | ||||
-rw-r--r-- | arch/x86/kvm/Kconfig | 3 |
15 files changed, 375 insertions, 75 deletions
diff --git a/arch/alpha/include/asm/hardirq.h b/arch/alpha/include/asm/hardirq.h index d953e234daa8..88971460fa6c 100644 --- a/arch/alpha/include/asm/hardirq.h +++ b/arch/alpha/include/asm/hardirq.h | |||
@@ -14,17 +14,4 @@ typedef struct { | |||
14 | 14 | ||
15 | void ack_bad_irq(unsigned int irq); | 15 | void ack_bad_irq(unsigned int irq); |
16 | 16 | ||
17 | #define HARDIRQ_BITS 12 | ||
18 | |||
19 | /* | ||
20 | * The hardirq mask has to be large enough to have | ||
21 | * space for potentially nestable IRQ sources in the system | ||
22 | * to nest on a single CPU. On Alpha, interrupts are masked at the CPU | ||
23 | * by IPL as well as at the system level. We only have 8 IPLs (UNIX PALcode) | ||
24 | * so we really only have 8 nestable IRQs, but allow some overhead | ||
25 | */ | ||
26 | #if (1 << HARDIRQ_BITS) < 16 | ||
27 | #error HARDIRQ_BITS is too low! | ||
28 | #endif | ||
29 | |||
30 | #endif /* _ALPHA_HARDIRQ_H */ | 17 | #endif /* _ALPHA_HARDIRQ_H */ |
diff --git a/arch/avr32/include/asm/hardirq.h b/arch/avr32/include/asm/hardirq.h index 267354356f60..015bc75ea798 100644 --- a/arch/avr32/include/asm/hardirq.h +++ b/arch/avr32/include/asm/hardirq.h | |||
@@ -20,15 +20,4 @@ void ack_bad_irq(unsigned int irq); | |||
20 | 20 | ||
21 | #endif /* __ASSEMBLY__ */ | 21 | #endif /* __ASSEMBLY__ */ |
22 | 22 | ||
23 | #define HARDIRQ_BITS 12 | ||
24 | |||
25 | /* | ||
26 | * The hardirq mask has to be large enough to have | ||
27 | * space for potentially all IRQ sources in the system | ||
28 | * nesting on a single CPU: | ||
29 | */ | ||
30 | #if (1 << HARDIRQ_BITS) < NR_IRQS | ||
31 | # error HARDIRQ_BITS is too low! | ||
32 | #endif | ||
33 | |||
34 | #endif /* __ASM_AVR32_HARDIRQ_H */ | 23 | #endif /* __ASM_AVR32_HARDIRQ_H */ |
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 6183aeccecf1..8b6a8a554afa 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig | |||
@@ -22,6 +22,9 @@ config IA64 | |||
22 | select HAVE_OPROFILE | 22 | select HAVE_OPROFILE |
23 | select HAVE_KPROBES | 23 | select HAVE_KPROBES |
24 | select HAVE_KRETPROBES | 24 | select HAVE_KRETPROBES |
25 | select HAVE_FTRACE_MCOUNT_RECORD | ||
26 | select HAVE_DYNAMIC_FTRACE if (!ITANIUM) | ||
27 | select HAVE_FUNCTION_TRACER | ||
25 | select HAVE_DMA_ATTRS | 28 | select HAVE_DMA_ATTRS |
26 | select HAVE_KVM | 29 | select HAVE_KVM |
27 | select HAVE_ARCH_TRACEHOOK | 30 | select HAVE_ARCH_TRACEHOOK |
diff --git a/arch/ia64/include/asm/ftrace.h b/arch/ia64/include/asm/ftrace.h new file mode 100644 index 000000000000..d20db3c2a656 --- /dev/null +++ b/arch/ia64/include/asm/ftrace.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef _ASM_IA64_FTRACE_H | ||
2 | #define _ASM_IA64_FTRACE_H | ||
3 | |||
4 | #ifdef CONFIG_FUNCTION_TRACER | ||
5 | #define MCOUNT_INSN_SIZE 32 /* sizeof mcount call */ | ||
6 | |||
7 | #ifndef __ASSEMBLY__ | ||
8 | extern void _mcount(unsigned long pfs, unsigned long r1, unsigned long b0, unsigned long r0); | ||
9 | #define mcount _mcount | ||
10 | |||
11 | #include <asm/kprobes.h> | ||
12 | /* In IA64, MCOUNT_ADDR is set in link time, so it's not a constant at compile time */ | ||
13 | #define MCOUNT_ADDR (((struct fnptr *)mcount)->ip) | ||
14 | #define FTRACE_ADDR (((struct fnptr *)ftrace_caller)->ip) | ||
15 | |||
16 | static inline unsigned long ftrace_call_adjust(unsigned long addr) | ||
17 | { | ||
18 | /* second bundle, insn 2 */ | ||
19 | return addr - 0x12; | ||
20 | } | ||
21 | |||
22 | struct dyn_arch_ftrace { | ||
23 | }; | ||
24 | #endif | ||
25 | |||
26 | #endif /* CONFIG_FUNCTION_TRACER */ | ||
27 | |||
28 | #endif /* _ASM_IA64_FTRACE_H */ | ||
diff --git a/arch/ia64/include/asm/hardirq.h b/arch/ia64/include/asm/hardirq.h index 140e495b8e0e..d514cd9edb49 100644 --- a/arch/ia64/include/asm/hardirq.h +++ b/arch/ia64/include/asm/hardirq.h | |||
@@ -20,16 +20,6 @@ | |||
20 | 20 | ||
21 | #define local_softirq_pending() (local_cpu_data->softirq_pending) | 21 | #define local_softirq_pending() (local_cpu_data->softirq_pending) |
22 | 22 | ||
23 | #define HARDIRQ_BITS 14 | ||
24 | |||
25 | /* | ||
26 | * The hardirq mask has to be large enough to have space for potentially all IRQ sources | ||
27 | * in the system nesting on a single CPU: | ||
28 | */ | ||
29 | #if (1 << HARDIRQ_BITS) < NR_IRQS | ||
30 | # error HARDIRQ_BITS is too low! | ||
31 | #endif | ||
32 | |||
33 | extern void __iomem *ipi_base_addr; | 23 | extern void __iomem *ipi_base_addr; |
34 | 24 | ||
35 | void ack_bad_irq(unsigned int irq); | 25 | void ack_bad_irq(unsigned int irq); |
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile index c381ea954892..ab6e7ec0bba3 100644 --- a/arch/ia64/kernel/Makefile +++ b/arch/ia64/kernel/Makefile | |||
@@ -2,6 +2,10 @@ | |||
2 | # Makefile for the linux kernel. | 2 | # Makefile for the linux kernel. |
3 | # | 3 | # |
4 | 4 | ||
5 | ifdef CONFIG_DYNAMIC_FTRACE | ||
6 | CFLAGS_REMOVE_ftrace.o = -pg | ||
7 | endif | ||
8 | |||
5 | extra-y := head.o init_task.o vmlinux.lds | 9 | extra-y := head.o init_task.o vmlinux.lds |
6 | 10 | ||
7 | obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \ | 11 | obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \ |
@@ -28,6 +32,7 @@ obj-$(CONFIG_IA64_CYCLONE) += cyclone.o | |||
28 | obj-$(CONFIG_CPU_FREQ) += cpufreq/ | 32 | obj-$(CONFIG_CPU_FREQ) += cpufreq/ |
29 | obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o | 33 | obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o |
30 | obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o | 34 | obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o |
35 | obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o | ||
31 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o | 36 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o |
32 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | 37 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o |
33 | obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o | 38 | obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o |
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S index e5341e2c1175..7e3382b06d56 100644 --- a/arch/ia64/kernel/entry.S +++ b/arch/ia64/kernel/entry.S | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <asm/processor.h> | 47 | #include <asm/processor.h> |
48 | #include <asm/thread_info.h> | 48 | #include <asm/thread_info.h> |
49 | #include <asm/unistd.h> | 49 | #include <asm/unistd.h> |
50 | #include <asm/ftrace.h> | ||
50 | 51 | ||
51 | #include "minstate.h" | 52 | #include "minstate.h" |
52 | 53 | ||
@@ -1404,6 +1405,105 @@ GLOBAL_ENTRY(unw_init_running) | |||
1404 | br.ret.sptk.many rp | 1405 | br.ret.sptk.many rp |
1405 | END(unw_init_running) | 1406 | END(unw_init_running) |
1406 | 1407 | ||
1408 | #ifdef CONFIG_FUNCTION_TRACER | ||
1409 | #ifdef CONFIG_DYNAMIC_FTRACE | ||
1410 | GLOBAL_ENTRY(_mcount) | ||
1411 | br ftrace_stub | ||
1412 | END(_mcount) | ||
1413 | |||
1414 | .here: | ||
1415 | br.ret.sptk.many b0 | ||
1416 | |||
1417 | GLOBAL_ENTRY(ftrace_caller) | ||
1418 | alloc out0 = ar.pfs, 8, 0, 4, 0 | ||
1419 | mov out3 = r0 | ||
1420 | ;; | ||
1421 | mov out2 = b0 | ||
1422 | add r3 = 0x20, r3 | ||
1423 | mov out1 = r1; | ||
1424 | br.call.sptk.many b0 = ftrace_patch_gp | ||
1425 | //this might be called from module, so we must patch gp | ||
1426 | ftrace_patch_gp: | ||
1427 | movl gp=__gp | ||
1428 | mov b0 = r3 | ||
1429 | ;; | ||
1430 | .global ftrace_call; | ||
1431 | ftrace_call: | ||
1432 | { | ||
1433 | .mlx | ||
1434 | nop.m 0x0 | ||
1435 | movl r3 = .here;; | ||
1436 | } | ||
1437 | alloc loc0 = ar.pfs, 4, 4, 2, 0 | ||
1438 | ;; | ||
1439 | mov loc1 = b0 | ||
1440 | mov out0 = b0 | ||
1441 | mov loc2 = r8 | ||
1442 | mov loc3 = r15 | ||
1443 | ;; | ||
1444 | adds out0 = -MCOUNT_INSN_SIZE, out0 | ||
1445 | mov out1 = in2 | ||
1446 | mov b6 = r3 | ||
1447 | |||
1448 | br.call.sptk.many b0 = b6 | ||
1449 | ;; | ||
1450 | mov ar.pfs = loc0 | ||
1451 | mov b0 = loc1 | ||
1452 | mov r8 = loc2 | ||
1453 | mov r15 = loc3 | ||
1454 | br ftrace_stub | ||
1455 | ;; | ||
1456 | END(ftrace_caller) | ||
1457 | |||
1458 | #else | ||
1459 | GLOBAL_ENTRY(_mcount) | ||
1460 | movl r2 = ftrace_stub | ||
1461 | movl r3 = ftrace_trace_function;; | ||
1462 | ld8 r3 = [r3];; | ||
1463 | ld8 r3 = [r3];; | ||
1464 | cmp.eq p7,p0 = r2, r3 | ||
1465 | (p7) br.sptk.many ftrace_stub | ||
1466 | ;; | ||
1467 | |||
1468 | alloc loc0 = ar.pfs, 4, 4, 2, 0 | ||
1469 | ;; | ||
1470 | mov loc1 = b0 | ||
1471 | mov out0 = b0 | ||
1472 | mov loc2 = r8 | ||
1473 | mov loc3 = r15 | ||
1474 | ;; | ||
1475 | adds out0 = -MCOUNT_INSN_SIZE, out0 | ||
1476 | mov out1 = in2 | ||
1477 | mov b6 = r3 | ||
1478 | |||
1479 | br.call.sptk.many b0 = b6 | ||
1480 | ;; | ||
1481 | mov ar.pfs = loc0 | ||
1482 | mov b0 = loc1 | ||
1483 | mov r8 = loc2 | ||
1484 | mov r15 = loc3 | ||
1485 | br ftrace_stub | ||
1486 | ;; | ||
1487 | END(_mcount) | ||
1488 | #endif | ||
1489 | |||
1490 | GLOBAL_ENTRY(ftrace_stub) | ||
1491 | mov r3 = b0 | ||
1492 | movl r2 = _mcount_ret_helper | ||
1493 | ;; | ||
1494 | mov b6 = r2 | ||
1495 | mov b7 = r3 | ||
1496 | br.ret.sptk.many b6 | ||
1497 | |||
1498 | _mcount_ret_helper: | ||
1499 | mov b0 = r42 | ||
1500 | mov r1 = r41 | ||
1501 | mov ar.pfs = r40 | ||
1502 | br b7 | ||
1503 | END(ftrace_stub) | ||
1504 | |||
1505 | #endif /* CONFIG_FUNCTION_TRACER */ | ||
1506 | |||
1407 | .rodata | 1507 | .rodata |
1408 | .align 8 | 1508 | .align 8 |
1409 | .globl sys_call_table | 1509 | .globl sys_call_table |
diff --git a/arch/ia64/kernel/ftrace.c b/arch/ia64/kernel/ftrace.c new file mode 100644 index 000000000000..7fc8c961b1f7 --- /dev/null +++ b/arch/ia64/kernel/ftrace.c | |||
@@ -0,0 +1,206 @@ | |||
1 | /* | ||
2 | * Dynamic function tracing support. | ||
3 | * | ||
4 | * Copyright (C) 2008 Shaohua Li <shaohua.li@intel.com> | ||
5 | * | ||
6 | * For licencing details, see COPYING. | ||
7 | * | ||
8 | * Defines low-level handling of mcount calls when the kernel | ||
9 | * is compiled with the -pg flag. When using dynamic ftrace, the | ||
10 | * mcount call-sites get patched lazily with NOP till they are | ||
11 | * enabled. All code mutation routines here take effect atomically. | ||
12 | */ | ||
13 | |||
14 | #include <linux/uaccess.h> | ||
15 | #include <linux/ftrace.h> | ||
16 | |||
17 | #include <asm/cacheflush.h> | ||
18 | #include <asm/patch.h> | ||
19 | |||
20 | /* In IA64, each function will be added below two bundles with -pg option */ | ||
21 | static unsigned char __attribute__((aligned(8))) | ||
22 | ftrace_orig_code[MCOUNT_INSN_SIZE] = { | ||
23 | 0x02, 0x40, 0x31, 0x10, 0x80, 0x05, /* alloc r40=ar.pfs,12,8,0 */ | ||
24 | 0xb0, 0x02, 0x00, 0x00, 0x42, 0x40, /* mov r43=r0;; */ | ||
25 | 0x05, 0x00, 0xc4, 0x00, /* mov r42=b0 */ | ||
26 | 0x11, 0x48, 0x01, 0x02, 0x00, 0x21, /* mov r41=r1 */ | ||
27 | 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* nop.i 0x0 */ | ||
28 | 0x08, 0x00, 0x00, 0x50 /* br.call.sptk.many b0 = _mcount;; */ | ||
29 | }; | ||
30 | |||
31 | struct ftrace_orig_insn { | ||
32 | u64 dummy1, dummy2, dummy3; | ||
33 | u64 dummy4:64-41+13; | ||
34 | u64 imm20:20; | ||
35 | u64 dummy5:3; | ||
36 | u64 sign:1; | ||
37 | u64 dummy6:4; | ||
38 | }; | ||
39 | |||
40 | /* mcount stub will be converted below for nop */ | ||
41 | static unsigned char ftrace_nop_code[MCOUNT_INSN_SIZE] = { | ||
42 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MII] nop.m 0x0 */ | ||
43 | 0x30, 0x00, 0x00, 0x60, 0x00, 0x00, /* mov r3=ip */ | ||
44 | 0x00, 0x00, 0x04, 0x00, /* nop.i 0x0 */ | ||
45 | 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MLX] nop.m 0x0 */ | ||
46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* nop.x 0x0;; */ | ||
47 | 0x00, 0x00, 0x04, 0x00 | ||
48 | }; | ||
49 | |||
50 | static unsigned char *ftrace_nop_replace(void) | ||
51 | { | ||
52 | return ftrace_nop_code; | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * mcount stub will be converted below for call | ||
57 | * Note: Just the last instruction is changed against nop | ||
58 | * */ | ||
59 | static unsigned char __attribute__((aligned(8))) | ||
60 | ftrace_call_code[MCOUNT_INSN_SIZE] = { | ||
61 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MII] nop.m 0x0 */ | ||
62 | 0x30, 0x00, 0x00, 0x60, 0x00, 0x00, /* mov r3=ip */ | ||
63 | 0x00, 0x00, 0x04, 0x00, /* nop.i 0x0 */ | ||
64 | 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MLX] nop.m 0x0 */ | ||
65 | 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, /* brl.many .;;*/ | ||
66 | 0xf8, 0xff, 0xff, 0xc8 | ||
67 | }; | ||
68 | |||
69 | struct ftrace_call_insn { | ||
70 | u64 dummy1, dummy2; | ||
71 | u64 dummy3:48; | ||
72 | u64 imm39_l:16; | ||
73 | u64 imm39_h:23; | ||
74 | u64 dummy4:13; | ||
75 | u64 imm20:20; | ||
76 | u64 dummy5:3; | ||
77 | u64 i:1; | ||
78 | u64 dummy6:4; | ||
79 | }; | ||
80 | |||
81 | static unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) | ||
82 | { | ||
83 | struct ftrace_call_insn *code = (void *)ftrace_call_code; | ||
84 | unsigned long offset = addr - (ip + 0x10); | ||
85 | |||
86 | code->imm39_l = offset >> 24; | ||
87 | code->imm39_h = offset >> 40; | ||
88 | code->imm20 = offset >> 4; | ||
89 | code->i = offset >> 63; | ||
90 | return ftrace_call_code; | ||
91 | } | ||
92 | |||
93 | static int | ||
94 | ftrace_modify_code(unsigned long ip, unsigned char *old_code, | ||
95 | unsigned char *new_code, int do_check) | ||
96 | { | ||
97 | unsigned char replaced[MCOUNT_INSN_SIZE]; | ||
98 | |||
99 | /* | ||
100 | * Note: Due to modules and __init, code can | ||
101 | * disappear and change, we need to protect against faulting | ||
102 | * as well as code changing. We do this by using the | ||
103 | * probe_kernel_* functions. | ||
104 | * | ||
105 | * No real locking needed, this code is run through | ||
106 | * kstop_machine, or before SMP starts. | ||
107 | */ | ||
108 | |||
109 | if (!do_check) | ||
110 | goto skip_check; | ||
111 | |||
112 | /* read the text we want to modify */ | ||
113 | if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE)) | ||
114 | return -EFAULT; | ||
115 | |||
116 | /* Make sure it is what we expect it to be */ | ||
117 | if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0) | ||
118 | return -EINVAL; | ||
119 | |||
120 | skip_check: | ||
121 | /* replace the text with the new text */ | ||
122 | if (probe_kernel_write(((void *)ip), new_code, MCOUNT_INSN_SIZE)) | ||
123 | return -EPERM; | ||
124 | flush_icache_range(ip, ip + MCOUNT_INSN_SIZE); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static int ftrace_make_nop_check(struct dyn_ftrace *rec, unsigned long addr) | ||
130 | { | ||
131 | unsigned char __attribute__((aligned(8))) replaced[MCOUNT_INSN_SIZE]; | ||
132 | unsigned long ip = rec->ip; | ||
133 | |||
134 | if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE)) | ||
135 | return -EFAULT; | ||
136 | if (rec->flags & FTRACE_FL_CONVERTED) { | ||
137 | struct ftrace_call_insn *call_insn, *tmp_call; | ||
138 | |||
139 | call_insn = (void *)ftrace_call_code; | ||
140 | tmp_call = (void *)replaced; | ||
141 | call_insn->imm39_l = tmp_call->imm39_l; | ||
142 | call_insn->imm39_h = tmp_call->imm39_h; | ||
143 | call_insn->imm20 = tmp_call->imm20; | ||
144 | call_insn->i = tmp_call->i; | ||
145 | if (memcmp(replaced, ftrace_call_code, MCOUNT_INSN_SIZE) != 0) | ||
146 | return -EINVAL; | ||
147 | return 0; | ||
148 | } else { | ||
149 | struct ftrace_orig_insn *call_insn, *tmp_call; | ||
150 | |||
151 | call_insn = (void *)ftrace_orig_code; | ||
152 | tmp_call = (void *)replaced; | ||
153 | call_insn->sign = tmp_call->sign; | ||
154 | call_insn->imm20 = tmp_call->imm20; | ||
155 | if (memcmp(replaced, ftrace_orig_code, MCOUNT_INSN_SIZE) != 0) | ||
156 | return -EINVAL; | ||
157 | return 0; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | int ftrace_make_nop(struct module *mod, | ||
162 | struct dyn_ftrace *rec, unsigned long addr) | ||
163 | { | ||
164 | int ret; | ||
165 | char *new; | ||
166 | |||
167 | ret = ftrace_make_nop_check(rec, addr); | ||
168 | if (ret) | ||
169 | return ret; | ||
170 | new = ftrace_nop_replace(); | ||
171 | return ftrace_modify_code(rec->ip, NULL, new, 0); | ||
172 | } | ||
173 | |||
174 | int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) | ||
175 | { | ||
176 | unsigned long ip = rec->ip; | ||
177 | unsigned char *old, *new; | ||
178 | |||
179 | old= ftrace_nop_replace(); | ||
180 | new = ftrace_call_replace(ip, addr); | ||
181 | return ftrace_modify_code(ip, old, new, 1); | ||
182 | } | ||
183 | |||
184 | /* in IA64, _mcount can't directly call ftrace_stub. Only jump is ok */ | ||
185 | int ftrace_update_ftrace_func(ftrace_func_t func) | ||
186 | { | ||
187 | unsigned long ip; | ||
188 | unsigned long addr = ((struct fnptr *)ftrace_call)->ip; | ||
189 | |||
190 | if (func == ftrace_stub) | ||
191 | return 0; | ||
192 | ip = ((struct fnptr *)func)->ip; | ||
193 | |||
194 | ia64_patch_imm64(addr + 2, ip); | ||
195 | |||
196 | flush_icache_range(addr, addr + 16); | ||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | /* run from kstop_machine */ | ||
201 | int __init ftrace_dyn_arch_init(void *data) | ||
202 | { | ||
203 | *(unsigned long *)data = 0; | ||
204 | |||
205 | return 0; | ||
206 | } | ||
diff --git a/arch/ia64/kernel/ia64_ksyms.c b/arch/ia64/kernel/ia64_ksyms.c index 6da1f20d7372..2d311864e359 100644 --- a/arch/ia64/kernel/ia64_ksyms.c +++ b/arch/ia64/kernel/ia64_ksyms.c | |||
@@ -112,3 +112,9 @@ EXPORT_SYMBOL_GPL(esi_call_phys); | |||
112 | #endif | 112 | #endif |
113 | extern char ia64_ivt[]; | 113 | extern char ia64_ivt[]; |
114 | EXPORT_SYMBOL(ia64_ivt); | 114 | EXPORT_SYMBOL(ia64_ivt); |
115 | |||
116 | #include <asm/ftrace.h> | ||
117 | #ifdef CONFIG_FUNCTION_TRACER | ||
118 | /* mcount is defined in assembly */ | ||
119 | EXPORT_SYMBOL(_mcount); | ||
120 | #endif | ||
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 9c39095b33fc..8fc9a847cf48 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -34,6 +34,7 @@ config X86 | |||
34 | select HAVE_FUNCTION_TRACER | 34 | select HAVE_FUNCTION_TRACER |
35 | select HAVE_FUNCTION_GRAPH_TRACER | 35 | select HAVE_FUNCTION_GRAPH_TRACER |
36 | select HAVE_FUNCTION_TRACE_MCOUNT_TEST | 36 | select HAVE_FUNCTION_TRACE_MCOUNT_TEST |
37 | select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE | ||
37 | select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) | 38 | select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) |
38 | select HAVE_ARCH_KGDB if !X86_VOYAGER | 39 | select HAVE_ARCH_KGDB if !X86_VOYAGER |
39 | select HAVE_ARCH_TRACEHOOK | 40 | select HAVE_ARCH_TRACEHOOK |
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c index 4b1c319d30c3..c5d737cdb365 100644 --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/cpufreq.h> | 33 | #include <linux/cpufreq.h> |
34 | #include <linux/compiler.h> | 34 | #include <linux/compiler.h> |
35 | #include <linux/dmi.h> | 35 | #include <linux/dmi.h> |
36 | #include <linux/ftrace.h> | 36 | #include <trace/power.h> |
37 | 37 | ||
38 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
39 | #include <acpi/processor.h> | 39 | #include <acpi/processor.h> |
@@ -70,6 +70,8 @@ struct acpi_cpufreq_data { | |||
70 | 70 | ||
71 | static DEFINE_PER_CPU(struct acpi_cpufreq_data *, drv_data); | 71 | static DEFINE_PER_CPU(struct acpi_cpufreq_data *, drv_data); |
72 | 72 | ||
73 | DEFINE_TRACE(power_mark); | ||
74 | |||
73 | /* acpi_perf_data is a pointer to percpu data. */ | 75 | /* acpi_perf_data is a pointer to percpu data. */ |
74 | static struct acpi_processor_performance *acpi_perf_data; | 76 | static struct acpi_processor_performance *acpi_perf_data; |
75 | 77 | ||
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index 6b1f6f6f8661..077c9ea655fc 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/bug.h> | 14 | #include <linux/bug.h> |
15 | #include <linux/nmi.h> | 15 | #include <linux/nmi.h> |
16 | #include <linux/sysfs.h> | 16 | #include <linux/sysfs.h> |
17 | #include <linux/ftrace.h> | ||
17 | 18 | ||
18 | #include <asm/stacktrace.h> | 19 | #include <asm/stacktrace.h> |
19 | 20 | ||
@@ -195,6 +196,11 @@ unsigned __kprobes long oops_begin(void) | |||
195 | int cpu; | 196 | int cpu; |
196 | unsigned long flags; | 197 | unsigned long flags; |
197 | 198 | ||
199 | /* notify the hw-branch tracer so it may disable tracing and | ||
200 | add the last trace to the trace buffer - | ||
201 | the earlier this happens, the more useful the trace. */ | ||
202 | trace_hw_branch_oops(); | ||
203 | |||
198 | oops_enter(); | 204 | oops_enter(); |
199 | 205 | ||
200 | /* racy, but better than risking deadlock. */ | 206 | /* racy, but better than risking deadlock. */ |
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 231bdd3c5b1c..2f9c0c8cb4c7 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c | |||
@@ -82,7 +82,7 @@ static unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) | |||
82 | * are the same as what exists. | 82 | * are the same as what exists. |
83 | */ | 83 | */ |
84 | 84 | ||
85 | static atomic_t in_nmi = ATOMIC_INIT(0); | 85 | static atomic_t nmi_running = ATOMIC_INIT(0); |
86 | static int mod_code_status; /* holds return value of text write */ | 86 | static int mod_code_status; /* holds return value of text write */ |
87 | static int mod_code_write; /* set when NMI should do the write */ | 87 | static int mod_code_write; /* set when NMI should do the write */ |
88 | static void *mod_code_ip; /* holds the IP to write to */ | 88 | static void *mod_code_ip; /* holds the IP to write to */ |
@@ -115,8 +115,8 @@ static void ftrace_mod_code(void) | |||
115 | 115 | ||
116 | void ftrace_nmi_enter(void) | 116 | void ftrace_nmi_enter(void) |
117 | { | 117 | { |
118 | atomic_inc(&in_nmi); | 118 | atomic_inc(&nmi_running); |
119 | /* Must have in_nmi seen before reading write flag */ | 119 | /* Must have nmi_running seen before reading write flag */ |
120 | smp_mb(); | 120 | smp_mb(); |
121 | if (mod_code_write) { | 121 | if (mod_code_write) { |
122 | ftrace_mod_code(); | 122 | ftrace_mod_code(); |
@@ -126,22 +126,21 @@ void ftrace_nmi_enter(void) | |||
126 | 126 | ||
127 | void ftrace_nmi_exit(void) | 127 | void ftrace_nmi_exit(void) |
128 | { | 128 | { |
129 | /* Finish all executions before clearing in_nmi */ | 129 | /* Finish all executions before clearing nmi_running */ |
130 | smp_wmb(); | 130 | smp_wmb(); |
131 | atomic_dec(&in_nmi); | 131 | atomic_dec(&nmi_running); |
132 | } | 132 | } |
133 | 133 | ||
134 | static void wait_for_nmi(void) | 134 | static void wait_for_nmi(void) |
135 | { | 135 | { |
136 | int waited = 0; | 136 | if (!atomic_read(&nmi_running)) |
137 | return; | ||
137 | 138 | ||
138 | while (atomic_read(&in_nmi)) { | 139 | do { |
139 | waited = 1; | ||
140 | cpu_relax(); | 140 | cpu_relax(); |
141 | } | 141 | } while (atomic_read(&nmi_running)); |
142 | 142 | ||
143 | if (waited) | 143 | nmi_wait_count++; |
144 | nmi_wait_count++; | ||
145 | } | 144 | } |
146 | 145 | ||
147 | static int | 146 | static int |
@@ -368,25 +367,6 @@ int ftrace_disable_ftrace_graph_caller(void) | |||
368 | return ftrace_mod_jmp(ip, old_offset, new_offset); | 367 | return ftrace_mod_jmp(ip, old_offset, new_offset); |
369 | } | 368 | } |
370 | 369 | ||
371 | #else /* CONFIG_DYNAMIC_FTRACE */ | ||
372 | |||
373 | /* | ||
374 | * These functions are picked from those used on | ||
375 | * this page for dynamic ftrace. They have been | ||
376 | * simplified to ignore all traces in NMI context. | ||
377 | */ | ||
378 | static atomic_t in_nmi; | ||
379 | |||
380 | void ftrace_nmi_enter(void) | ||
381 | { | ||
382 | atomic_inc(&in_nmi); | ||
383 | } | ||
384 | |||
385 | void ftrace_nmi_exit(void) | ||
386 | { | ||
387 | atomic_dec(&in_nmi); | ||
388 | } | ||
389 | |||
390 | #endif /* !CONFIG_DYNAMIC_FTRACE */ | 370 | #endif /* !CONFIG_DYNAMIC_FTRACE */ |
391 | 371 | ||
392 | /* Add a function return address to the trace stack on thread info.*/ | 372 | /* Add a function return address to the trace stack on thread info.*/ |
@@ -476,7 +456,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) | |||
476 | &return_to_handler; | 456 | &return_to_handler; |
477 | 457 | ||
478 | /* Nmi's are currently unsupported */ | 458 | /* Nmi's are currently unsupported */ |
479 | if (unlikely(atomic_read(&in_nmi))) | 459 | if (unlikely(in_nmi())) |
480 | return; | 460 | return; |
481 | 461 | ||
482 | if (unlikely(atomic_read(¤t->tracing_graph_pause))) | 462 | if (unlikely(atomic_read(¤t->tracing_graph_pause))) |
@@ -512,13 +492,6 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) | |||
512 | return; | 492 | return; |
513 | } | 493 | } |
514 | 494 | ||
515 | if (unlikely(!__kernel_text_address(old))) { | ||
516 | ftrace_graph_stop(); | ||
517 | *parent = old; | ||
518 | WARN_ON(1); | ||
519 | return; | ||
520 | } | ||
521 | |||
522 | calltime = cpu_clock(raw_smp_processor_id()); | 495 | calltime = cpu_clock(raw_smp_processor_id()); |
523 | 496 | ||
524 | if (push_return_trace(old, calltime, | 497 | if (push_return_trace(old, calltime, |
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 6d12f7e37f8c..23b328edc2b3 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/pm.h> | 9 | #include <linux/pm.h> |
10 | #include <linux/clockchips.h> | 10 | #include <linux/clockchips.h> |
11 | #include <linux/ftrace.h> | 11 | #include <trace/power.h> |
12 | #include <asm/system.h> | 12 | #include <asm/system.h> |
13 | #include <asm/apic.h> | 13 | #include <asm/apic.h> |
14 | 14 | ||
@@ -19,6 +19,9 @@ EXPORT_SYMBOL(idle_nomwait); | |||
19 | 19 | ||
20 | struct kmem_cache *task_xstate_cachep; | 20 | struct kmem_cache *task_xstate_cachep; |
21 | 21 | ||
22 | DEFINE_TRACE(power_start); | ||
23 | DEFINE_TRACE(power_end); | ||
24 | |||
22 | int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) | 25 | int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) |
23 | { | 26 | { |
24 | *dst = *src; | 27 | *dst = *src; |
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index b81125f0bdee..c7da3683f4c5 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig | |||
@@ -55,7 +55,8 @@ config KVM_AMD | |||
55 | 55 | ||
56 | config KVM_TRACE | 56 | config KVM_TRACE |
57 | bool "KVM trace support" | 57 | bool "KVM trace support" |
58 | depends on KVM && MARKERS && SYSFS | 58 | depends on KVM && SYSFS |
59 | select MARKERS | ||
59 | select RELAY | 60 | select RELAY |
60 | select DEBUG_FS | 61 | select DEBUG_FS |
61 | default n | 62 | default n |