aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/ftrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/ftrace.c')
-rw-r--r--arch/powerpc/kernel/ftrace.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 2d182f119d1d..1b12696cca06 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -23,25 +23,14 @@
23#include <asm/code-patching.h> 23#include <asm/code-patching.h>
24#include <asm/ftrace.h> 24#include <asm/ftrace.h>
25 25
26#ifdef CONFIG_PPC32
27# define GET_ADDR(addr) addr
28#else
29/* PowerPC64's functions are data that points to the functions */
30# define GET_ADDR(addr) (*(unsigned long *)addr)
31#endif
32 26
33#ifdef CONFIG_DYNAMIC_FTRACE 27#ifdef CONFIG_DYNAMIC_FTRACE
34static unsigned int ftrace_nop_replace(void)
35{
36 return PPC_INST_NOP;
37}
38
39static unsigned int 28static unsigned int
40ftrace_call_replace(unsigned long ip, unsigned long addr, int link) 29ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
41{ 30{
42 unsigned int op; 31 unsigned int op;
43 32
44 addr = GET_ADDR(addr); 33 addr = ppc_function_entry((void *)addr);
45 34
46 /* if (link) set op to 'bl' else 'b' */ 35 /* if (link) set op to 'bl' else 'b' */
47 op = create_branch((unsigned int *)ip, addr, link ? 1 : 0); 36 op = create_branch((unsigned int *)ip, addr, link ? 1 : 0);
@@ -49,14 +38,6 @@ ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
49 return op; 38 return op;
50} 39}
51 40
52#ifdef CONFIG_PPC64
53# define _ASM_ALIGN " .align 3 "
54# define _ASM_PTR " .llong "
55#else
56# define _ASM_ALIGN " .align 2 "
57# define _ASM_PTR " .long "
58#endif
59
60static int 41static int
61ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new) 42ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
62{ 43{
@@ -197,7 +178,7 @@ __ftrace_make_nop(struct module *mod,
197 ptr = ((unsigned long)jmp[0] << 32) + jmp[1]; 178 ptr = ((unsigned long)jmp[0] << 32) + jmp[1];
198 179
199 /* This should match what was called */ 180 /* This should match what was called */
200 if (ptr != GET_ADDR(addr)) { 181 if (ptr != ppc_function_entry((void *)addr)) {
201 printk(KERN_ERR "addr does not match %lx\n", ptr); 182 printk(KERN_ERR "addr does not match %lx\n", ptr);
202 return -EINVAL; 183 return -EINVAL;
203 } 184 }
@@ -328,7 +309,7 @@ int ftrace_make_nop(struct module *mod,
328 if (test_24bit_addr(ip, addr)) { 309 if (test_24bit_addr(ip, addr)) {
329 /* within range */ 310 /* within range */
330 old = ftrace_call_replace(ip, addr, 1); 311 old = ftrace_call_replace(ip, addr, 1);
331 new = ftrace_nop_replace(); 312 new = PPC_INST_NOP;
332 return ftrace_modify_code(ip, old, new); 313 return ftrace_modify_code(ip, old, new);
333 } 314 }
334 315
@@ -466,7 +447,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
466 */ 447 */
467 if (test_24bit_addr(ip, addr)) { 448 if (test_24bit_addr(ip, addr)) {
468 /* within range */ 449 /* within range */
469 old = ftrace_nop_replace(); 450 old = PPC_INST_NOP;
470 new = ftrace_call_replace(ip, addr, 1); 451 new = ftrace_call_replace(ip, addr, 1);
471 return ftrace_modify_code(ip, old, new); 452 return ftrace_modify_code(ip, old, new);
472 } 453 }
@@ -570,7 +551,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
570 return_hooker = (unsigned long)&mod_return_to_handler; 551 return_hooker = (unsigned long)&mod_return_to_handler;
571#endif 552#endif
572 553
573 return_hooker = GET_ADDR(return_hooker); 554 return_hooker = ppc_function_entry((void *)return_hooker);
574 555
575 /* 556 /*
576 * Protect against fault, even if it shouldn't 557 * Protect against fault, even if it shouldn't