On Mon, Aug 15, 2022 at 12:57:39PM +0200, Jiri Olsa wrote: > On Mon, Aug 15, 2022 at 12:18:38PM +0200, Peter Zijlstra wrote: > > On Thu, Aug 11, 2022 at 11:15:23AM +0200, Jiri Olsa wrote: > > > Using function address given at the generation time as the trampoline > > > ip argument. This way we get directly the function address that we > > > need, so we don't need to: > > > - read the ip from the stack > > > - subtract X86_PATCH_SIZE > > > - subtract ENDBR_INSN_SIZE if CONFIG_X86_KERNEL_IBT is enabled > > > which is not even implemented yet ;-) > > > > Can you please tell me what all this does and why? > > > > arch_prepare_bpf_trampoline prepares bpf trampoline for given function > specified by 'func_addr' argument The bpf trampoline is what's used for ftrace direct call, no? > the changed code is storing/preparing caller's 'ip' address on the > trampoline's stack so the get_func_ip helper can use it I've no idea what get_func_ip() helper is... > currently the trampoline code gets the caller's ip address by reading > caller's return address from stack and subtracting X86_PATCH_SIZE from > it > > the change uses 'func_addr' as caller's 'ip' address when trampoline is > generated .. this way we don't need to retrieve the return address from > stack and care about endbr instruction if IBT is enabled Ok, I *think* I sorta understand that.