]> git.ipfire.org Git - thirdparty/linux.git/commit
bpf: implement "jmp" mode for trampoline
authorMenglong Dong <menglong8.dong@gmail.com>
Tue, 18 Nov 2025 12:36:34 +0000 (20:36 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 24 Nov 2025 17:47:04 +0000 (09:47 -0800)
commit402e44b31e9d8cb082d85870ee0d0ad54f97c311
treebcbde53baf8efb5649e1d71a225c3dca036fc05e
parentae4a3160d19cd16b874737ebc1798c7bc2fe3c9e
bpf: implement "jmp" mode for trampoline

Implement the "jmp" mode for the bpf trampoline. For the ftrace_managed
case, we need only to set the FTRACE_OPS_FL_JMP on the tr->fops if "jmp"
is needed.

For the bpf poke case, we will check the origin poke type with the
"origin_flags", and current poke type with "tr->flags". The function
bpf_trampoline_update_fentry() is introduced to do the job.

The "jmp" mode will only be enabled with CONFIG_DYNAMIC_FTRACE_WITH_JMP
enabled and BPF_TRAMP_F_SHARE_IPMODIFY is not set. With
BPF_TRAMP_F_SHARE_IPMODIFY, we need to get the origin call ip from the
stack, so we can't use the "jmp" mode.

Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/20251118123639.688444-7-dongml2@chinatelecom.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/trampoline.c