Skip to content

Commit f8b4d36

Browse files
ftrace: Make DIRECT_CALLS work WITH_ARGS and !WITH_REGS
JIRA: https://issues.redhat.com/browse/RHEL-101598 commit 60c8971 Author: Florent Revest <[email protected]> Date: Tue Mar 21 15:04:23 2023 +0100 ftrace: Make DIRECT_CALLS work WITH_ARGS and !WITH_REGS Direct called trampolines can be called in two ways: - either from the ftrace callsite. In this case, they do not access any struct ftrace_regs nor pt_regs - Or, if a ftrace ops is also attached, from the end of a ftrace trampoline. In this case, the call_direct_funcs ops is in charge of setting the direct call trampoline's address in a struct ftrace_regs Since: commit 9705bc7 ("ftrace: pass fregs to arch_ftrace_set_direct_caller()") The later case no longer requires a full pt_regs. It only needs a struct ftrace_regs so DIRECT_CALLS can work with both WITH_ARGS or WITH_REGS. With architectures like arm64 already abandoning WITH_REGS in favor of WITH_ARGS, it's important to have DIRECT_CALLS work WITH_ARGS only. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Florent Revest <[email protected]> Co-developed-by: Mark Rutland <[email protected]> Signed-off-by: Mark Rutland <[email protected]> Acked-by: Jiri Olsa <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Jerome Marchand <[email protected]>
1 parent d182985 commit f8b4d36

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

include/linux/ftrace.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ enum {
237237
FTRACE_OPS_FL_DIRECT = BIT(17),
238238
};
239239

240+
#ifndef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
241+
#define FTRACE_OPS_FL_SAVE_ARGS FTRACE_OPS_FL_SAVE_REGS
242+
#else
243+
#define FTRACE_OPS_FL_SAVE_ARGS 0
244+
#endif
245+
240246
/*
241247
* FTRACE_OPS_CMD_* commands allow the ftrace core logic to request changes
242248
* to a ftrace_ops. Note, the requests may fail.

kernel/trace/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ config DYNAMIC_FTRACE_WITH_REGS
257257

258258
config DYNAMIC_FTRACE_WITH_DIRECT_CALLS
259259
def_bool y
260-
depends on DYNAMIC_FTRACE_WITH_REGS
260+
depends on DYNAMIC_FTRACE_WITH_REGS || DYNAMIC_FTRACE_WITH_ARGS
261261
depends on HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
262262

263263
config DYNAMIC_FTRACE_WITH_CALL_OPS

kernel/trace/ftrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5275,7 +5275,7 @@ static LIST_HEAD(ftrace_direct_funcs);
52755275

52765276
static int register_ftrace_function_nolock(struct ftrace_ops *ops);
52775277

5278-
#define MULTI_FLAGS (FTRACE_OPS_FL_DIRECT | FTRACE_OPS_FL_SAVE_REGS)
5278+
#define MULTI_FLAGS (FTRACE_OPS_FL_DIRECT | FTRACE_OPS_FL_SAVE_ARGS)
52795279

52805280
static int check_direct_multi(struct ftrace_ops *ops)
52815281
{

0 commit comments

Comments
 (0)