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 | |
| 13 | #include <linux/spinlock.h> |
| 14 | #include <linux/hardirq.h> |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 15 | #include <linux/uaccess.h> |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 16 | #include <linux/module.h> |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 17 | #include <linux/ftrace.h> |
| 18 | #include <linux/percpu.h> |
| 19 | #include <linux/init.h> |
| 20 | #include <linux/list.h> |
| 21 | |
| 22 | #include <asm/cacheflush.h> |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 23 | #include <asm/code-patching.h> |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 24 | #include <asm/ftrace.h> |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 25 | |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 26 | #ifdef CONFIG_PPC32 |
| 27 | # define GET_ADDR(addr) addr |
| 28 | #else |
| 29 | /* PowerPC64's functions are data that points to the functions */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 30 | # define GET_ADDR(addr) (*(unsigned long *)addr) |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 31 | #endif |
| 32 | |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 33 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 34 | static unsigned int ftrace_nop = PPC_NOP_INSTR; |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 35 | |
Steven Rostedt | 15adc04 | 2008-10-23 09:33:08 -0400 | [diff] [blame] | 36 | static unsigned int ftrace_calc_offset(long ip, long addr) |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 37 | { |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 38 | return (int)(addr - ip); |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 39 | } |
| 40 | |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 41 | static unsigned char *ftrace_nop_replace(void) |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 42 | { |
| 43 | return (char *)&ftrace_nop; |
| 44 | } |
| 45 | |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 46 | static unsigned char * |
| 47 | ftrace_call_replace(unsigned long ip, unsigned long addr, int link) |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 48 | { |
| 49 | static unsigned int op; |
| 50 | |
Steven Rostedt | ccbfac2 | 2008-05-22 14:31:07 -0400 | [diff] [blame] | 51 | /* |
| 52 | * It would be nice to just use create_function_call, but that will |
| 53 | * update the code itself. Here we need to just return the |
| 54 | * instruction that is going to be modified, without modifying the |
| 55 | * code. |
| 56 | */ |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 57 | addr = GET_ADDR(addr); |
| 58 | |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 59 | /* if (link) set op to 'bl' else 'b' */ |
| 60 | op = 0x48000000 | (link ? 1 : 0); |
| 61 | op |= (ftrace_calc_offset(ip, addr) & 0x03fffffc); |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | * No locking needed, this must be called via kstop_machine |
| 65 | * which in essence is like running on a uniprocessor machine. |
| 66 | */ |
| 67 | return (unsigned char *)&op; |
| 68 | } |
| 69 | |
| 70 | #ifdef CONFIG_PPC64 |
| 71 | # define _ASM_ALIGN " .align 3 " |
| 72 | # define _ASM_PTR " .llong " |
| 73 | #else |
| 74 | # define _ASM_ALIGN " .align 2 " |
| 75 | # define _ASM_PTR " .long " |
| 76 | #endif |
| 77 | |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 78 | static int |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 79 | ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
| 80 | unsigned char *new_code) |
| 81 | { |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 82 | unsigned char replaced[MCOUNT_INSN_SIZE]; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 83 | |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 84 | /* |
| 85 | * Note: Due to modules and __init, code can |
| 86 | * disappear and change, we need to protect against faulting |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 87 | * as well as code changing. We do this by using the |
| 88 | * probe_kernel_* functions. |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 89 | * |
| 90 | * No real locking needed, this code is run through |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 91 | * kstop_machine, or before SMP starts. |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 92 | */ |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 93 | |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 94 | /* read the text we want to modify */ |
| 95 | if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE)) |
| 96 | return -EFAULT; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 97 | |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 98 | /* Make sure it is what we expect it to be */ |
| 99 | if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0) |
| 100 | return -EINVAL; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 101 | |
Steven Rostedt | e4486fe | 2008-11-14 16:21:20 -0800 | [diff] [blame] | 102 | /* replace the text with the new text */ |
| 103 | if (probe_kernel_write((void *)ip, new_code, MCOUNT_INSN_SIZE)) |
| 104 | return -EPERM; |
| 105 | |
| 106 | flush_icache_range(ip, ip + 8); |
| 107 | |
| 108 | return 0; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 109 | } |
| 110 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 111 | /* |
| 112 | * Helper functions that are the same for both PPC64 and PPC32. |
| 113 | */ |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 114 | static int test_24bit_addr(unsigned long ip, unsigned long addr) |
| 115 | { |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 116 | |
Steven Rostedt | 0029ff8 | 2008-11-25 14:06:19 -0800 | [diff] [blame] | 117 | /* use the create_branch to verify that this offset can be branched */ |
| 118 | return create_branch((unsigned int *)ip, addr, 0); |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 119 | } |
| 120 | |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 121 | #ifdef CONFIG_MODULES |
| 122 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 123 | static int is_bl_op(unsigned int op) |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 124 | { |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 125 | return (op & 0xfc000003) == 0x48000001; |
| 126 | } |
| 127 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 128 | static unsigned long find_bl_target(unsigned long ip, unsigned int op) |
| 129 | { |
| 130 | static int offset; |
| 131 | |
| 132 | offset = (op & 0x03fffffc); |
| 133 | /* make it signed */ |
| 134 | if (offset & 0x02000000) |
| 135 | offset |= 0xfe000000; |
| 136 | |
| 137 | return ip + (long)offset; |
| 138 | } |
| 139 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 140 | #ifdef CONFIG_PPC64 |
| 141 | static int |
| 142 | __ftrace_make_nop(struct module *mod, |
| 143 | struct dyn_ftrace *rec, unsigned long addr) |
| 144 | { |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 145 | unsigned int op; |
| 146 | unsigned int jmp[5]; |
| 147 | unsigned long ptr; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 148 | unsigned long ip = rec->ip; |
| 149 | unsigned long tramp; |
| 150 | int offset; |
| 151 | |
| 152 | /* read where this goes */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 153 | if (probe_kernel_read(&op, (void *)ip, sizeof(int))) |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 154 | return -EFAULT; |
| 155 | |
| 156 | /* Make sure that that this is still a 24bit jump */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 157 | if (!is_bl_op(op)) { |
| 158 | printk(KERN_ERR "Not expected bl: opcode is %x\n", op); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 159 | return -EINVAL; |
| 160 | } |
| 161 | |
| 162 | /* lets find where the pointer goes */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 163 | tramp = find_bl_target(ip, op); |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 164 | |
| 165 | /* |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 166 | * On PPC64 the trampoline looks like: |
| 167 | * 0x3d, 0x82, 0x00, 0x00, addis r12,r2, <high> |
| 168 | * 0x39, 0x8c, 0x00, 0x00, addi r12,r12, <low> |
| 169 | * Where the bytes 2,3,6 and 7 make up the 32bit offset |
| 170 | * to the TOC that holds the pointer. |
| 171 | * to jump to. |
| 172 | * 0xf8, 0x41, 0x00, 0x28, std r2,40(r1) |
| 173 | * 0xe9, 0x6c, 0x00, 0x20, ld r11,32(r12) |
| 174 | * The actually address is 32 bytes from the offset |
| 175 | * into the TOC. |
| 176 | * 0xe8, 0x4c, 0x00, 0x28, ld r2,40(r12) |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 177 | */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 178 | |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 179 | pr_debug("ip:%lx jumps to %lx r2: %lx", ip, tramp, mod->arch.toc); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 180 | |
| 181 | /* Find where the trampoline jumps to */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 182 | if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) { |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 183 | printk(KERN_ERR "Failed to read %lx\n", tramp); |
| 184 | return -EFAULT; |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 185 | } |
| 186 | |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 187 | pr_debug(" %08x %08x", jmp[0], jmp[1]); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 188 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 189 | /* verify that this is what we expect it to be */ |
| 190 | if (((jmp[0] & 0xffff0000) != 0x3d820000) || |
| 191 | ((jmp[1] & 0xffff0000) != 0x398c0000) || |
| 192 | (jmp[2] != 0xf8410028) || |
| 193 | (jmp[3] != 0xe96c0020) || |
| 194 | (jmp[4] != 0xe84c0028)) { |
| 195 | printk(KERN_ERR "Not a trampoline\n"); |
| 196 | return -EINVAL; |
| 197 | } |
| 198 | |
Steven Rostedt | f25f907 | 2009-02-07 20:22:40 +0000 | [diff] [blame] | 199 | /* The bottom half is signed extended */ |
| 200 | offset = ((unsigned)((unsigned short)jmp[0]) << 16) + |
| 201 | (int)((short)jmp[1]); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 202 | |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 203 | pr_debug(" %x ", offset); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 204 | |
| 205 | /* get the address this jumps too */ |
| 206 | tramp = mod->arch.toc + offset + 32; |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 207 | pr_debug("toc: %lx", tramp); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 208 | |
| 209 | if (probe_kernel_read(jmp, (void *)tramp, 8)) { |
| 210 | printk(KERN_ERR "Failed to read %lx\n", tramp); |
| 211 | return -EFAULT; |
| 212 | } |
| 213 | |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 214 | pr_debug(" %08x %08x\n", jmp[0], jmp[1]); |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 215 | |
| 216 | ptr = ((unsigned long)jmp[0] << 32) + jmp[1]; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 217 | |
| 218 | /* This should match what was called */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 219 | if (ptr != GET_ADDR(addr)) { |
| 220 | printk(KERN_ERR "addr does not match %lx\n", ptr); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 221 | return -EINVAL; |
| 222 | } |
| 223 | |
| 224 | /* |
| 225 | * We want to nop the line, but the next line is |
| 226 | * 0xe8, 0x41, 0x00, 0x28 ld r2,40(r1) |
| 227 | * This needs to be turned to a nop too. |
| 228 | */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 229 | if (probe_kernel_read(&op, (void *)(ip+4), MCOUNT_INSN_SIZE)) |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 230 | return -EFAULT; |
| 231 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 232 | if (op != 0xe8410028) { |
| 233 | printk(KERN_ERR "Next line is not ld! (%08x)\n", op); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 234 | return -EINVAL; |
| 235 | } |
| 236 | |
| 237 | /* |
| 238 | * Milton Miller pointed out that we can not blindly do nops. |
| 239 | * If a task was preempted when calling a trace function, |
| 240 | * the nops will remove the way to restore the TOC in r2 |
| 241 | * and the r2 TOC will get corrupted. |
| 242 | */ |
| 243 | |
| 244 | /* |
| 245 | * Replace: |
| 246 | * bl <tramp> <==== will be replaced with "b 1f" |
| 247 | * ld r2,40(r1) |
| 248 | * 1: |
| 249 | */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 250 | op = 0x48000008; /* b +8 */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 251 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 252 | if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 253 | return -EPERM; |
| 254 | |
Steven Rostedt | ec682ce | 2008-11-25 10:22:48 -0800 | [diff] [blame] | 255 | |
| 256 | flush_icache_range(ip, ip + 8); |
| 257 | |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 258 | return 0; |
| 259 | } |
| 260 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 261 | #else /* !PPC64 */ |
| 262 | static int |
| 263 | __ftrace_make_nop(struct module *mod, |
| 264 | struct dyn_ftrace *rec, unsigned long addr) |
| 265 | { |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 266 | unsigned int op; |
| 267 | unsigned int jmp[4]; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 268 | unsigned long ip = rec->ip; |
| 269 | unsigned long tramp; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 270 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 271 | if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE)) |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 272 | return -EFAULT; |
| 273 | |
| 274 | /* Make sure that that this is still a 24bit jump */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 275 | if (!is_bl_op(op)) { |
| 276 | printk(KERN_ERR "Not expected bl: opcode is %x\n", op); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 277 | return -EINVAL; |
| 278 | } |
| 279 | |
| 280 | /* lets find where the pointer goes */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 281 | tramp = find_bl_target(ip, op); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 282 | |
| 283 | /* |
| 284 | * On PPC32 the trampoline looks like: |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 285 | * 0x3d, 0x60, 0x00, 0x00 lis r11,sym@ha |
| 286 | * 0x39, 0x6b, 0x00, 0x00 addi r11,r11,sym@l |
| 287 | * 0x7d, 0x69, 0x03, 0xa6 mtctr r11 |
| 288 | * 0x4e, 0x80, 0x04, 0x20 bctr |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 289 | */ |
| 290 | |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 291 | pr_debug("ip:%lx jumps to %lx", ip, tramp); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 292 | |
| 293 | /* Find where the trampoline jumps to */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 294 | if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) { |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 295 | printk(KERN_ERR "Failed to read %lx\n", tramp); |
| 296 | return -EFAULT; |
| 297 | } |
| 298 | |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 299 | pr_debug(" %08x %08x ", jmp[0], jmp[1]); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 300 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 301 | /* verify that this is what we expect it to be */ |
| 302 | if (((jmp[0] & 0xffff0000) != 0x3d600000) || |
| 303 | ((jmp[1] & 0xffff0000) != 0x396b0000) || |
| 304 | (jmp[2] != 0x7d6903a6) || |
| 305 | (jmp[3] != 0x4e800420)) { |
| 306 | printk(KERN_ERR "Not a trampoline\n"); |
| 307 | return -EINVAL; |
| 308 | } |
| 309 | |
| 310 | tramp = (jmp[1] & 0xffff) | |
| 311 | ((jmp[0] & 0xffff) << 16); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 312 | if (tramp & 0x8000) |
| 313 | tramp -= 0x10000; |
| 314 | |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 315 | pr_debug(" %x ", tramp); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 316 | |
| 317 | if (tramp != addr) { |
| 318 | printk(KERN_ERR |
| 319 | "Trampoline location %08lx does not match addr\n", |
| 320 | tramp); |
| 321 | return -EINVAL; |
| 322 | } |
| 323 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 324 | op = PPC_NOP_INSTR; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 325 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 326 | if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 327 | return -EPERM; |
| 328 | |
Steven Rostedt | ec682ce | 2008-11-25 10:22:48 -0800 | [diff] [blame] | 329 | flush_icache_range(ip, ip + 8); |
| 330 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 331 | return 0; |
| 332 | } |
| 333 | #endif /* PPC64 */ |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 334 | #endif /* CONFIG_MODULES */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 335 | |
| 336 | int ftrace_make_nop(struct module *mod, |
| 337 | struct dyn_ftrace *rec, unsigned long addr) |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 338 | { |
| 339 | unsigned char *old, *new; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 340 | unsigned long ip = rec->ip; |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 341 | |
| 342 | /* |
| 343 | * If the calling address is more that 24 bits away, |
| 344 | * then we had to use a trampoline to make the call. |
| 345 | * Otherwise just update the call site. |
| 346 | */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 347 | if (test_24bit_addr(ip, addr)) { |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 348 | /* within range */ |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 349 | old = ftrace_call_replace(ip, addr, 1); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 350 | new = ftrace_nop_replace(); |
| 351 | return ftrace_modify_code(ip, old, new); |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 352 | } |
| 353 | |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 354 | #ifdef CONFIG_MODULES |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 355 | /* |
| 356 | * Out of range jumps are called from modules. |
| 357 | * We should either already have a pointer to the module |
| 358 | * or it has been passed in. |
| 359 | */ |
| 360 | if (!rec->arch.mod) { |
| 361 | if (!mod) { |
| 362 | printk(KERN_ERR "No module loaded addr=%lx\n", |
| 363 | addr); |
| 364 | return -EFAULT; |
| 365 | } |
| 366 | rec->arch.mod = mod; |
| 367 | } else if (mod) { |
| 368 | if (mod != rec->arch.mod) { |
| 369 | printk(KERN_ERR |
| 370 | "Record mod %p not equal to passed in mod %p\n", |
| 371 | rec->arch.mod, mod); |
| 372 | return -EINVAL; |
| 373 | } |
| 374 | /* nothing to do if mod == rec->arch.mod */ |
| 375 | } else |
| 376 | mod = rec->arch.mod; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 377 | |
| 378 | return __ftrace_make_nop(mod, rec, addr); |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 379 | #else |
| 380 | /* We should not get here without modules */ |
| 381 | return -EINVAL; |
| 382 | #endif /* CONFIG_MODULES */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 383 | } |
| 384 | |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 385 | #ifdef CONFIG_MODULES |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 386 | #ifdef CONFIG_PPC64 |
| 387 | static int |
| 388 | __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) |
| 389 | { |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 390 | unsigned int op[2]; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 391 | unsigned long ip = rec->ip; |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 392 | |
| 393 | /* read where this goes */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 394 | if (probe_kernel_read(op, (void *)ip, MCOUNT_INSN_SIZE * 2)) |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 395 | return -EFAULT; |
| 396 | |
| 397 | /* |
| 398 | * It should be pointing to two nops or |
| 399 | * b +8; ld r2,40(r1) |
| 400 | */ |
| 401 | if (((op[0] != 0x48000008) || (op[1] != 0xe8410028)) && |
| 402 | ((op[0] != PPC_NOP_INSTR) || (op[1] != PPC_NOP_INSTR))) { |
| 403 | printk(KERN_ERR "Expected NOPs but have %x %x\n", op[0], op[1]); |
| 404 | return -EINVAL; |
| 405 | } |
| 406 | |
| 407 | /* If we never set up a trampoline to ftrace_caller, then bail */ |
| 408 | if (!rec->arch.mod->arch.tramp) { |
| 409 | printk(KERN_ERR "No ftrace trampoline\n"); |
| 410 | return -EINVAL; |
| 411 | } |
| 412 | |
Steven Rostedt | 0029ff8 | 2008-11-25 14:06:19 -0800 | [diff] [blame] | 413 | /* create the branch to the trampoline */ |
| 414 | op[0] = create_branch((unsigned int *)ip, |
| 415 | rec->arch.mod->arch.tramp, BRANCH_SET_LINK); |
| 416 | if (!op[0]) { |
| 417 | printk(KERN_ERR "REL24 out of range!\n"); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 418 | return -EINVAL; |
| 419 | } |
| 420 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 421 | /* ld r2,40(r1) */ |
| 422 | op[1] = 0xe8410028; |
| 423 | |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 424 | pr_debug("write to %lx\n", rec->ip); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 425 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 426 | if (probe_kernel_write((void *)ip, op, MCOUNT_INSN_SIZE * 2)) |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 427 | return -EPERM; |
| 428 | |
Steven Rostedt | ec682ce | 2008-11-25 10:22:48 -0800 | [diff] [blame] | 429 | flush_icache_range(ip, ip + 8); |
| 430 | |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 431 | return 0; |
| 432 | } |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 433 | #else |
| 434 | static int |
| 435 | __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) |
| 436 | { |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 437 | unsigned int op; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 438 | unsigned long ip = rec->ip; |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 439 | |
| 440 | /* read where this goes */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 441 | if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE)) |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 442 | return -EFAULT; |
| 443 | |
| 444 | /* It should be pointing to a nop */ |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 445 | if (op != PPC_NOP_INSTR) { |
| 446 | printk(KERN_ERR "Expected NOP but have %x\n", op); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 447 | return -EINVAL; |
| 448 | } |
| 449 | |
| 450 | /* If we never set up a trampoline to ftrace_caller, then bail */ |
| 451 | if (!rec->arch.mod->arch.tramp) { |
| 452 | printk(KERN_ERR "No ftrace trampoline\n"); |
| 453 | return -EINVAL; |
| 454 | } |
| 455 | |
Steven Rostedt | 0029ff8 | 2008-11-25 14:06:19 -0800 | [diff] [blame] | 456 | /* create the branch to the trampoline */ |
| 457 | op = create_branch((unsigned int *)ip, |
| 458 | rec->arch.mod->arch.tramp, BRANCH_SET_LINK); |
| 459 | if (!op) { |
| 460 | printk(KERN_ERR "REL24 out of range!\n"); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 461 | return -EINVAL; |
| 462 | } |
| 463 | |
Steven Rostedt | 44e1d06 | 2009-02-04 18:29:03 -0800 | [diff] [blame] | 464 | pr_debug("write to %lx\n", rec->ip); |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 465 | |
Steven Rostedt | d9af12b7 | 2008-11-25 06:39:18 -0800 | [diff] [blame] | 466 | if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) |
Steven Rostedt | 7cc45e6 | 2008-11-15 02:39:05 -0500 | [diff] [blame] | 467 | return -EPERM; |
| 468 | |
Steven Rostedt | ec682ce | 2008-11-25 10:22:48 -0800 | [diff] [blame] | 469 | flush_icache_range(ip, ip + 8); |
| 470 | |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 471 | return 0; |
| 472 | } |
| 473 | #endif /* CONFIG_PPC64 */ |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 474 | #endif /* CONFIG_MODULES */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 475 | |
| 476 | int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) |
| 477 | { |
| 478 | unsigned char *old, *new; |
| 479 | unsigned long ip = rec->ip; |
| 480 | |
| 481 | /* |
| 482 | * If the calling address is more that 24 bits away, |
| 483 | * then we had to use a trampoline to make the call. |
| 484 | * Otherwise just update the call site. |
| 485 | */ |
| 486 | if (test_24bit_addr(ip, addr)) { |
| 487 | /* within range */ |
| 488 | old = ftrace_nop_replace(); |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 489 | new = ftrace_call_replace(ip, addr, 1); |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 490 | return ftrace_modify_code(ip, old, new); |
| 491 | } |
| 492 | |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 493 | #ifdef CONFIG_MODULES |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 494 | /* |
| 495 | * Out of range jumps are called from modules. |
| 496 | * Being that we are converting from nop, it had better |
| 497 | * already have a module defined. |
| 498 | */ |
| 499 | if (!rec->arch.mod) { |
| 500 | printk(KERN_ERR "No module loaded\n"); |
| 501 | return -EINVAL; |
| 502 | } |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 503 | |
| 504 | return __ftrace_make_call(rec, addr); |
Steven Rostedt | 17be5b3 | 2009-02-05 21:33:09 -0800 | [diff] [blame] | 505 | #else |
| 506 | /* We should not get here without modules */ |
| 507 | return -EINVAL; |
| 508 | #endif /* CONFIG_MODULES */ |
Steven Rostedt | f48cb8b | 2008-11-14 20:47:03 -0800 | [diff] [blame] | 509 | } |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 510 | |
Steven Rostedt | 15adc04 | 2008-10-23 09:33:08 -0400 | [diff] [blame] | 511 | int ftrace_update_ftrace_func(ftrace_func_t func) |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 512 | { |
| 513 | unsigned long ip = (unsigned long)(&ftrace_call); |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 514 | unsigned char old[MCOUNT_INSN_SIZE], *new; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 515 | int ret; |
| 516 | |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 517 | memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE); |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 518 | new = ftrace_call_replace(ip, (unsigned long)func, 1); |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 519 | ret = ftrace_modify_code(ip, old, new); |
| 520 | |
| 521 | return ret; |
| 522 | } |
| 523 | |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 524 | int __init ftrace_dyn_arch_init(void *data) |
| 525 | { |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 526 | /* caller expects data to be zero */ |
| 527 | unsigned long *p = data; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 528 | |
Steven Rostedt | 8fd6e5a | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 529 | *p = 0; |
Steven Rostedt | 4e491d1 | 2008-05-14 23:49:44 -0400 | [diff] [blame] | 530 | |
| 531 | return 0; |
| 532 | } |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 533 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
| 534 | |
| 535 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| 536 | |
Steven Rostedt | 4654288 | 2009-02-10 22:19:54 -0800 | [diff] [blame] | 537 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 538 | extern void ftrace_graph_call(void); |
| 539 | extern void ftrace_graph_stub(void); |
| 540 | |
| 541 | int ftrace_enable_ftrace_graph_caller(void) |
| 542 | { |
| 543 | unsigned long ip = (unsigned long)(&ftrace_graph_call); |
| 544 | unsigned long addr = (unsigned long)(&ftrace_graph_caller); |
| 545 | unsigned long stub = (unsigned long)(&ftrace_graph_stub); |
| 546 | unsigned char old[MCOUNT_INSN_SIZE], *new; |
| 547 | |
| 548 | new = ftrace_call_replace(ip, stub, 0); |
| 549 | memcpy(old, new, MCOUNT_INSN_SIZE); |
| 550 | new = ftrace_call_replace(ip, addr, 0); |
| 551 | |
| 552 | return ftrace_modify_code(ip, old, new); |
| 553 | } |
| 554 | |
| 555 | int ftrace_disable_ftrace_graph_caller(void) |
| 556 | { |
| 557 | unsigned long ip = (unsigned long)(&ftrace_graph_call); |
| 558 | unsigned long addr = (unsigned long)(&ftrace_graph_caller); |
| 559 | unsigned long stub = (unsigned long)(&ftrace_graph_stub); |
| 560 | unsigned char old[MCOUNT_INSN_SIZE], *new; |
| 561 | |
| 562 | new = ftrace_call_replace(ip, addr, 0); |
| 563 | memcpy(old, new, MCOUNT_INSN_SIZE); |
| 564 | new = ftrace_call_replace(ip, stub, 0); |
| 565 | |
| 566 | return ftrace_modify_code(ip, old, new); |
| 567 | } |
| 568 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
| 569 | |
Steven Rostedt | bb72534 | 2009-02-11 12:45:49 -0800 | [diff] [blame] | 570 | #ifdef CONFIG_PPC64 |
| 571 | extern void mod_return_to_handler(void); |
| 572 | #endif |
| 573 | |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 574 | /* |
| 575 | * Hook the return address and push it in the stack of return addrs |
| 576 | * in current thread info. |
| 577 | */ |
| 578 | void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) |
| 579 | { |
| 580 | unsigned long old; |
| 581 | unsigned long long calltime; |
| 582 | int faulted; |
| 583 | struct ftrace_graph_ent trace; |
Steven Rostedt | bb72534 | 2009-02-11 12:45:49 -0800 | [diff] [blame] | 584 | unsigned long return_hooker = (unsigned long)&return_to_handler; |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 585 | |
| 586 | if (unlikely(atomic_read(¤t->tracing_graph_pause))) |
| 587 | return; |
| 588 | |
Steven Rostedt | bb72534 | 2009-02-11 12:45:49 -0800 | [diff] [blame] | 589 | #if CONFIG_PPC64 |
| 590 | /* non core kernel code needs to save and restore the TOC */ |
| 591 | if (REGION_ID(self_addr) != KERNEL_REGION_ID) |
| 592 | return_hooker = (unsigned long)&mod_return_to_handler; |
| 593 | #endif |
| 594 | |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 595 | return_hooker = GET_ADDR(return_hooker); |
| 596 | |
| 597 | /* |
| 598 | * Protect against fault, even if it shouldn't |
| 599 | * happen. This tool is too much intrusive to |
| 600 | * ignore such a protection. |
| 601 | */ |
| 602 | asm volatile( |
| 603 | "1: " PPC_LL "%[old], 0(%[parent])\n" |
| 604 | "2: " PPC_STL "%[return_hooker], 0(%[parent])\n" |
| 605 | " li %[faulted], 0\n" |
Steven Rostedt | fad4f47 | 2009-02-11 19:10:57 -0500 | [diff] [blame^] | 606 | "3:\n" |
Steven Rostedt | 6794c78 | 2009-02-09 21:10:27 -0800 | [diff] [blame] | 607 | |
| 608 | ".section .fixup, \"ax\"\n" |
| 609 | "4: li %[faulted], 1\n" |
| 610 | " b 3b\n" |
| 611 | ".previous\n" |
| 612 | |
| 613 | ".section __ex_table,\"a\"\n" |
| 614 | PPC_LONG_ALIGN "\n" |
| 615 | PPC_LONG "1b,4b\n" |
| 616 | PPC_LONG "2b,4b\n" |
| 617 | ".previous" |
| 618 | |
| 619 | : [old] "=r" (old), [faulted] "=r" (faulted) |
| 620 | : [parent] "r" (parent), [return_hooker] "r" (return_hooker) |
| 621 | : "memory" |
| 622 | ); |
| 623 | |
| 624 | if (unlikely(faulted)) { |
| 625 | ftrace_graph_stop(); |
| 626 | WARN_ON(1); |
| 627 | return; |
| 628 | } |
| 629 | |
| 630 | calltime = cpu_clock(raw_smp_processor_id()); |
| 631 | |
| 632 | if (ftrace_push_return_trace(old, calltime, |
| 633 | self_addr, &trace.depth) == -EBUSY) { |
| 634 | *parent = old; |
| 635 | return; |
| 636 | } |
| 637 | |
| 638 | trace.func = self_addr; |
| 639 | |
| 640 | /* Only trace if the calling function expects to */ |
| 641 | if (!ftrace_graph_entry(&trace)) { |
| 642 | current->curr_ret_stack--; |
| 643 | *parent = old; |
| 644 | } |
| 645 | } |
| 646 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ |