]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
x86/ftrace: Implement DYNAMIC_FTRACE_WITH_JMP
authorMenglong Dong <menglong8.dong@gmail.com>
Tue, 18 Nov 2025 12:36:30 +0000 (20:36 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 24 Nov 2025 17:46:37 +0000 (09:46 -0800)
commit0c3772a8db1f697c22dd6caef1fe938fbb0e0a5b
treebf2436f0211c8ca443112a9c00facd389d6a6ec6
parent25e4e3565d45f567f78089f38822fa64abee5230
x86/ftrace: Implement DYNAMIC_FTRACE_WITH_JMP

Implement the DYNAMIC_FTRACE_WITH_JMP for x86_64. In ftrace_call_replace,
we will use JMP32_INSN_OPCODE instead of CALL_INSN_OPCODE if the address
should use "jmp".

Meanwhile, adjust the direct call in the ftrace_regs_caller. The RSB is
balanced in the "jmp" mode. Take the function "foo" for example:

 original_caller:
 call foo -> foo:
         call fentry -> fentry:
                 [do ftrace callbacks ]
                 move tramp_addr to stack
                 RET -> tramp_addr
                         tramp_addr:
                         [..]
                         call foo_body -> foo_body:
                                 [..]
                                 RET -> back to tramp_addr
                         [..]
                         RET -> back to original_caller

Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/20251118123639.688444-3-dongml2@chinatelecom.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/x86/Kconfig
arch/x86/kernel/ftrace.c
arch/x86/kernel/ftrace_64.S