]> git.ipfire.org Git - thirdparty/linux.git/commit
riscv: ftrace: Add DYNAMIC_FTRACE_WITH_DIRECT_CALLS support
authorSong Shuai <suagrfillet@gmail.com>
Thu, 30 Nov 2023 12:15:30 +0000 (13:15 +0100)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 18 Jan 2024 02:17:09 +0000 (18:17 -0800)
commit196c79f19a92764d45005599f35338cf0a9eafbb
treed29441488a5f8f2db428abf1cb5deb6752d367ad
parent35e61e8827ee8ea09e6093ab4d8ba45efd537e36
riscv: ftrace: Add DYNAMIC_FTRACE_WITH_DIRECT_CALLS support

Select the DYNAMIC_FTRACE_WITH_DIRECT_CALLS to provide the
register_ftrace_direct[_multi] interfaces allowing users to register
the customed trampoline (direct_caller) as the mcount for one or more
target functions. And modify_ftrace_direct[_multi] are also provided
for modifying direct_caller.

To make the direct_caller and the other ftrace hooks (e.g.
function/fgraph tracer, k[ret]probes) co-exist, a temporary register
is nominated to store the address of direct_caller in
ftrace_regs_caller. After the setting of the address direct_caller by
direct_ops->func and the RESTORE_REGS in ftrace_regs_caller,
direct_caller will be jumped to by the `jr` inst.

Add DYNAMIC_FTRACE_WITH_DIRECT_CALLS support for RISC-V.

Signed-off-by: Song Shuai <suagrfillet@gmail.com>
Tested-by: Guo Ren <guoren@kernel.org>
Signed-off-by: Guo Ren <guoren@kernel.org>
Acked-by: Björn Töpel <bjorn@rivosinc.com>
Link: https://lore.kernel.org/r/20231130121531.1178502-4-bjorn@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/Kconfig
arch/riscv/include/asm/ftrace.h
arch/riscv/kernel/mcount-dyn.S