1 // SPDX-License-Identifier: GPL-2.0
3 * Code for replacing ftrace calls with jumps.
7 * Thanks goes out to P.A. Semi, Inc for supplying me with a PPC64 box.
9 * Added function graph tracer code, taken from x86 that was written
10 * by Frederic Weisbecker, and ported to PPC by Steven Rostedt.
14 #define pr_fmt(fmt) "ftrace-powerpc: " fmt
16 #include <linux/spinlock.h>
17 #include <linux/hardirq.h>
18 #include <linux/uaccess.h>
19 #include <linux/module.h>
20 #include <linux/ftrace.h>
21 #include <linux/percpu.h>
22 #include <linux/init.h>
23 #include <linux/list.h>
25 #include <asm/asm-prototypes.h>
26 #include <asm/cacheflush.h>
27 #include <asm/code-patching.h>
28 #include <asm/ftrace.h>
29 #include <asm/syscall.h>
32 #ifdef CONFIG_DYNAMIC_FTRACE
35 * We generally only have a single long_branch tramp and at most 2 or 3 plt
36 * tramps generated. But, we don't use the plt tramps currently. We also allot
37 * 2 tramps after .text and .init.text. So, we only end up with around 3 usable
38 * tramps in total. Set aside 8 just to be sure.
40 #define NUM_FTRACE_TRAMPS 8
41 static unsigned long ftrace_tramps[NUM_FTRACE_TRAMPS];
44 ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
48 addr = ppc_function_entry((void *)addr);
50 /* if (link) set op to 'bl' else 'b' */
51 op = create_branch((unsigned int *)ip, addr, link ? 1 : 0);
57 ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
59 unsigned int replaced;
63 * We are paranoid about modifying text, as if a bug was to happen, it
64 * could cause us to read or write to someplace that could cause harm.
65 * Carefully read and modify the code with probe_kernel_*(), and make
66 * sure what we read is what we expected it to be before modifying it.
69 /* read the text we want to modify */
70 if (probe_kernel_read(&replaced, (void *)ip, MCOUNT_INSN_SIZE))
73 /* Make sure it is what we expect it to be */
74 if (replaced != old) {
75 pr_err("%p: replaced (%#x) != old (%#x)",
76 (void *)ip, replaced, old);
80 /* replace the text with the new text */
81 if (patch_instruction((unsigned int *)ip, new))
88 * Helper functions that are the same for both PPC64 and PPC32.
90 static int test_24bit_addr(unsigned long ip, unsigned long addr)
92 addr = ppc_function_entry((void *)addr);
94 /* use the create_branch to verify that this offset can be branched */
95 return create_branch((unsigned int *)ip, addr, 0);
98 static int is_bl_op(unsigned int op)
100 return (op & 0xfc000003) == 0x48000001;
103 static int is_b_op(unsigned int op)
105 return (op & 0xfc000003) == 0x48000000;
108 static unsigned long find_bl_target(unsigned long ip, unsigned int op)
112 offset = (op & 0x03fffffc);
114 if (offset & 0x02000000)
115 offset |= 0xfe000000;
117 return ip + (long)offset;
120 #ifdef CONFIG_MODULES
123 __ftrace_make_nop(struct module *mod,
124 struct dyn_ftrace *rec, unsigned long addr)
126 unsigned long entry, ptr, tramp;
127 unsigned long ip = rec->ip;
128 unsigned int op, pop;
130 /* read where this goes */
131 if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
132 pr_err("Fetching opcode failed.\n");
136 /* Make sure that that this is still a 24bit jump */
138 pr_err("Not expected bl: opcode is %x\n", op);
142 /* lets find where the pointer goes */
143 tramp = find_bl_target(ip, op);
145 pr_devel("ip:%lx jumps to %lx", ip, tramp);
147 if (module_trampoline_target(mod, tramp, &ptr)) {
148 pr_err("Failed to get trampoline target\n");
152 pr_devel("trampoline target %lx", ptr);
154 entry = ppc_global_function_entry((void *)addr);
155 /* This should match what was called */
157 pr_err("addr %lx does not match expected %lx\n", ptr, entry);
161 #ifdef CONFIG_MPROFILE_KERNEL
162 /* When using -mkernel_profile there is no load to jump over */
165 if (probe_kernel_read(&op, (void *)(ip - 4), 4)) {
166 pr_err("Fetching instruction at %lx failed.\n", ip - 4);
170 /* We expect either a mflr r0, or a std r0, LRSAVE(r1) */
171 if (op != PPC_INST_MFLR && op != PPC_INST_STD_LR) {
172 pr_err("Unexpected instruction %08x around bl _mcount\n", op);
177 * Our original call site looks like:
182 * Milton Miller pointed out that we can not simply nop the branch.
183 * If a task was preempted when calling a trace function, the nops
184 * will remove the way to restore the TOC in r2 and the r2 TOC will
187 * Use a b +8 to jump over the load.
190 pop = PPC_INST_BRANCH | 8; /* b +8 */
193 * Check what is in the next instruction. We can see ld r2,40(r1), but
194 * on first pass after boot we will see mflr r0.
196 if (probe_kernel_read(&op, (void *)(ip+4), MCOUNT_INSN_SIZE)) {
197 pr_err("Fetching op failed.\n");
201 if (op != PPC_INST_LD_TOC) {
202 pr_err("Expected %08x found %08x\n", PPC_INST_LD_TOC, op);
205 #endif /* CONFIG_MPROFILE_KERNEL */
207 if (patch_instruction((unsigned int *)ip, pop)) {
208 pr_err("Patching NOP failed.\n");
217 __ftrace_make_nop(struct module *mod,
218 struct dyn_ftrace *rec, unsigned long addr)
222 unsigned long ip = rec->ip;
225 if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE))
228 /* Make sure that that this is still a 24bit jump */
230 pr_err("Not expected bl: opcode is %x\n", op);
234 /* lets find where the pointer goes */
235 tramp = find_bl_target(ip, op);
238 * On PPC32 the trampoline looks like:
239 * 0x3d, 0x80, 0x00, 0x00 lis r12,sym@ha
240 * 0x39, 0x8c, 0x00, 0x00 addi r12,r12,sym@l
241 * 0x7d, 0x89, 0x03, 0xa6 mtctr r12
242 * 0x4e, 0x80, 0x04, 0x20 bctr
245 pr_devel("ip:%lx jumps to %lx", ip, tramp);
247 /* Find where the trampoline jumps to */
248 if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) {
249 pr_err("Failed to read %lx\n", tramp);
253 pr_devel(" %08x %08x ", jmp[0], jmp[1]);
255 /* verify that this is what we expect it to be */
256 if (((jmp[0] & 0xffff0000) != 0x3d800000) ||
257 ((jmp[1] & 0xffff0000) != 0x398c0000) ||
258 (jmp[2] != 0x7d8903a6) ||
259 (jmp[3] != 0x4e800420)) {
260 pr_err("Not a trampoline\n");
264 tramp = (jmp[1] & 0xffff) |
265 ((jmp[0] & 0xffff) << 16);
269 pr_devel(" %lx ", tramp);
272 pr_err("Trampoline location %08lx does not match addr\n",
279 if (patch_instruction((unsigned int *)ip, op))
285 #endif /* CONFIG_MODULES */
287 static unsigned long find_ftrace_tramp(unsigned long ip)
292 * We have the compiler generated long_branch tramps at the end
293 * and we prefer those
295 for (i = NUM_FTRACE_TRAMPS - 1; i >= 0; i--)
296 if (!ftrace_tramps[i])
298 else if (create_branch((void *)ip, ftrace_tramps[i], 0))
299 return ftrace_tramps[i];
304 static int add_ftrace_tramp(unsigned long tramp)
308 for (i = 0; i < NUM_FTRACE_TRAMPS; i++)
309 if (!ftrace_tramps[i]) {
310 ftrace_tramps[i] = tramp;
318 * If this is a compiler generated long_branch trampoline (essentially, a
319 * trampoline that has a branch to _mcount()), we re-write the branch to
320 * instead go to ftrace_[regs_]caller() and note down the location of this
323 static int setup_mcount_compiler_tramp(unsigned long tramp)
327 static unsigned long ftrace_plt_tramps[NUM_FTRACE_TRAMPS];
329 /* Is this a known long jump tramp? */
330 for (i = 0; i < NUM_FTRACE_TRAMPS; i++)
331 if (!ftrace_tramps[i])
333 else if (ftrace_tramps[i] == tramp)
336 /* Is this a known plt tramp? */
337 for (i = 0; i < NUM_FTRACE_TRAMPS; i++)
338 if (!ftrace_plt_tramps[i])
340 else if (ftrace_plt_tramps[i] == tramp)
343 /* New trampoline -- read where this goes */
344 if (probe_kernel_read(&op, (void *)tramp, sizeof(int))) {
345 pr_debug("Fetching opcode failed.\n");
349 /* Is this a 24 bit branch? */
351 pr_debug("Trampoline is not a long branch tramp.\n");
355 /* lets find where the pointer goes */
356 ptr = find_bl_target(tramp, op);
358 if (ptr != ppc_global_function_entry((void *)_mcount)) {
359 pr_debug("Trampoline target %p is not _mcount\n", (void *)ptr);
363 /* Let's re-write the tramp to go to ftrace_[regs_]caller */
364 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
365 ptr = ppc_global_function_entry((void *)ftrace_regs_caller);
367 ptr = ppc_global_function_entry((void *)ftrace_caller);
369 if (!create_branch((void *)tramp, ptr, 0)) {
370 pr_debug("%ps is not reachable from existing mcount tramp\n",
375 if (patch_branch((unsigned int *)tramp, ptr, 0)) {
376 pr_debug("REL24 out of range!\n");
380 if (add_ftrace_tramp(tramp)) {
381 pr_debug("No tramp locations left\n");
388 static int __ftrace_make_nop_kernel(struct dyn_ftrace *rec, unsigned long addr)
390 unsigned long tramp, ip = rec->ip;
393 /* Read where this goes */
394 if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
395 pr_err("Fetching opcode failed.\n");
399 /* Make sure that that this is still a 24bit jump */
401 pr_err("Not expected bl: opcode is %x\n", op);
405 /* Let's find where the pointer goes */
406 tramp = find_bl_target(ip, op);
408 pr_devel("ip:%lx jumps to %lx", ip, tramp);
410 if (setup_mcount_compiler_tramp(tramp)) {
411 /* Are other trampolines reachable? */
412 if (!find_ftrace_tramp(ip)) {
413 pr_err("No ftrace trampolines reachable from %ps\n",
419 if (patch_instruction((unsigned int *)ip, PPC_INST_NOP)) {
420 pr_err("Patching NOP failed.\n");
427 int ftrace_make_nop(struct module *mod,
428 struct dyn_ftrace *rec, unsigned long addr)
430 unsigned long ip = rec->ip;
431 unsigned int old, new;
434 * If the calling address is more that 24 bits away,
435 * then we had to use a trampoline to make the call.
436 * Otherwise just update the call site.
438 if (test_24bit_addr(ip, addr)) {
440 old = ftrace_call_replace(ip, addr, 1);
442 return ftrace_modify_code(ip, old, new);
443 } else if (core_kernel_text(ip))
444 return __ftrace_make_nop_kernel(rec, addr);
446 #ifdef CONFIG_MODULES
448 * Out of range jumps are called from modules.
449 * We should either already have a pointer to the module
450 * or it has been passed in.
452 if (!rec->arch.mod) {
454 pr_err("No module loaded addr=%lx\n", addr);
459 if (mod != rec->arch.mod) {
460 pr_err("Record mod %p not equal to passed in mod %p\n",
464 /* nothing to do if mod == rec->arch.mod */
468 return __ftrace_make_nop(mod, rec, addr);
470 /* We should not get here without modules */
472 #endif /* CONFIG_MODULES */
475 #ifdef CONFIG_MODULES
478 * Examine the existing instructions for __ftrace_make_call.
479 * They should effectively be a NOP, and follow formal constraints,
480 * depending on the ABI. Return false if they don't.
482 #ifndef CONFIG_MPROFILE_KERNEL
484 expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1)
492 * The load offset is different depending on the ABI. For simplicity
493 * just mask it out when doing the compare.
495 if ((op0 != 0x48000008) || ((op1 & 0xffff0000) != 0xe8410000))
501 expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1)
503 /* look for patched "NOP" on ppc64 with -mprofile-kernel */
504 if (op0 != PPC_INST_NOP)
511 __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
514 void *ip = (void *)rec->ip;
515 unsigned long entry, ptr, tramp;
516 struct module *mod = rec->arch.mod;
518 /* read where this goes */
519 if (probe_kernel_read(op, ip, sizeof(op)))
522 if (!expected_nop_sequence(ip, op[0], op[1])) {
523 pr_err("Unexpected call sequence at %p: %x %x\n",
528 /* If we never set up ftrace trampoline(s), then bail */
529 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
530 if (!mod->arch.tramp || !mod->arch.tramp_regs) {
532 if (!mod->arch.tramp) {
534 pr_err("No ftrace trampoline\n");
538 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
539 if (rec->flags & FTRACE_FL_REGS)
540 tramp = mod->arch.tramp_regs;
543 tramp = mod->arch.tramp;
545 if (module_trampoline_target(mod, tramp, &ptr)) {
546 pr_err("Failed to get trampoline target\n");
550 pr_devel("trampoline target %lx", ptr);
552 entry = ppc_global_function_entry((void *)addr);
553 /* This should match what was called */
555 pr_err("addr %lx does not match expected %lx\n", ptr, entry);
559 /* Ensure branch is within 24 bits */
560 if (!create_branch(ip, tramp, BRANCH_SET_LINK)) {
561 pr_err("Branch out of range\n");
565 if (patch_branch(ip, tramp, BRANCH_SET_LINK)) {
566 pr_err("REL24 out of range!\n");
573 #else /* !CONFIG_PPC64: */
575 __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
578 unsigned long ip = rec->ip;
580 /* read where this goes */
581 if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE))
584 /* It should be pointing to a nop */
585 if (op != PPC_INST_NOP) {
586 pr_err("Expected NOP but have %x\n", op);
590 /* If we never set up a trampoline to ftrace_caller, then bail */
591 if (!rec->arch.mod->arch.tramp) {
592 pr_err("No ftrace trampoline\n");
596 /* create the branch to the trampoline */
597 op = create_branch((unsigned int *)ip,
598 rec->arch.mod->arch.tramp, BRANCH_SET_LINK);
600 pr_err("REL24 out of range!\n");
604 pr_devel("write to %lx\n", rec->ip);
606 if (patch_instruction((unsigned int *)ip, op))
611 #endif /* CONFIG_PPC64 */
612 #endif /* CONFIG_MODULES */
614 static int __ftrace_make_call_kernel(struct dyn_ftrace *rec, unsigned long addr)
617 void *ip = (void *)rec->ip;
618 unsigned long tramp, entry, ptr;
620 /* Make sure we're being asked to patch branch to a known ftrace addr */
621 entry = ppc_global_function_entry((void *)ftrace_caller);
622 ptr = ppc_global_function_entry((void *)addr);
625 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
626 entry = ppc_global_function_entry((void *)ftrace_regs_caller);
629 pr_err("Unknown ftrace addr to patch: %ps\n", (void *)ptr);
631 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
636 /* Make sure we have a nop */
637 if (probe_kernel_read(&op, ip, sizeof(op))) {
638 pr_err("Unable to read ftrace location %p\n", ip);
642 if (op != PPC_INST_NOP) {
643 pr_err("Unexpected call sequence at %p: %x\n", ip, op);
647 tramp = find_ftrace_tramp((unsigned long)ip);
649 pr_err("No ftrace trampolines reachable from %ps\n", ip);
653 if (patch_branch(ip, tramp, BRANCH_SET_LINK)) {
654 pr_err("Error patching branch to ftrace tramp!\n");
661 int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
663 unsigned long ip = rec->ip;
664 unsigned int old, new;
667 * If the calling address is more that 24 bits away,
668 * then we had to use a trampoline to make the call.
669 * Otherwise just update the call site.
671 if (test_24bit_addr(ip, addr)) {
674 new = ftrace_call_replace(ip, addr, 1);
675 return ftrace_modify_code(ip, old, new);
676 } else if (core_kernel_text(ip))
677 return __ftrace_make_call_kernel(rec, addr);
679 #ifdef CONFIG_MODULES
681 * Out of range jumps are called from modules.
682 * Being that we are converting from nop, it had better
683 * already have a module defined.
685 if (!rec->arch.mod) {
686 pr_err("No module loaded\n");
690 return __ftrace_make_call(rec, addr);
692 /* We should not get here without modules */
694 #endif /* CONFIG_MODULES */
697 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
698 #ifdef CONFIG_MODULES
700 __ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
704 unsigned long ip = rec->ip;
705 unsigned long entry, ptr, tramp;
706 struct module *mod = rec->arch.mod;
708 /* If we never set up ftrace trampolines, then bail */
709 if (!mod->arch.tramp || !mod->arch.tramp_regs) {
710 pr_err("No ftrace trampoline\n");
714 /* read where this goes */
715 if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
716 pr_err("Fetching opcode failed.\n");
720 /* Make sure that that this is still a 24bit jump */
722 pr_err("Not expected bl: opcode is %x\n", op);
726 /* lets find where the pointer goes */
727 tramp = find_bl_target(ip, op);
728 entry = ppc_global_function_entry((void *)old_addr);
730 pr_devel("ip:%lx jumps to %lx", ip, tramp);
732 if (tramp != entry) {
733 /* old_addr is not within range, so we must have used a trampoline */
734 if (module_trampoline_target(mod, tramp, &ptr)) {
735 pr_err("Failed to get trampoline target\n");
739 pr_devel("trampoline target %lx", ptr);
741 /* This should match what was called */
743 pr_err("addr %lx does not match expected %lx\n", ptr, entry);
748 /* The new target may be within range */
749 if (test_24bit_addr(ip, addr)) {
751 if (patch_branch((unsigned int *)ip, addr, BRANCH_SET_LINK)) {
752 pr_err("REL24 out of range!\n");
759 if (rec->flags & FTRACE_FL_REGS)
760 tramp = mod->arch.tramp_regs;
762 tramp = mod->arch.tramp;
764 if (module_trampoline_target(mod, tramp, &ptr)) {
765 pr_err("Failed to get trampoline target\n");
769 pr_devel("trampoline target %lx", ptr);
771 entry = ppc_global_function_entry((void *)addr);
772 /* This should match what was called */
774 pr_err("addr %lx does not match expected %lx\n", ptr, entry);
778 /* Ensure branch is within 24 bits */
779 if (!create_branch((unsigned int *)ip, tramp, BRANCH_SET_LINK)) {
780 pr_err("Branch out of range\n");
784 if (patch_branch((unsigned int *)ip, tramp, BRANCH_SET_LINK)) {
785 pr_err("REL24 out of range!\n");
793 int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
796 unsigned long ip = rec->ip;
797 unsigned int old, new;
800 * If the calling address is more that 24 bits away,
801 * then we had to use a trampoline to make the call.
802 * Otherwise just update the call site.
804 if (test_24bit_addr(ip, addr) && test_24bit_addr(ip, old_addr)) {
806 old = ftrace_call_replace(ip, old_addr, 1);
807 new = ftrace_call_replace(ip, addr, 1);
808 return ftrace_modify_code(ip, old, new);
809 } else if (core_kernel_text(ip)) {
811 * We always patch out of range locations to go to the regs
812 * variant, so there is nothing to do here
817 #ifdef CONFIG_MODULES
819 * Out of range jumps are called from modules.
821 if (!rec->arch.mod) {
822 pr_err("No module loaded\n");
826 return __ftrace_modify_call(rec, old_addr, addr);
828 /* We should not get here without modules */
830 #endif /* CONFIG_MODULES */
834 int ftrace_update_ftrace_func(ftrace_func_t func)
836 unsigned long ip = (unsigned long)(&ftrace_call);
837 unsigned int old, new;
840 old = *(unsigned int *)&ftrace_call;
841 new = ftrace_call_replace(ip, (unsigned long)func, 1);
842 ret = ftrace_modify_code(ip, old, new);
844 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
845 /* Also update the regs callback function */
847 ip = (unsigned long)(&ftrace_regs_call);
848 old = *(unsigned int *)&ftrace_regs_call;
849 new = ftrace_call_replace(ip, (unsigned long)func, 1);
850 ret = ftrace_modify_code(ip, old, new);
858 * Use the default ftrace_modify_all_code, but without
861 void arch_ftrace_update_code(int command)
863 ftrace_modify_all_code(command);
867 #define PACATOC offsetof(struct paca_struct, kernel_toc)
869 #define PPC_LO(v) ((v) & 0xffff)
870 #define PPC_HI(v) (((v) >> 16) & 0xffff)
871 #define PPC_HA(v) PPC_HI ((v) + 0x8000)
873 extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[];
875 int __init ftrace_dyn_arch_init(void)
878 unsigned int *tramp[] = { ftrace_tramp_text, ftrace_tramp_init };
880 0xe98d0000 | PACATOC, /* ld r12,PACATOC(r13) */
881 0x3d8c0000, /* addis r12,r12,<high> */
882 0x398c0000, /* addi r12,r12,<low> */
883 0x7d8903a6, /* mtctr r12 */
884 0x4e800420, /* bctr */
886 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
887 unsigned long addr = ppc_global_function_entry((void *)ftrace_regs_caller);
889 unsigned long addr = ppc_global_function_entry((void *)ftrace_caller);
891 long reladdr = addr - kernel_toc_addr();
893 if (reladdr > 0x7FFFFFFF || reladdr < -(0x80000000L)) {
894 pr_err("Address of %ps out of range of kernel_toc.\n",
899 for (i = 0; i < 2; i++) {
900 memcpy(tramp[i], stub_insns, sizeof(stub_insns));
901 tramp[i][1] |= PPC_HA(reladdr);
902 tramp[i][2] |= PPC_LO(reladdr);
903 add_ftrace_tramp((unsigned long)tramp[i]);
909 int __init ftrace_dyn_arch_init(void)
914 #endif /* CONFIG_DYNAMIC_FTRACE */
916 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
918 extern void ftrace_graph_call(void);
919 extern void ftrace_graph_stub(void);
921 int ftrace_enable_ftrace_graph_caller(void)
923 unsigned long ip = (unsigned long)(&ftrace_graph_call);
924 unsigned long addr = (unsigned long)(&ftrace_graph_caller);
925 unsigned long stub = (unsigned long)(&ftrace_graph_stub);
926 unsigned int old, new;
928 old = ftrace_call_replace(ip, stub, 0);
929 new = ftrace_call_replace(ip, addr, 0);
931 return ftrace_modify_code(ip, old, new);
934 int ftrace_disable_ftrace_graph_caller(void)
936 unsigned long ip = (unsigned long)(&ftrace_graph_call);
937 unsigned long addr = (unsigned long)(&ftrace_graph_caller);
938 unsigned long stub = (unsigned long)(&ftrace_graph_stub);
939 unsigned int old, new;
941 old = ftrace_call_replace(ip, addr, 0);
942 new = ftrace_call_replace(ip, stub, 0);
944 return ftrace_modify_code(ip, old, new);
948 * Hook the return address and push it in the stack of return addrs
949 * in current thread info. Return the address we want to divert to.
951 unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip)
953 struct ftrace_graph_ent trace;
954 unsigned long return_hooker;
956 if (unlikely(ftrace_graph_is_dead()))
959 if (unlikely(atomic_read(¤t->tracing_graph_pause)))
962 return_hooker = ppc_function_entry(return_to_handler);
965 trace.depth = current->curr_ret_stack + 1;
967 /* Only trace if the calling function expects to */
968 if (!ftrace_graph_entry(&trace))
971 if (ftrace_push_return_trace(parent, ip, &trace.depth, 0,
975 parent = return_hooker;
979 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
981 #if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64)
982 unsigned long __init arch_syscall_addr(int nr)
984 return sys_call_table[nr*2];
986 #endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
988 #ifdef PPC64_ELF_ABI_v1
989 char *arch_ftrace_match_adjust(char *str, const char *search)
991 if (str[0] == '.' && search[0] != '.')
996 #endif /* PPC64_ELF_ABI_v1 */