Lines Matching +full:no +full:- +full:pc +full:- +full:write

1 // SPDX-License-Identifier: GPL-2.0-only
15 #include <asm/debug-monitors.h>
25 static int ftrace_modify_code(unsigned long pc, u32 old, u32 new, in ftrace_modify_code() argument
33 * could cause us to read or write to someplace that could cause harm. in ftrace_modify_code()
39 if (aarch64_insn_read((void *)pc, &replaced)) in ftrace_modify_code()
40 return -EFAULT; in ftrace_modify_code()
43 return -EINVAL; in ftrace_modify_code()
45 if (aarch64_insn_patch_text_nosync((void *)pc, new)) in ftrace_modify_code()
46 return -EPERM; in ftrace_modify_code()
56 unsigned long pc; in ftrace_update_ftrace_func() local
59 pc = (unsigned long)ftrace_call; in ftrace_update_ftrace_func()
60 new = aarch64_insn_gen_branch_imm(pc, (unsigned long)func, in ftrace_update_ftrace_func()
63 return ftrace_modify_code(pc, 0, new, false); in ftrace_update_ftrace_func()
69 struct plt_entry *plt = mod->arch.ftrace_trampolines; in get_ftrace_plt()
93 unsigned long pc = rec->ip; in ftrace_find_callable_addr() local
94 long offset = (long)*addr - (long)pc; in ftrace_find_callable_addr()
99 * as-is and branch to that directly. in ftrace_find_callable_addr()
101 if (offset >= -SZ_128M && offset < SZ_128M) in ftrace_find_callable_addr()
107 * only when module PLT support is built-in. in ftrace_find_callable_addr()
114 * dealing with an out-of-range condition, we can assume it in ftrace_find_callable_addr()
123 mod = __module_text_address(pc); in ftrace_find_callable_addr()
132 pr_err("ftrace: no module PLT for %ps\n", (void *)*addr); in ftrace_find_callable_addr()
145 unsigned long pc = rec->ip; in ftrace_make_call() local
149 return -EINVAL; in ftrace_make_call()
152 new = aarch64_insn_gen_branch_imm(pc, addr, AARCH64_INSN_BRANCH_LINK); in ftrace_make_call()
154 return ftrace_modify_code(pc, old, new, true); in ftrace_make_call()
161 unsigned long pc = rec->ip; in ftrace_modify_call() local
165 return -EINVAL; in ftrace_modify_call()
167 return -EINVAL; in ftrace_modify_call()
169 old = aarch64_insn_gen_branch_imm(pc, old_addr, in ftrace_modify_call()
171 new = aarch64_insn_gen_branch_imm(pc, addr, AARCH64_INSN_BRANCH_LINK); in ftrace_modify_call()
173 return ftrace_modify_code(pc, old, new, true); in ftrace_modify_call()
178 * All instrumented functions follow the AAPCS, so x0-x8 and x19-x30 are live,
179 * and x9-x18 are free for our use.
181 * At runtime we want to be able to swing a single NOP <-> BL to enable or
187 * +----------+------------+------------+
195 * Note: ftrace_process_locs() has pre-adjusted rec->ip to be the address of
200 unsigned long pc = rec->ip - AARCH64_INSN_SIZE; in ftrace_init_nop() local
207 return ftrace_modify_code(pc, old, new, true); in ftrace_init_nop()
217 unsigned long pc = rec->ip; in ftrace_make_nop() local
233 return aarch64_insn_patch_text_nosync((void *)pc, new); in ftrace_make_nop()
237 return -EINVAL; in ftrace_make_nop()
239 old = aarch64_insn_gen_branch_imm(pc, addr, AARCH64_INSN_BRANCH_LINK); in ftrace_make_nop()
241 return ftrace_modify_code(pc, old, new, true); in ftrace_make_nop()
264 if (unlikely(atomic_read(&current->tracing_graph_pause))) in prepare_ftrace_return()
269 * No protection against faulting at *parent, which may be seen in prepare_ftrace_return()
288 * and arch_ftrace_get_regs(fregs) will always give a non-NULL pt_regs in ftrace_graph_func()
303 unsigned long pc = (unsigned long)&ftrace_graph_call; in ftrace_modify_graph_caller() local
306 branch = aarch64_insn_gen_branch_imm(pc, in ftrace_modify_graph_caller()
312 return ftrace_modify_code(pc, nop, branch, true); in ftrace_modify_graph_caller()
314 return ftrace_modify_code(pc, branch, nop, true); in ftrace_modify_graph_caller()