aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/kernel/ftrace.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 60c60ccf5e3c..77a7d186db1c 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -20,12 +20,6 @@
20#include <asm/code-patching.h> 20#include <asm/code-patching.h>
21#include <asm/ftrace.h> 21#include <asm/ftrace.h>
22 22
23#if 0
24#define DEBUGP printk
25#else
26#define DEBUGP(fmt , ...) do { } while (0)
27#endif
28
29static unsigned int ftrace_nop = PPC_NOP_INSTR; 23static unsigned int ftrace_nop = PPC_NOP_INSTR;
30 24
31#ifdef CONFIG_PPC32 25#ifdef CONFIG_PPC32
@@ -175,7 +169,7 @@ __ftrace_make_nop(struct module *mod,
175 * 0xe8, 0x4c, 0x00, 0x28, ld r2,40(r12) 169 * 0xe8, 0x4c, 0x00, 0x28, ld r2,40(r12)
176 */ 170 */
177 171
178 DEBUGP("ip:%lx jumps to %lx r2: %lx", ip, tramp, mod->arch.toc); 172 pr_debug("ip:%lx jumps to %lx r2: %lx", ip, tramp, mod->arch.toc);
179 173
180 /* Find where the trampoline jumps to */ 174 /* Find where the trampoline jumps to */
181 if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) { 175 if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) {
@@ -183,7 +177,7 @@ __ftrace_make_nop(struct module *mod,
183 return -EFAULT; 177 return -EFAULT;
184 } 178 }
185 179
186 DEBUGP(" %08x %08x", jmp[0], jmp[1]); 180 pr_debug(" %08x %08x", jmp[0], jmp[1]);
187 181
188 /* verify that this is what we expect it to be */ 182 /* verify that this is what we expect it to be */
189 if (((jmp[0] & 0xffff0000) != 0x3d820000) || 183 if (((jmp[0] & 0xffff0000) != 0x3d820000) ||
@@ -199,18 +193,18 @@ __ftrace_make_nop(struct module *mod,
199 offset = ((unsigned)((unsigned short)jmp[0]) << 16) + 193 offset = ((unsigned)((unsigned short)jmp[0]) << 16) +
200 (int)((short)jmp[1]); 194 (int)((short)jmp[1]);
201 195
202 DEBUGP(" %x ", offset); 196 pr_debug(" %x ", offset);
203 197
204 /* get the address this jumps too */ 198 /* get the address this jumps too */
205 tramp = mod->arch.toc + offset + 32; 199 tramp = mod->arch.toc + offset + 32;
206 DEBUGP("toc: %lx", tramp); 200 pr_debug("toc: %lx", tramp);
207 201
208 if (probe_kernel_read(jmp, (void *)tramp, 8)) { 202 if (probe_kernel_read(jmp, (void *)tramp, 8)) {
209 printk(KERN_ERR "Failed to read %lx\n", tramp); 203 printk(KERN_ERR "Failed to read %lx\n", tramp);
210 return -EFAULT; 204 return -EFAULT;
211 } 205 }
212 206
213 DEBUGP(" %08x %08x\n", jmp[0], jmp[1]); 207 pr_debug(" %08x %08x\n", jmp[0], jmp[1]);
214 208
215 ptr = ((unsigned long)jmp[0] << 32) + jmp[1]; 209 ptr = ((unsigned long)jmp[0] << 32) + jmp[1];
216 210
@@ -287,7 +281,7 @@ __ftrace_make_nop(struct module *mod,
287 * 0x4e, 0x80, 0x04, 0x20 bctr 281 * 0x4e, 0x80, 0x04, 0x20 bctr
288 */ 282 */
289 283
290 DEBUGP("ip:%lx jumps to %lx", ip, tramp); 284 pr_debug("ip:%lx jumps to %lx", ip, tramp);
291 285
292 /* Find where the trampoline jumps to */ 286 /* Find where the trampoline jumps to */
293 if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) { 287 if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) {
@@ -295,7 +289,7 @@ __ftrace_make_nop(struct module *mod,
295 return -EFAULT; 289 return -EFAULT;
296 } 290 }
297 291
298 DEBUGP(" %08x %08x ", jmp[0], jmp[1]); 292 pr_debug(" %08x %08x ", jmp[0], jmp[1]);
299 293
300 /* verify that this is what we expect it to be */ 294 /* verify that this is what we expect it to be */
301 if (((jmp[0] & 0xffff0000) != 0x3d600000) || 295 if (((jmp[0] & 0xffff0000) != 0x3d600000) ||
@@ -311,7 +305,7 @@ __ftrace_make_nop(struct module *mod,
311 if (tramp & 0x8000) 305 if (tramp & 0x8000)
312 tramp -= 0x10000; 306 tramp -= 0x10000;
313 307
314 DEBUGP(" %x ", tramp); 308 pr_debug(" %x ", tramp);
315 309
316 if (tramp != addr) { 310 if (tramp != addr) {
317 printk(KERN_ERR 311 printk(KERN_ERR
@@ -414,7 +408,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
414 /* ld r2,40(r1) */ 408 /* ld r2,40(r1) */
415 op[1] = 0xe8410028; 409 op[1] = 0xe8410028;
416 410
417 DEBUGP("write to %lx\n", rec->ip); 411 pr_debug("write to %lx\n", rec->ip);
418 412
419 if (probe_kernel_write((void *)ip, op, MCOUNT_INSN_SIZE * 2)) 413 if (probe_kernel_write((void *)ip, op, MCOUNT_INSN_SIZE * 2))
420 return -EPERM; 414 return -EPERM;
@@ -454,7 +448,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
454 return -EINVAL; 448 return -EINVAL;
455 } 449 }
456 450
457 DEBUGP("write to %lx\n", rec->ip); 451 pr_debug("write to %lx\n", rec->ip);
458 452
459 if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) 453 if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE))
460 return -EPERM; 454 return -EPERM;