1 // SPDX-License-Identifier: GPL-2.0
3 * Code for replacing ftrace calls with jumps.
5 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
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] == tramp)
334 /* Is this a known plt tramp? */
335 for (i = 0; i < NUM_FTRACE_TRAMPS; i++)
336 if (!ftrace_plt_tramps[i])
338 else if (ftrace_plt_tramps[i] == tramp)
341 /* New trampoline -- read where this goes */
342 if (probe_kernel_read(&op, (void *)tramp, sizeof(int))) {
343 pr_debug("Fetching opcode failed.\n");
347 /* Is this a 24 bit branch? */
349 pr_debug("Trampoline is not a long branch tramp.\n");
353 /* lets find where the pointer goes */
354 ptr = find_bl_target(tramp, op);
356 if (ptr != ppc_global_function_entry((void *)_mcount)) {
357 pr_debug("Trampoline target %p is not _mcount\n", (void *)ptr);
361 /* Let's re-write the tramp to go to ftrace_[regs_]caller */
362 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
363 ptr = ppc_global_function_entry((void *)ftrace_regs_caller);
365 ptr = ppc_global_function_entry((void *)ftrace_caller);
367 if (!create_branch((void *)tramp, ptr, 0)) {
368 pr_debug("%ps is not reachable from existing mcount tramp\n",
373 if (patch_branch((unsigned int *)tramp, ptr, 0)) {
374 pr_debug("REL24 out of range!\n");
378 if (add_ftrace_tramp(tramp)) {
379 pr_debug("No tramp locations left\n");
386 static int __ftrace_make_nop_kernel(struct dyn_ftrace *rec, unsigned long addr)
388 unsigned long tramp, ip = rec->ip;
391 /* Read where this goes */
392 if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
393 pr_err("Fetching opcode failed.\n");
397 /* Make sure that that this is still a 24bit jump */
399 pr_err("Not expected bl: opcode is %x\n", op);
403 /* Let's find where the pointer goes */
404 tramp = find_bl_target(ip, op);
406 pr_devel("ip:%lx jumps to %lx", ip, tramp);
408 if (setup_mcount_compiler_tramp(tramp)) {
409 /* Are other trampolines reachable? */
410 if (!find_ftrace_tramp(ip)) {
411 pr_err("No ftrace trampolines reachable from %ps\n",
417 if (patch_instruction((unsigned int *)ip, PPC_INST_NOP)) {
418 pr_err("Patching NOP failed.\n");
425 int ftrace_make_nop(struct module *mod,
426 struct dyn_ftrace *rec, unsigned long addr)
428 unsigned long ip = rec->ip;
429 unsigned int old, new;
432 * If the calling address is more that 24 bits away,
433 * then we had to use a trampoline to make the call.
434 * Otherwise just update the call site.
436 if (test_24bit_addr(ip, addr)) {
438 old = ftrace_call_replace(ip, addr, 1);
440 return ftrace_modify_code(ip, old, new);
441 } else if (core_kernel_text(ip))
442 return __ftrace_make_nop_kernel(rec, addr);
444 #ifdef CONFIG_MODULES
446 * Out of range jumps are called from modules.
447 * We should either already have a pointer to the module
448 * or it has been passed in.
450 if (!rec->arch.mod) {
452 pr_err("No module loaded addr=%lx\n", addr);
457 if (mod != rec->arch.mod) {
458 pr_err("Record mod %p not equal to passed in mod %p\n",
462 /* nothing to do if mod == rec->arch.mod */
466 return __ftrace_make_nop(mod, rec, addr);
468 /* We should not get here without modules */
470 #endif /* CONFIG_MODULES */
473 #ifdef CONFIG_MODULES
476 * Examine the existing instructions for __ftrace_make_call.
477 * They should effectively be a NOP, and follow formal constraints,
478 * depending on the ABI. Return false if they don't.
480 #ifndef CONFIG_MPROFILE_KERNEL
482 expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1)
490 * The load offset is different depending on the ABI. For simplicity
491 * just mask it out when doing the compare.
493 if ((op0 != 0x48000008) || ((op1 & 0xffff0000) != 0xe8410000))
499 expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1)
501 /* look for patched "NOP" on ppc64 with -mprofile-kernel */
502 if (op0 != PPC_INST_NOP)
509 __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
512 void *ip = (void *)rec->ip;
513 unsigned long entry, ptr, tramp;
514 struct module *mod = rec->arch.mod;
516 /* read where this goes */
517 if (probe_kernel_read(op, ip, sizeof(op)))
520 if (!expected_nop_sequence(ip, op[0], op[1])) {
521 pr_err("Unexpected call sequence at %p: %x %x\n",
526 /* If we never set up ftrace trampoline(s), then bail */
527 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
528 if (!mod->arch.tramp || !mod->arch.tramp_regs) {
530 if (!mod->arch.tramp) {
532 pr_err("No ftrace trampoline\n");
536 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
537 if (rec->flags & FTRACE_FL_REGS)
538 tramp = mod->arch.tramp_regs;
541 tramp = mod->arch.tramp;
543 if (module_trampoline_target(mod, tramp, &ptr)) {
544 pr_err("Failed to get trampoline target\n");
548 pr_devel("trampoline target %lx", ptr);
550 entry = ppc_global_function_entry((void *)addr);
551 /* This should match what was called */
553 pr_err("addr %lx does not match expected %lx\n", ptr, entry);
557 /* Ensure branch is within 24 bits */
558 if (!create_branch(ip, tramp, BRANCH_SET_LINK)) {
559 pr_err("Branch out of range\n");
563 if (patch_branch(ip, tramp, BRANCH_SET_LINK)) {
564 pr_err("REL24 out of range!\n");
571 #else /* !CONFIG_PPC64: */
573 __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
576 unsigned long ip = rec->ip;
578 /* read where this goes */
579 if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE))
582 /* It should be pointing to a nop */
583 if (op != PPC_INST_NOP) {
584 pr_err("Expected NOP but have %x\n", op);
588 /* If we never set up a trampoline to ftrace_caller, then bail */
589 if (!rec->arch.mod->arch.tramp) {
590 pr_err("No ftrace trampoline\n");
594 /* create the branch to the trampoline */
595 op = create_branch((unsigned int *)ip,
596 rec->arch.mod->arch.tramp, BRANCH_SET_LINK);
598 pr_err("REL24 out of range!\n");
602 pr_devel("write to %lx\n", rec->ip);
604 if (patch_instruction((unsigned int *)ip, op))
609 #endif /* CONFIG_PPC64 */
610 #endif /* CONFIG_MODULES */
612 static int __ftrace_make_call_kernel(struct dyn_ftrace *rec, unsigned long addr)
615 void *ip = (void *)rec->ip;
616 unsigned long tramp, entry, ptr;
618 /* Make sure we're being asked to patch branch to a known ftrace addr */
619 entry = ppc_global_function_entry((void *)ftrace_caller);
620 ptr = ppc_global_function_entry((void *)addr);
623 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
624 entry = ppc_global_function_entry((void *)ftrace_regs_caller);
627 pr_err("Unknown ftrace addr to patch: %ps\n", (void *)ptr);
629 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
634 /* Make sure we have a nop */
635 if (probe_kernel_read(&op, ip, sizeof(op))) {
636 pr_err("Unable to read ftrace location %p\n", ip);
640 if (op != PPC_INST_NOP) {
641 pr_err("Unexpected call sequence at %p: %x\n", ip, op);
645 tramp = find_ftrace_tramp((unsigned long)ip);
647 pr_err("No ftrace trampolines reachable from %ps\n", ip);
651 if (patch_branch(ip, tramp, BRANCH_SET_LINK)) {
652 pr_err("Error patching branch to ftrace tramp!\n");
659 int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
661 unsigned long ip = rec->ip;
662 unsigned int old, new;
665 * If the calling address is more that 24 bits away,
666 * then we had to use a trampoline to make the call.
667 * Otherwise just update the call site.
669 if (test_24bit_addr(ip, addr)) {
672 new = ftrace_call_replace(ip, addr, 1);
673 return ftrace_modify_code(ip, old, new);
674 } else if (core_kernel_text(ip))
675 return __ftrace_make_call_kernel(rec, addr);
677 #ifdef CONFIG_MODULES
679 * Out of range jumps are called from modules.
680 * Being that we are converting from nop, it had better
681 * already have a module defined.
683 if (!rec->arch.mod) {
684 pr_err("No module loaded\n");
688 return __ftrace_make_call(rec, addr);
690 /* We should not get here without modules */
692 #endif /* CONFIG_MODULES */
695 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
696 #ifdef CONFIG_MODULES
698 __ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
702 unsigned long ip = rec->ip;
703 unsigned long entry, ptr, tramp;
704 struct module *mod = rec->arch.mod;
706 /* If we never set up ftrace trampolines, then bail */
707 if (!mod->arch.tramp || !mod->arch.tramp_regs) {
708 pr_err("No ftrace trampoline\n");
712 /* read where this goes */
713 if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
714 pr_err("Fetching opcode failed.\n");
718 /* Make sure that that this is still a 24bit jump */
720 pr_err("Not expected bl: opcode is %x\n", op);
724 /* lets find where the pointer goes */
725 tramp = find_bl_target(ip, op);
726 entry = ppc_global_function_entry((void *)old_addr);
728 pr_devel("ip:%lx jumps to %lx", ip, tramp);
730 if (tramp != entry) {
731 /* old_addr is not within range, so we must have used a trampoline */
732 if (module_trampoline_target(mod, tramp, &ptr)) {
733 pr_err("Failed to get trampoline target\n");
737 pr_devel("trampoline target %lx", ptr);
739 /* This should match what was called */
741 pr_err("addr %lx does not match expected %lx\n", ptr, entry);
746 /* The new target may be within range */
747 if (test_24bit_addr(ip, addr)) {
749 if (patch_branch((unsigned int *)ip, addr, BRANCH_SET_LINK)) {
750 pr_err("REL24 out of range!\n");
757 if (rec->flags & FTRACE_FL_REGS)
758 tramp = mod->arch.tramp_regs;
760 tramp = mod->arch.tramp;
762 if (module_trampoline_target(mod, tramp, &ptr)) {
763 pr_err("Failed to get trampoline target\n");
767 pr_devel("trampoline target %lx", ptr);
769 entry = ppc_global_function_entry((void *)addr);
770 /* This should match what was called */
772 pr_err("addr %lx does not match expected %lx\n", ptr, entry);
776 /* Ensure branch is within 24 bits */
777 if (!create_branch((unsigned int *)ip, tramp, BRANCH_SET_LINK)) {
778 pr_err("Branch out of range\n");
782 if (patch_branch((unsigned int *)ip, tramp, BRANCH_SET_LINK)) {
783 pr_err("REL24 out of range!\n");
791 int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
794 unsigned long ip = rec->ip;
795 unsigned int old, new;
798 * If the calling address is more that 24 bits away,
799 * then we had to use a trampoline to make the call.
800 * Otherwise just update the call site.
802 if (test_24bit_addr(ip, addr) && test_24bit_addr(ip, old_addr)) {
804 old = ftrace_call_replace(ip, old_addr, 1);
805 new = ftrace_call_replace(ip, addr, 1);
806 return ftrace_modify_code(ip, old, new);
807 } else if (core_kernel_text(ip)) {
809 * We always patch out of range locations to go to the regs
810 * variant, so there is nothing to do here
815 #ifdef CONFIG_MODULES
817 * Out of range jumps are called from modules.
819 if (!rec->arch.mod) {
820 pr_err("No module loaded\n");
824 return __ftrace_modify_call(rec, old_addr, addr);
826 /* We should not get here without modules */
828 #endif /* CONFIG_MODULES */
832 int ftrace_update_ftrace_func(ftrace_func_t func)
834 unsigned long ip = (unsigned long)(&ftrace_call);
835 unsigned int old, new;
838 old = *(unsigned int *)&ftrace_call;
839 new = ftrace_call_replace(ip, (unsigned long)func, 1);
840 ret = ftrace_modify_code(ip, old, new);
842 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
843 /* Also update the regs callback function */
845 ip = (unsigned long)(&ftrace_regs_call);
846 old = *(unsigned int *)&ftrace_regs_call;
847 new = ftrace_call_replace(ip, (unsigned long)func, 1);
848 ret = ftrace_modify_code(ip, old, new);
856 * Use the default ftrace_modify_all_code, but without
859 void arch_ftrace_update_code(int command)
861 ftrace_modify_all_code(command);
865 #define PACATOC offsetof(struct paca_struct, kernel_toc)
867 extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[];
869 void ftrace_free_init_tramp(void)
873 for (i = 0; i < NUM_FTRACE_TRAMPS && ftrace_tramps[i]; i++)
874 if (ftrace_tramps[i] == (unsigned long)ftrace_tramp_init) {
875 ftrace_tramps[i] = 0;
880 int __init ftrace_dyn_arch_init(void)
883 unsigned int *tramp[] = { ftrace_tramp_text, ftrace_tramp_init };
885 0xe98d0000 | PACATOC, /* ld r12,PACATOC(r13) */
886 0x3d8c0000, /* addis r12,r12,<high> */
887 0x398c0000, /* addi r12,r12,<low> */
888 0x7d8903a6, /* mtctr r12 */
889 0x4e800420, /* bctr */
891 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
892 unsigned long addr = ppc_global_function_entry((void *)ftrace_regs_caller);
894 unsigned long addr = ppc_global_function_entry((void *)ftrace_caller);
896 long reladdr = addr - kernel_toc_addr();
898 if (reladdr > 0x7FFFFFFF || reladdr < -(0x80000000L)) {
899 pr_err("Address of %ps out of range of kernel_toc.\n",
904 for (i = 0; i < 2; i++) {
905 memcpy(tramp[i], stub_insns, sizeof(stub_insns));
906 tramp[i][1] |= PPC_HA(reladdr);
907 tramp[i][2] |= PPC_LO(reladdr);
908 add_ftrace_tramp((unsigned long)tramp[i]);
914 int __init ftrace_dyn_arch_init(void)
919 #endif /* CONFIG_DYNAMIC_FTRACE */
921 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
923 extern void ftrace_graph_call(void);
924 extern void ftrace_graph_stub(void);
926 int ftrace_enable_ftrace_graph_caller(void)
928 unsigned long ip = (unsigned long)(&ftrace_graph_call);
929 unsigned long addr = (unsigned long)(&ftrace_graph_caller);
930 unsigned long stub = (unsigned long)(&ftrace_graph_stub);
931 unsigned int old, new;
933 old = ftrace_call_replace(ip, stub, 0);
934 new = ftrace_call_replace(ip, addr, 0);
936 return ftrace_modify_code(ip, old, new);
939 int ftrace_disable_ftrace_graph_caller(void)
941 unsigned long ip = (unsigned long)(&ftrace_graph_call);
942 unsigned long addr = (unsigned long)(&ftrace_graph_caller);
943 unsigned long stub = (unsigned long)(&ftrace_graph_stub);
944 unsigned int old, new;
946 old = ftrace_call_replace(ip, addr, 0);
947 new = ftrace_call_replace(ip, stub, 0);
949 return ftrace_modify_code(ip, old, new);
953 * Hook the return address and push it in the stack of return addrs
954 * in current thread info. Return the address we want to divert to.
956 unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip,
959 unsigned long return_hooker;
961 if (unlikely(ftrace_graph_is_dead()))
964 if (unlikely(atomic_read(¤t->tracing_graph_pause)))
967 return_hooker = ppc_function_entry(return_to_handler);
969 if (!function_graph_enter(parent, ip, 0, (unsigned long *)sp))
970 parent = return_hooker;
974 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
976 #ifdef PPC64_ELF_ABI_v1
977 char *arch_ftrace_match_adjust(char *str, const char *search)
979 if (str[0] == '.' && search[0] != '.')
984 #endif /* PPC64_ELF_ABI_v1 */