diff options
Diffstat (limited to 'arch/powerpc/kernel/ftrace.c')
-rw-r--r-- | arch/powerpc/kernel/ftrace.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c index f202d0731b06..d178834fe508 100644 --- a/arch/powerpc/kernel/ftrace.c +++ b/arch/powerpc/kernel/ftrace.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) "ftrace-powerpc: " fmt | ||
14 | |||
13 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
14 | #include <linux/hardirq.h> | 16 | #include <linux/hardirq.h> |
15 | #include <linux/uaccess.h> | 17 | #include <linux/uaccess.h> |
@@ -105,7 +107,7 @@ __ftrace_make_nop(struct module *mod, | |||
105 | struct dyn_ftrace *rec, unsigned long addr) | 107 | struct dyn_ftrace *rec, unsigned long addr) |
106 | { | 108 | { |
107 | unsigned int op; | 109 | unsigned int op; |
108 | unsigned long ptr; | 110 | unsigned long entry, ptr; |
109 | unsigned long ip = rec->ip; | 111 | unsigned long ip = rec->ip; |
110 | void *tramp; | 112 | void *tramp; |
111 | 113 | ||
@@ -115,7 +117,7 @@ __ftrace_make_nop(struct module *mod, | |||
115 | 117 | ||
116 | /* Make sure that that this is still a 24bit jump */ | 118 | /* Make sure that that this is still a 24bit jump */ |
117 | if (!is_bl_op(op)) { | 119 | if (!is_bl_op(op)) { |
118 | printk(KERN_ERR "Not expected bl: opcode is %x\n", op); | 120 | pr_err("Not expected bl: opcode is %x\n", op); |
119 | return -EINVAL; | 121 | return -EINVAL; |
120 | } | 122 | } |
121 | 123 | ||
@@ -125,21 +127,21 @@ __ftrace_make_nop(struct module *mod, | |||
125 | pr_devel("ip:%lx jumps to %p", ip, tramp); | 127 | pr_devel("ip:%lx jumps to %p", ip, tramp); |
126 | 128 | ||
127 | if (!is_module_trampoline(tramp)) { | 129 | if (!is_module_trampoline(tramp)) { |
128 | printk(KERN_ERR "Not a trampoline\n"); | 130 | pr_err("Not a trampoline\n"); |
129 | return -EINVAL; | 131 | return -EINVAL; |
130 | } | 132 | } |
131 | 133 | ||
132 | if (module_trampoline_target(mod, tramp, &ptr)) { | 134 | if (module_trampoline_target(mod, tramp, &ptr)) { |
133 | printk(KERN_ERR "Failed to get trampoline target\n"); | 135 | pr_err("Failed to get trampoline target\n"); |
134 | return -EFAULT; | 136 | return -EFAULT; |
135 | } | 137 | } |
136 | 138 | ||
137 | pr_devel("trampoline target %lx", ptr); | 139 | pr_devel("trampoline target %lx", ptr); |
138 | 140 | ||
141 | entry = ppc_global_function_entry((void *)addr); | ||
139 | /* This should match what was called */ | 142 | /* This should match what was called */ |
140 | if (ptr != ppc_function_entry((void *)addr)) { | 143 | if (ptr != entry) { |
141 | printk(KERN_ERR "addr %lx does not match expected %lx\n", | 144 | pr_err("addr %lx does not match expected %lx\n", ptr, entry); |
142 | ptr, ppc_function_entry((void *)addr)); | ||
143 | return -EINVAL; | 145 | return -EINVAL; |
144 | } | 146 | } |
145 | 147 | ||
@@ -179,7 +181,7 @@ __ftrace_make_nop(struct module *mod, | |||
179 | 181 | ||
180 | /* Make sure that that this is still a 24bit jump */ | 182 | /* Make sure that that this is still a 24bit jump */ |
181 | if (!is_bl_op(op)) { | 183 | if (!is_bl_op(op)) { |
182 | printk(KERN_ERR "Not expected bl: opcode is %x\n", op); | 184 | pr_err("Not expected bl: opcode is %x\n", op); |
183 | return -EINVAL; | 185 | return -EINVAL; |
184 | } | 186 | } |
185 | 187 | ||
@@ -198,7 +200,7 @@ __ftrace_make_nop(struct module *mod, | |||
198 | 200 | ||
199 | /* Find where the trampoline jumps to */ | 201 | /* Find where the trampoline jumps to */ |
200 | if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) { | 202 | if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) { |
201 | printk(KERN_ERR "Failed to read %lx\n", tramp); | 203 | pr_err("Failed to read %lx\n", tramp); |
202 | return -EFAULT; | 204 | return -EFAULT; |
203 | } | 205 | } |
204 | 206 | ||
@@ -209,7 +211,7 @@ __ftrace_make_nop(struct module *mod, | |||
209 | ((jmp[1] & 0xffff0000) != 0x398c0000) || | 211 | ((jmp[1] & 0xffff0000) != 0x398c0000) || |
210 | (jmp[2] != 0x7d8903a6) || | 212 | (jmp[2] != 0x7d8903a6) || |
211 | (jmp[3] != 0x4e800420)) { | 213 | (jmp[3] != 0x4e800420)) { |
212 | printk(KERN_ERR "Not a trampoline\n"); | 214 | pr_err("Not a trampoline\n"); |
213 | return -EINVAL; | 215 | return -EINVAL; |
214 | } | 216 | } |
215 | 217 | ||
@@ -221,8 +223,7 @@ __ftrace_make_nop(struct module *mod, | |||
221 | pr_devel(" %lx ", tramp); | 223 | pr_devel(" %lx ", tramp); |
222 | 224 | ||
223 | if (tramp != addr) { | 225 | if (tramp != addr) { |
224 | printk(KERN_ERR | 226 | pr_err("Trampoline location %08lx does not match addr\n", |
225 | "Trampoline location %08lx does not match addr\n", | ||
226 | tramp); | 227 | tramp); |
227 | return -EINVAL; | 228 | return -EINVAL; |
228 | } | 229 | } |
@@ -263,15 +264,13 @@ int ftrace_make_nop(struct module *mod, | |||
263 | */ | 264 | */ |
264 | if (!rec->arch.mod) { | 265 | if (!rec->arch.mod) { |
265 | if (!mod) { | 266 | if (!mod) { |
266 | printk(KERN_ERR "No module loaded addr=%lx\n", | 267 | pr_err("No module loaded addr=%lx\n", addr); |
267 | addr); | ||
268 | return -EFAULT; | 268 | return -EFAULT; |
269 | } | 269 | } |
270 | rec->arch.mod = mod; | 270 | rec->arch.mod = mod; |
271 | } else if (mod) { | 271 | } else if (mod) { |
272 | if (mod != rec->arch.mod) { | 272 | if (mod != rec->arch.mod) { |
273 | printk(KERN_ERR | 273 | pr_err("Record mod %p not equal to passed in mod %p\n", |
274 | "Record mod %p not equal to passed in mod %p\n", | ||
275 | rec->arch.mod, mod); | 274 | rec->arch.mod, mod); |
276 | return -EINVAL; | 275 | return -EINVAL; |
277 | } | 276 | } |
@@ -307,26 +306,25 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) | |||
307 | * The load offset is different depending on the ABI. For simplicity | 306 | * The load offset is different depending on the ABI. For simplicity |
308 | * just mask it out when doing the compare. | 307 | * just mask it out when doing the compare. |
309 | */ | 308 | */ |
310 | if ((op[0] != 0x48000008) || ((op[1] & 0xffff00000) != 0xe8410000)) { | 309 | if ((op[0] != 0x48000008) || ((op[1] & 0xffff0000) != 0xe8410000)) { |
311 | printk(KERN_ERR "Unexpected call sequence: %x %x\n", | 310 | pr_err("Unexpected call sequence: %x %x\n", op[0], op[1]); |
312 | op[0], op[1]); | ||
313 | return -EINVAL; | 311 | return -EINVAL; |
314 | } | 312 | } |
315 | 313 | ||
316 | /* If we never set up a trampoline to ftrace_caller, then bail */ | 314 | /* If we never set up a trampoline to ftrace_caller, then bail */ |
317 | if (!rec->arch.mod->arch.tramp) { | 315 | if (!rec->arch.mod->arch.tramp) { |
318 | printk(KERN_ERR "No ftrace trampoline\n"); | 316 | pr_err("No ftrace trampoline\n"); |
319 | return -EINVAL; | 317 | return -EINVAL; |
320 | } | 318 | } |
321 | 319 | ||
322 | /* Ensure branch is within 24 bits */ | 320 | /* Ensure branch is within 24 bits */ |
323 | if (create_branch(ip, rec->arch.mod->arch.tramp, BRANCH_SET_LINK)) { | 321 | if (!create_branch(ip, rec->arch.mod->arch.tramp, BRANCH_SET_LINK)) { |
324 | printk(KERN_ERR "Branch out of range"); | 322 | pr_err("Branch out of range\n"); |
325 | return -EINVAL; | 323 | return -EINVAL; |
326 | } | 324 | } |
327 | 325 | ||
328 | if (patch_branch(ip, rec->arch.mod->arch.tramp, BRANCH_SET_LINK)) { | 326 | if (patch_branch(ip, rec->arch.mod->arch.tramp, BRANCH_SET_LINK)) { |
329 | printk(KERN_ERR "REL24 out of range!\n"); | 327 | pr_err("REL24 out of range!\n"); |
330 | return -EINVAL; | 328 | return -EINVAL; |
331 | } | 329 | } |
332 | 330 | ||
@@ -345,13 +343,13 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) | |||
345 | 343 | ||
346 | /* It should be pointing to a nop */ | 344 | /* It should be pointing to a nop */ |
347 | if (op != PPC_INST_NOP) { | 345 | if (op != PPC_INST_NOP) { |
348 | printk(KERN_ERR "Expected NOP but have %x\n", op); | 346 | pr_err("Expected NOP but have %x\n", op); |
349 | return -EINVAL; | 347 | return -EINVAL; |
350 | } | 348 | } |
351 | 349 | ||
352 | /* If we never set up a trampoline to ftrace_caller, then bail */ | 350 | /* If we never set up a trampoline to ftrace_caller, then bail */ |
353 | if (!rec->arch.mod->arch.tramp) { | 351 | if (!rec->arch.mod->arch.tramp) { |
354 | printk(KERN_ERR "No ftrace trampoline\n"); | 352 | pr_err("No ftrace trampoline\n"); |
355 | return -EINVAL; | 353 | return -EINVAL; |
356 | } | 354 | } |
357 | 355 | ||
@@ -359,7 +357,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) | |||
359 | op = create_branch((unsigned int *)ip, | 357 | op = create_branch((unsigned int *)ip, |
360 | rec->arch.mod->arch.tramp, BRANCH_SET_LINK); | 358 | rec->arch.mod->arch.tramp, BRANCH_SET_LINK); |
361 | if (!op) { | 359 | if (!op) { |
362 | printk(KERN_ERR "REL24 out of range!\n"); | 360 | pr_err("REL24 out of range!\n"); |
363 | return -EINVAL; | 361 | return -EINVAL; |
364 | } | 362 | } |
365 | 363 | ||
@@ -397,7 +395,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) | |||
397 | * already have a module defined. | 395 | * already have a module defined. |
398 | */ | 396 | */ |
399 | if (!rec->arch.mod) { | 397 | if (!rec->arch.mod) { |
400 | printk(KERN_ERR "No module loaded\n"); | 398 | pr_err("No module loaded\n"); |
401 | return -EINVAL; | 399 | return -EINVAL; |
402 | } | 400 | } |
403 | 401 | ||