Skip to content

Commit 60c8971

Browse files
FlorentRevestrostedt
authored andcommitted
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]>
1 parent dbaccb6 commit 60c8971

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
@@ -241,6 +241,12 @@ enum {
241241
FTRACE_OPS_FL_DIRECT = BIT(17),
242242
};
243243

244+
#ifndef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
245+
#define FTRACE_OPS_FL_SAVE_ARGS FTRACE_OPS_FL_SAVE_REGS
246+
#else
247+
#define FTRACE_OPS_FL_SAVE_ARGS 0
248+
#endif
249+
244250
/*
245251
* FTRACE_OPS_CMD_* commands allow the ftrace core logic to request changes
246252
* 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
@@ -5288,7 +5288,7 @@ static LIST_HEAD(ftrace_direct_funcs);
52885288

52895289
static int register_ftrace_function_nolock(struct ftrace_ops *ops);
52905290

5291-
#define MULTI_FLAGS (FTRACE_OPS_FL_DIRECT | FTRACE_OPS_FL_SAVE_REGS)
5291+
#define MULTI_FLAGS (FTRACE_OPS_FL_DIRECT | FTRACE_OPS_FL_SAVE_ARGS)
52925292

52935293
static int check_direct_multi(struct ftrace_ops *ops)
52945294
{

0 commit comments

Comments
 (0)