Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Code for replacing ftrace calls with jumps. |
| 3 | * |
| 4 | * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> |
| 5 | * |
| 6 | * Thanks goes out to P.A. Semi, Inc for supplying me with a PPC64 box. |
| 7 | * |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 8 | * Added function graph tracer code, taken from x86 that was written |
| 9 | * by Frederic Weisbecker, and ported to PPC by Steven Rostedt. |
| 10 | * |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 11 | */ |
| 12 | |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 13 | #define pr_fmt(fmt) "ftrace-powerpc: " fmt |
| 14 | |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 15 | #include <linux/spinlock.h> |
| 16 | #include <linux/hardirq.h> |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 17 | #include <linux/uaccess.h> |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 18 | #include <linux/module.h> |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 19 | #include <linux/ftrace.h> |
| 20 | #include <linux/percpu.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/list.h> |
| 23 | |
| 24 | #include <asm/cacheflush.h> |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 25 | #include <asm/code-patching.h> |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 26 | #include <asm/ftrace.h> |
Ian Munsie | 02424d8 | 2011-02-02 17:27:24 +0000 | [diff] [blame] | 27 | #include <asm/syscall.h> |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 28 | |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 29 | |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 30 | #ifdef CONFIG_DYNAMIC_FTRACE |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 31 | static unsigned int |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 32 | ftrace_call_replace(unsigned long ip, unsigned long addr, int link) |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 33 | { |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 34 | unsigned int op; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 35 | |
Michael Ellerman | 4a9e3f8 | 2009-05-28 19:33:34 +0000 | [diff] [blame] | 36 | addr = ppc_function_entry((void *)addr); |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 37 | |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 38 | /* if (link) set op to 'bl' else 'b' */ |
Steven Rostedt | bb9b903 | 2009-02-13 06:45:27 -0800 | [diff] [blame] | 39 | op = create_branch((unsigned int *)ip, addr, link ? 1 : 0); |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 40 | |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 41 | return op; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 42 | } |
| 43 | |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 44 | static int |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 45 | ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new) |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 46 | { |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 47 | unsigned int replaced; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 48 | |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 49 | /* |
| 50 | * Note: Due to modules and __init, code can |
| 51 | * disappear and change, we need to protect against faulting |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 52 | * as well as code changing. We do this by using the |
| 53 | * probe_kernel_* functions. |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 54 | * |
| 55 | * No real locking needed, this code is run through |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 56 | * kstop_machine, or before SMP starts. |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 57 | */ |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 58 | |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 59 | /* read the text we want to modify */ |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 60 | if (probe_kernel_read(&replaced, (void *)ip, MCOUNT_INSN_SIZE)) |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 61 | return -EFAULT; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 62 | |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 63 | /* Make sure it is what we expect it to be */ |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 64 | if (replaced != old) |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 65 | return -EINVAL; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 66 | |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 67 | /* replace the text with the new text */ |
Steven Rostedt | 65b8c72 | 2012-04-26 08:31:19 +0000 | [diff] [blame] | 68 | if (patch_instruction((unsigned int *)ip, new)) |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 69 | return -EPERM; |
| 70 | |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 71 | return 0; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 72 | } |
| 73 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 74 | /* |
| 75 | * Helper functions that are the same for both PPC64 and PPC32. |
| 76 | */ |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 77 | static int test_24bit_addr(unsigned long ip, unsigned long addr) |
| 78 | { |
Liu Ping Fan | a95fc58 | 2014-02-26 10:23:01 +0800 | [diff] [blame] | 79 | addr = ppc_function_entry((void *)addr); |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 80 | |
Steven Rostedt | 0029ff8 | 2008-11-25 14:06:19 -0800 | [diff] [blame] | 81 | /* use the create_branch to verify that this offset can be branched */ |
| 82 | return create_branch((unsigned int *)ip, addr, 0); |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 83 | } |
| 84 | |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 85 | #ifdef CONFIG_MODULES |
| 86 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 87 | static int is_bl_op(unsigned int op) |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 88 | { |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 89 | return (op & 0xfc000003) == 0x48000001; |
| 90 | } |
| 91 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 92 | static unsigned long find_bl_target(unsigned long ip, unsigned int op) |
| 93 | { |
| 94 | static int offset; |
| 95 | |
| 96 | offset = (op & 0x03fffffc); |
| 97 | /* make it signed */ |
| 98 | if (offset & 0x02000000) |
| 99 | offset |= 0xfe000000; |
| 100 | |
| 101 | return ip + (long)offset; |
| 102 | } |
| 103 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 104 | #ifdef CONFIG_PPC64 |
| 105 | static int |
| 106 | __ftrace_make_nop(struct module *mod, |
| 107 | struct dyn_ftrace *rec, unsigned long addr) |
| 108 | { |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 109 | unsigned int op; |
Michael Ellerman | d84e0d6 | 2014-06-17 16:15:35 +1000 | [diff] [blame] | 110 | unsigned long entry, ptr; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 111 | unsigned long ip = rec->ip; |
Anton Blanchard | 62c9da6 | 2014-04-04 16:52:58 +1100 | [diff] [blame] | 112 | void *tramp; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 113 | |
| 114 | /* read where this goes */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 115 | if (probe_kernel_read(&op, (void *)ip, sizeof(int))) |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 116 | return -EFAULT; |
| 117 | |
| 118 | /* Make sure that that this is still a 24bit jump */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 119 | if (!is_bl_op(op)) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 120 | pr_err("Not expected bl: opcode is %x\n", op); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 121 | return -EINVAL; |
| 122 | } |
| 123 | |
| 124 | /* lets find where the pointer goes */ |
Anton Blanchard | 62c9da6 | 2014-04-04 16:52:58 +1100 | [diff] [blame] | 125 | tramp = (void *)find_bl_target(ip, op); |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 126 | |
Anton Blanchard | 62c9da6 | 2014-04-04 16:52:58 +1100 | [diff] [blame] | 127 | pr_devel("ip:%lx jumps to %p", ip, tramp); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 128 | |
Anton Blanchard | 62c9da6 | 2014-04-04 16:52:58 +1100 | [diff] [blame] | 129 | if (!is_module_trampoline(tramp)) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 130 | pr_err("Not a trampoline\n"); |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 131 | return -EINVAL; |
| 132 | } |
| 133 | |
Anton Blanchard | 62c9da6 | 2014-04-04 16:52:58 +1100 | [diff] [blame] | 134 | if (module_trampoline_target(mod, tramp, &ptr)) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 135 | pr_err("Failed to get trampoline target\n"); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 136 | return -EFAULT; |
| 137 | } |
| 138 | |
Anton Blanchard | 62c9da6 | 2014-04-04 16:52:58 +1100 | [diff] [blame] | 139 | pr_devel("trampoline target %lx", ptr); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 140 | |
Michael Ellerman | d84e0d6 | 2014-06-17 16:15:35 +1000 | [diff] [blame] | 141 | entry = ppc_global_function_entry((void *)addr); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 142 | /* This should match what was called */ |
Michael Ellerman | d84e0d6 | 2014-06-17 16:15:35 +1000 | [diff] [blame] | 143 | if (ptr != entry) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 144 | pr_err("addr %lx does not match expected %lx\n", ptr, entry); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 145 | return -EINVAL; |
| 146 | } |
| 147 | |
| 148 | /* |
Anton Blanchard | 62c9da6 | 2014-04-04 16:52:58 +1100 | [diff] [blame] | 149 | * Our original call site looks like: |
| 150 | * |
| 151 | * bl <tramp> |
| 152 | * ld r2,XX(r1) |
| 153 | * |
| 154 | * Milton Miller pointed out that we can not simply nop the branch. |
| 155 | * If a task was preempted when calling a trace function, the nops |
| 156 | * will remove the way to restore the TOC in r2 and the r2 TOC will |
| 157 | * get corrupted. |
| 158 | * |
| 159 | * Use a b +8 to jump over the load. |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 160 | */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 161 | op = 0x48000008; /* b +8 */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 162 | |
Steven Rostedt | 65b8c72 | 2012-04-26 08:31:19 +0000 | [diff] [blame] | 163 | if (patch_instruction((unsigned int *)ip, op)) |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 164 | return -EPERM; |
| 165 | |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 166 | return 0; |
| 167 | } |
| 168 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 169 | #else /* !PPC64 */ |
| 170 | static int |
| 171 | __ftrace_make_nop(struct module *mod, |
| 172 | struct dyn_ftrace *rec, unsigned long addr) |
| 173 | { |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 174 | unsigned int op; |
| 175 | unsigned int jmp[4]; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 176 | unsigned long ip = rec->ip; |
| 177 | unsigned long tramp; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 178 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 179 | if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE)) |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 180 | return -EFAULT; |
| 181 | |
| 182 | /* Make sure that that this is still a 24bit jump */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 183 | if (!is_bl_op(op)) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 184 | pr_err("Not expected bl: opcode is %x\n", op); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 185 | return -EINVAL; |
| 186 | } |
| 187 | |
| 188 | /* lets find where the pointer goes */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 189 | tramp = find_bl_target(ip, op); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 190 | |
| 191 | /* |
| 192 | * On PPC32 the trampoline looks like: |
roger blofeld | fd5a429 | 2012-06-21 05:27:14 +0000 | [diff] [blame] | 193 | * 0x3d, 0x80, 0x00, 0x00 lis r12,sym@ha |
| 194 | * 0x39, 0x8c, 0x00, 0x00 addi r12,r12,sym@l |
| 195 | * 0x7d, 0x89, 0x03, 0xa6 mtctr r12 |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 196 | * 0x4e, 0x80, 0x04, 0x20 bctr |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 197 | */ |
| 198 | |
Michael Ellerman | 021376a | 2009-05-13 20:30:24 +0000 | [diff] [blame] | 199 | pr_devel("ip:%lx jumps to %lx", ip, tramp); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 200 | |
| 201 | /* Find where the trampoline jumps to */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 202 | if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 203 | pr_err("Failed to read %lx\n", tramp); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 204 | return -EFAULT; |
| 205 | } |
| 206 | |
Michael Ellerman | 021376a | 2009-05-13 20:30:24 +0000 | [diff] [blame] | 207 | pr_devel(" %08x %08x ", jmp[0], jmp[1]); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 208 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 209 | /* verify that this is what we expect it to be */ |
roger blofeld | fd5a429 | 2012-06-21 05:27:14 +0000 | [diff] [blame] | 210 | if (((jmp[0] & 0xffff0000) != 0x3d800000) || |
| 211 | ((jmp[1] & 0xffff0000) != 0x398c0000) || |
| 212 | (jmp[2] != 0x7d8903a6) || |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 213 | (jmp[3] != 0x4e800420)) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 214 | pr_err("Not a trampoline\n"); |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 215 | return -EINVAL; |
| 216 | } |
| 217 | |
| 218 | tramp = (jmp[1] & 0xffff) | |
| 219 | ((jmp[0] & 0xffff) << 16); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 220 | if (tramp & 0x8000) |
| 221 | tramp -= 0x10000; |
| 222 | |
Michael Ellerman | 021376a | 2009-05-13 20:30:24 +0000 | [diff] [blame] | 223 | pr_devel(" %lx ", tramp); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 224 | |
| 225 | if (tramp != addr) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 226 | pr_err("Trampoline location %08lx does not match addr\n", |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 227 | tramp); |
| 228 | return -EINVAL; |
| 229 | } |
| 230 | |
Kumar Gala | 16c57b3 | 2009-02-10 20:10:44 +0000 | [diff] [blame] | 231 | op = PPC_INST_NOP; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 232 | |
Steven Rostedt | 65b8c72 | 2012-04-26 08:31:19 +0000 | [diff] [blame] | 233 | if (patch_instruction((unsigned int *)ip, op)) |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 234 | return -EPERM; |
| 235 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 236 | return 0; |
| 237 | } |
| 238 | #endif /* PPC64 */ |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 239 | #endif /* CONFIG_MODULES */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 240 | |
| 241 | int ftrace_make_nop(struct module *mod, |
| 242 | struct dyn_ftrace *rec, unsigned long addr) |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 243 | { |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 244 | unsigned long ip = rec->ip; |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 245 | unsigned int old, new; |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 246 | |
| 247 | /* |
| 248 | * If the calling address is more that 24 bits away, |
| 249 | * then we had to use a trampoline to make the call. |
| 250 | * Otherwise just update the call site. |
| 251 | */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 252 | if (test_24bit_addr(ip, addr)) { |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 253 | /* within range */ |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 254 | old = ftrace_call_replace(ip, addr, 1); |
Michael Ellerman | 92e02a5 | 2009-05-28 19:33:36 +0000 | [diff] [blame] | 255 | new = PPC_INST_NOP; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 256 | return ftrace_modify_code(ip, old, new); |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 257 | } |
| 258 | |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 259 | #ifdef CONFIG_MODULES |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 260 | /* |
| 261 | * Out of range jumps are called from modules. |
| 262 | * We should either already have a pointer to the module |
| 263 | * or it has been passed in. |
| 264 | */ |
| 265 | if (!rec->arch.mod) { |
| 266 | if (!mod) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 267 | pr_err("No module loaded addr=%lx\n", addr); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 268 | return -EFAULT; |
| 269 | } |
| 270 | rec->arch.mod = mod; |
| 271 | } else if (mod) { |
| 272 | if (mod != rec->arch.mod) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 273 | pr_err("Record mod %p not equal to passed in mod %p\n", |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 274 | rec->arch.mod, mod); |
| 275 | return -EINVAL; |
| 276 | } |
| 277 | /* nothing to do if mod == rec->arch.mod */ |
| 278 | } else |
| 279 | mod = rec->arch.mod; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 280 | |
| 281 | return __ftrace_make_nop(mod, rec, addr); |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 282 | #else |
| 283 | /* We should not get here without modules */ |
| 284 | return -EINVAL; |
| 285 | #endif /* CONFIG_MODULES */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 286 | } |
| 287 | |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 288 | #ifdef CONFIG_MODULES |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 289 | #ifdef CONFIG_PPC64 |
| 290 | static int |
| 291 | __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) |
| 292 | { |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 293 | unsigned int op[2]; |
Anton Blanchard | 24a1bdc | 2014-04-04 16:54:04 +1100 | [diff] [blame] | 294 | void *ip = (void *)rec->ip; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 295 | |
| 296 | /* read where this goes */ |
Anton Blanchard | 24a1bdc | 2014-04-04 16:54:04 +1100 | [diff] [blame] | 297 | if (probe_kernel_read(op, ip, sizeof(op))) |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 298 | return -EFAULT; |
| 299 | |
| 300 | /* |
Anton Blanchard | 24a1bdc | 2014-04-04 16:54:04 +1100 | [diff] [blame] | 301 | * We expect to see: |
| 302 | * |
| 303 | * b +8 |
| 304 | * ld r2,XX(r1) |
| 305 | * |
| 306 | * The load offset is different depending on the ABI. For simplicity |
| 307 | * just mask it out when doing the compare. |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 308 | */ |
Michael Ellerman | dfc382a | 2014-06-17 16:15:33 +1000 | [diff] [blame] | 309 | if ((op[0] != 0x48000008) || ((op[1] & 0xffff0000) != 0xe8410000)) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 310 | pr_err("Unexpected call sequence: %x %x\n", op[0], op[1]); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 311 | return -EINVAL; |
| 312 | } |
| 313 | |
| 314 | /* If we never set up a trampoline to ftrace_caller, then bail */ |
| 315 | if (!rec->arch.mod->arch.tramp) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 316 | pr_err("No ftrace trampoline\n"); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 317 | return -EINVAL; |
| 318 | } |
| 319 | |
Anton Blanchard | 24a1bdc | 2014-04-04 16:54:04 +1100 | [diff] [blame] | 320 | /* Ensure branch is within 24 bits */ |
Michael Ellerman | b7b348c | 2014-06-17 16:15:34 +1000 | [diff] [blame] | 321 | if (!create_branch(ip, rec->arch.mod->arch.tramp, BRANCH_SET_LINK)) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 322 | pr_err("Branch out of range\n"); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 323 | return -EINVAL; |
| 324 | } |
| 325 | |
Anton Blanchard | 24a1bdc | 2014-04-04 16:54:04 +1100 | [diff] [blame] | 326 | if (patch_branch(ip, rec->arch.mod->arch.tramp, BRANCH_SET_LINK)) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 327 | pr_err("REL24 out of range!\n"); |
Anton Blanchard | 24a1bdc | 2014-04-04 16:54:04 +1100 | [diff] [blame] | 328 | return -EINVAL; |
| 329 | } |
Steven Rostedt | ec682ce | 2008-11-25 10:22:48 -0800 | [diff] [blame] | 330 | |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 331 | return 0; |
| 332 | } |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 333 | #else |
| 334 | static int |
| 335 | __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) |
| 336 | { |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 337 | unsigned int op; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 338 | unsigned long ip = rec->ip; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 339 | |
| 340 | /* read where this goes */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 341 | if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE)) |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 342 | return -EFAULT; |
| 343 | |
| 344 | /* It should be pointing to a nop */ |
Kumar Gala | 16c57b3 | 2009-02-10 20:10:44 +0000 | [diff] [blame] | 345 | if (op != PPC_INST_NOP) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 346 | pr_err("Expected NOP but have %x\n", op); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 347 | return -EINVAL; |
| 348 | } |
| 349 | |
| 350 | /* If we never set up a trampoline to ftrace_caller, then bail */ |
| 351 | if (!rec->arch.mod->arch.tramp) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 352 | pr_err("No ftrace trampoline\n"); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 353 | return -EINVAL; |
| 354 | } |
| 355 | |
Steven Rostedt | 0029ff8 | 2008-11-25 14:06:19 -0800 | [diff] [blame] | 356 | /* create the branch to the trampoline */ |
| 357 | op = create_branch((unsigned int *)ip, |
| 358 | rec->arch.mod->arch.tramp, BRANCH_SET_LINK); |
| 359 | if (!op) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 360 | pr_err("REL24 out of range!\n"); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 361 | return -EINVAL; |
| 362 | } |
| 363 | |
Michael Ellerman | 021376a | 2009-05-13 20:30:24 +0000 | [diff] [blame] | 364 | pr_devel("write to %lx\n", rec->ip); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 365 | |
Steven Rostedt | 65b8c72 | 2012-04-26 08:31:19 +0000 | [diff] [blame] | 366 | if (patch_instruction((unsigned int *)ip, op)) |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 367 | return -EPERM; |
| 368 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 369 | return 0; |
| 370 | } |
| 371 | #endif /* CONFIG_PPC64 */ |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 372 | #endif /* CONFIG_MODULES */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 373 | |
| 374 | int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) |
| 375 | { |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 376 | unsigned long ip = rec->ip; |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 377 | unsigned int old, new; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 378 | |
| 379 | /* |
| 380 | * If the calling address is more that 24 bits away, |
| 381 | * then we had to use a trampoline to make the call. |
| 382 | * Otherwise just update the call site. |
| 383 | */ |
| 384 | if (test_24bit_addr(ip, addr)) { |
| 385 | /* within range */ |
Michael Ellerman | 92e02a5 | 2009-05-28 19:33:36 +0000 | [diff] [blame] | 386 | old = PPC_INST_NOP; |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 387 | new = ftrace_call_replace(ip, addr, 1); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 388 | return ftrace_modify_code(ip, old, new); |
| 389 | } |
| 390 | |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 391 | #ifdef CONFIG_MODULES |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 392 | /* |
| 393 | * Out of range jumps are called from modules. |
| 394 | * Being that we are converting from nop, it had better |
| 395 | * already have a module defined. |
| 396 | */ |
| 397 | if (!rec->arch.mod) { |
Michael Ellerman | 072c4c0 | 2014-06-17 16:15:36 +1000 | [diff] [blame] | 398 | pr_err("No module loaded\n"); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 399 | return -EINVAL; |
| 400 | } |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 401 | |
| 402 | return __ftrace_make_call(rec, addr); |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 403 | #else |
| 404 | /* We should not get here without modules */ |
| 405 | return -EINVAL; |
| 406 | #endif /* CONFIG_MODULES */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 407 | } |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 408 | |
Steven Rostedt | 15adc04 | 2008-10-23 09:33:08 -0400 | [diff] [blame] | 409 | int ftrace_update_ftrace_func(ftrace_func_t func) |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 410 | { |
| 411 | unsigned long ip = (unsigned long)(&ftrace_call); |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 412 | unsigned int old, new; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 413 | int ret; |
| 414 | |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 415 | old = *(unsigned int *)&ftrace_call; |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 416 | new = ftrace_call_replace(ip, (unsigned long)func, 1); |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 417 | ret = ftrace_modify_code(ip, old, new); |
| 418 | |
| 419 | return ret; |
| 420 | } |
| 421 | |
Steven Rostedt | ee456bb | 2012-04-26 08:31:17 +0000 | [diff] [blame] | 422 | static int __ftrace_replace_code(struct dyn_ftrace *rec, int enable) |
| 423 | { |
| 424 | unsigned long ftrace_addr = (unsigned long)FTRACE_ADDR; |
| 425 | int ret; |
| 426 | |
| 427 | ret = ftrace_update_record(rec, enable); |
| 428 | |
| 429 | switch (ret) { |
| 430 | case FTRACE_UPDATE_IGNORE: |
| 431 | return 0; |
| 432 | case FTRACE_UPDATE_MAKE_CALL: |
| 433 | return ftrace_make_call(rec, ftrace_addr); |
| 434 | case FTRACE_UPDATE_MAKE_NOP: |
| 435 | return ftrace_make_nop(NULL, rec, ftrace_addr); |
| 436 | } |
| 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | void ftrace_replace_code(int enable) |
| 442 | { |
| 443 | struct ftrace_rec_iter *iter; |
| 444 | struct dyn_ftrace *rec; |
| 445 | int ret; |
| 446 | |
| 447 | for (iter = ftrace_rec_iter_start(); iter; |
| 448 | iter = ftrace_rec_iter_next(iter)) { |
| 449 | rec = ftrace_rec_iter_record(iter); |
| 450 | ret = __ftrace_replace_code(rec, enable); |
| 451 | if (ret) { |
| 452 | ftrace_bug(ret, rec->ip); |
| 453 | return; |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | void arch_ftrace_update_code(int command) |
| 459 | { |
| 460 | if (command & FTRACE_UPDATE_CALLS) |
| 461 | ftrace_replace_code(1); |
| 462 | else if (command & FTRACE_DISABLE_CALLS) |
| 463 | ftrace_replace_code(0); |
| 464 | |
| 465 | if (command & FTRACE_UPDATE_TRACE_FUNC) |
| 466 | ftrace_update_ftrace_func(ftrace_trace_function); |
| 467 | |
| 468 | if (command & FTRACE_START_FUNC_RET) |
| 469 | ftrace_enable_ftrace_graph_caller(); |
| 470 | else if (command & FTRACE_STOP_FUNC_RET) |
| 471 | ftrace_disable_ftrace_graph_caller(); |
| 472 | } |
| 473 | |
Jiri Slaby | 3a36cb1 | 2014-02-24 19:59:59 +0100 | [diff] [blame] | 474 | int __init ftrace_dyn_arch_init(void) |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 475 | { |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 476 | return 0; |
| 477 | } |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 478 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
| 479 | |
| 480 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| 481 | |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 482 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 483 | extern void ftrace_graph_call(void); |
| 484 | extern void ftrace_graph_stub(void); |
| 485 | |
| 486 | int ftrace_enable_ftrace_graph_caller(void) |
| 487 | { |
| 488 | unsigned long ip = (unsigned long)(&ftrace_graph_call); |
| 489 | unsigned long addr = (unsigned long)(&ftrace_graph_caller); |
| 490 | unsigned long stub = (unsigned long)(&ftrace_graph_stub); |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 491 | unsigned int old, new; |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 492 | |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 493 | old = ftrace_call_replace(ip, stub, 0); |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 494 | new = ftrace_call_replace(ip, addr, 0); |
| 495 | |
| 496 | return ftrace_modify_code(ip, old, new); |
| 497 | } |
| 498 | |
| 499 | int ftrace_disable_ftrace_graph_caller(void) |
| 500 | { |
| 501 | unsigned long ip = (unsigned long)(&ftrace_graph_call); |
| 502 | unsigned long addr = (unsigned long)(&ftrace_graph_caller); |
| 503 | unsigned long stub = (unsigned long)(&ftrace_graph_stub); |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 504 | unsigned int old, new; |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 505 | |
Steven Rostedt | b54dcfe | 2009-02-13 06:31:39 -0800 | [diff] [blame] | 506 | old = ftrace_call_replace(ip, addr, 0); |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 507 | new = ftrace_call_replace(ip, stub, 0); |
| 508 | |
| 509 | return ftrace_modify_code(ip, old, new); |
| 510 | } |
| 511 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
| 512 | |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 513 | /* |
| 514 | * Hook the return address and push it in the stack of return addrs |
Anton Blanchard | b3c1872 | 2014-09-17 17:07:04 +1000 | [diff] [blame^] | 515 | * in current thread info. Return the address we want to divert to. |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 516 | */ |
Anton Blanchard | b3c1872 | 2014-09-17 17:07:04 +1000 | [diff] [blame^] | 517 | unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip) |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 518 | { |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 519 | struct ftrace_graph_ent trace; |
Anton Blanchard | 7d56c65 | 2014-09-17 17:07:03 +1000 | [diff] [blame] | 520 | unsigned long return_hooker; |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 521 | |
Steven Rostedt (Red Hat) | 96d4f43 | 2014-06-25 10:27:30 -0400 | [diff] [blame] | 522 | if (unlikely(ftrace_graph_is_dead())) |
Anton Blanchard | b3c1872 | 2014-09-17 17:07:04 +1000 | [diff] [blame^] | 523 | goto out; |
Steven Rostedt (Red Hat) | 96d4f43 | 2014-06-25 10:27:30 -0400 | [diff] [blame] | 524 | |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 525 | if (unlikely(atomic_read(¤t->tracing_graph_pause))) |
Anton Blanchard | b3c1872 | 2014-09-17 17:07:04 +1000 | [diff] [blame^] | 526 | goto out; |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 527 | |
Anton Blanchard | 7d56c65 | 2014-09-17 17:07:03 +1000 | [diff] [blame] | 528 | return_hooker = ppc_function_entry(return_to_handler); |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 529 | |
Anton Blanchard | b3c1872 | 2014-09-17 17:07:04 +1000 | [diff] [blame^] | 530 | trace.func = ip; |
Steven Rostedt | bac821a | 2012-07-18 12:35:28 +0000 | [diff] [blame] | 531 | trace.depth = current->curr_ret_stack + 1; |
| 532 | |
| 533 | /* Only trace if the calling function expects to */ |
Anton Blanchard | b3c1872 | 2014-09-17 17:07:04 +1000 | [diff] [blame^] | 534 | if (!ftrace_graph_entry(&trace)) |
| 535 | goto out; |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 536 | |
Anton Blanchard | b3c1872 | 2014-09-17 17:07:04 +1000 | [diff] [blame^] | 537 | if (ftrace_push_return_trace(parent, ip, &trace.depth, 0) == -EBUSY) |
| 538 | goto out; |
| 539 | |
| 540 | parent = return_hooker; |
| 541 | out: |
| 542 | return parent; |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 543 | } |
| 544 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ |
Ian Munsie | 02424d8 | 2011-02-02 17:27:24 +0000 | [diff] [blame] | 545 | |
| 546 | #if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) |
| 547 | unsigned long __init arch_syscall_addr(int nr) |
| 548 | { |
| 549 | return sys_call_table[nr*2]; |
| 550 | } |
| 551 | #endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */ |