Lines Matching +full:bl +full:- +full:code +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0-only
15 #include <asm/debug-monitors.h>
18 #include <asm/text-patching.h>
23 int offset; member
29 .offset = offsetof(struct __arch_ftrace_regs, field), \
55 if (!strcmp(roff->name, name)) in ftrace_regs_query_register_offset()
56 return roff->offset; in ftrace_regs_query_register_offset()
59 return -EINVAL; in ftrace_regs_query_register_offset()
73 * When using patchable-function-entry without pre-function NOPS, addr in ftrace_call_adjust()
79 * addr+04: NOP // To be patched to BL <caller> in ftrace_call_adjust()
83 * addr-04: BTI C in ftrace_call_adjust()
85 * addr+04: NOP // To be patched to BL <caller> in ftrace_call_adjust()
88 * to `BL <caller>`, which is at `addr + 4` bytes in either case. in ftrace_call_adjust()
95 * When using patchable-function-entry with pre-function NOPs, addr is in ftrace_call_adjust()
96 * the address of the first pre-function NOP. in ftrace_call_adjust()
98 * Starting from an 8-byte aligned base, the compiler has either in ftrace_call_adjust()
104 * addr+12: NOP // To be patched to BL <caller> in ftrace_call_adjust()
112 * addr+16: NOP // To be patched to BL <caller> in ftrace_call_adjust()
115 * to `BL <caller>`, which is at either addr+12 or addr+16 depending on in ftrace_call_adjust()
120 WARN_RATELIMIT(1, "Misaligned patch-site %pS\n", in ftrace_call_adjust()
135 WARN_RATELIMIT(1, "unexpected insn in patch-site %pS: 0x%08x\n", in ftrace_call_adjust()
152 * When using patchable-function-entry without pre-function NOPS, ftrace in arch_ftrace_get_symaddr()
158 * func+04: NOP // To be patched to BL <caller> in arch_ftrace_get_symaddr()
162 * func-04: BTI C in arch_ftrace_get_symaddr()
164 * func+04: NOP // To be patched to BL <caller> in arch_ftrace_get_symaddr()
166 * The fentry_ip is the address of `BL <caller>` which is at `func + 4` in arch_ftrace_get_symaddr()
170 return fentry_ip - AARCH64_INSN_SIZE; in arch_ftrace_get_symaddr()
173 * When using patchable-function-entry with pre-function NOPs, BTI is in arch_ftrace_get_symaddr()
177 * func+04: NOP // To be patched to BL <caller> in arch_ftrace_get_symaddr()
183 * func+08: NOP // To be patched to BL <caller> in arch_ftrace_get_symaddr()
185 * The fentry_ip is the address of `BL <caller>` which is at either in arch_ftrace_get_symaddr()
191 return fentry_ip - AARCH64_INSN_SIZE; in arch_ftrace_get_symaddr()
197 if (get_kernel_nofault(insn, (u32 *)(fentry_ip - AARCH64_INSN_SIZE * 2))) in arch_ftrace_get_symaddr()
200 insn = *(u32 *)(fentry_ip - AARCH64_INSN_SIZE * 2); in arch_ftrace_get_symaddr()
204 return fentry_ip - AARCH64_INSN_SIZE * 2; in arch_ftrace_get_symaddr()
206 return fentry_ip - AARCH64_INSN_SIZE; in arch_ftrace_get_symaddr()
222 * Carefully read and modify the code with aarch64_insn_*() which uses in ftrace_modify_code()
228 return -EFAULT; in ftrace_modify_code()
231 return -EINVAL; in ftrace_modify_code()
234 return -EPERM; in ftrace_modify_code()
264 struct plt_entry *plt = mod->arch.ftrace_trampolines; in get_ftrace_plt()
274 long offset = (long)addr - (long)pc; in reachable_by_bl() local
276 return offset >= -SZ_128M && offset < SZ_128M; in reachable_by_bl()
282 * Due to the limited range of 'BL' instructions, modules may be placed too far
292 unsigned long pc = rec->ip; in ftrace_find_callable_addr()
298 * through ops->direct_call. in ftrace_find_callable_addr()
304 * When the target is within range of the 'BL' instruction, use 'addr' in ftrace_find_callable_addr()
305 * as-is and branch to that directly. in ftrace_find_callable_addr()
311 * When the target is outside of the range of a 'BL' instruction, we in ftrace_find_callable_addr()
313 * only when module PLT support is built-in. in ftrace_find_callable_addr()
320 * dealing with an out-of-range condition, we can assume it in ftrace_find_callable_addr()
325 * retains its validity throughout the remainder of this code. in ftrace_find_callable_addr()
351 if (rec->flags & FTRACE_FL_CALL_OPS_EN) { in arm64_rec_get_ops()
365 unsigned long literal = ALIGN_DOWN(rec->ip - 12, 8); in ftrace_rec_set_ops()
389 unsigned long pc = rec->ip; in ftrace_make_call()
398 return -EINVAL; in ftrace_make_call()
410 unsigned long pc = rec->ip; in ftrace_modify_call()
419 return -EINVAL; in ftrace_modify_call()
421 return -EINVAL; in ftrace_modify_call()
434 * All instrumented functions follow the AAPCS, so x0-x8 and x19-x30 are live,
435 * and x9-x18 are free for our use.
437 * At runtime we want to be able to swing a single NOP <-> BL to enable or
438 * disable the ftrace call. The BL requires us to save the original LR value,
443 * +----------+------------+------------+
445 * | NOP | NOP | BL <entry> |
451 * Note: ftrace_process_locs() has pre-adjusted rec->ip to be the address of
452 * the BL.
456 unsigned long pc = rec->ip - AARCH64_INSN_SIZE; in ftrace_init_nop()
478 unsigned long pc = rec->ip; in ftrace_make_nop()
501 return -EINVAL; in ftrace_make_nop()
527 if (unlikely(atomic_read(¤t->tracing_graph_pause))) in prepare_ftrace_return()
548 unsigned long frame_pointer = arch_ftrace_regs(fregs)->fp; in ftrace_graph_func()
549 unsigned long *parent = &arch_ftrace_regs(fregs)->lr; in ftrace_graph_func()
552 if (unlikely(atomic_read(¤t->tracing_graph_pause))) in ftrace_graph_func()