[RFC PATCH v2 28/31] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Allow fprobe events to be enabled with CONFIG_DYNAMIC_FTRACE_WITH_ARGS. With this change, fprobe events mostly use ftrace_regs instead of pt_regs. Note that if the arch doesn't enable HAVE_PT_REGS_COMPAT_FTRACE_REGS, fprobe events will not be able to be used

[RFC PATCH v2 27/31] tracing/fprobe: Remove nr_maxactive from fprobe

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Remove depercated fprobe::nr_maxactive. This involves fprobe events to rejects the maxactive number. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Newly added. --- include/linux/fprobe.h |2 -- kernel/trace/trace_fprobe.c | 44

[RFC PATCH v2 26/31] fprobe: Rewrite fprobe on function-graph tracer

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Rewrite fprobe implementation on function-graph tracer. Major API changes are: - 'nr_maxactive' field is deprecated. - This depends on CONFIG_DYNAMIC_FTRACE_WITH_ARGS or !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS, and CONFIG_HAVE_FUNCTION_GRAPH

[RFC PATCH v2 25/31] tracing: Add ftrace_fill_perf_regs() for perf event

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_fill_perf_regs() which should be compatible with the perf_fetch_caller_regs(). In other words, the pt_regs returned from the ftrace_fill_perf_regs() must satisfy 'user_mode(regs) == false' and can be used for stack tracing. Signed-off-

[RFC PATCH v2 24/31] tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_partial_regs() which converts the ftrace_regs to pt_regs. If the architecture defines its own ftrace_regs, this copies partial registers to pt_regs and returns it. If not, ftrace_regs is the same as pt_regs and ftrace_partial_regs() will return

[RFC PATCH v2 23/31] fprobe: Use ftrace_regs in fprobe exit handler

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Change the fprobe exit handler to use ftrace_regs structure instead of pt_regs. This also introduce HAVE_PT_REGS_TO_FTRACE_REGS_CAST which means the ftrace_regs's memory layout is equal to the pt_regs so that those are able to cast. Fprobe introduces

[RFC PATCH v2 22/31] fprobe: Use ftrace_regs in fprobe entry handler

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) This allows fprobes to be available with CONFIG_DYNAMIC_FTRACE_WITH_ARGS instead of CONFIG_DYNAMIC_FTRACE_WITH_REGS, then we can enable fprobe on arm64. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Florent Revest --- Changes from previous series: NOTHING

[RFC PATCH v2 21/31] x86/ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Support HAVE_FUNCTION_GRAPH_FREGS on x86-64, which saves ftrace_regs on the stack in ftrace_graph return trampoline so that the callbacks can access registers via ftrace_regs APIs. Note that this only recovers 'rax' and 'rdx' registers because

[RFC PATCH v2 20/31] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a new return handler to fgraph_ops as 'retregfunc' which takes parent_ip and ftrace_regs instead of ftrace_graph_ret. This handler is available only if the arch support CONFIG_HAVE_FUNCTION_GRAPH_FREGS. Note that the 'retfunc' and &#

[RFC PATCH v2 19/31] function_graph: Add a new entry handler with parent_ip and ftrace_regs

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a new entry handler to fgraph_ops as 'entryregfunc' which takes parent_ip and ftrace_regs. Note that the 'entryfunc' and 'entryregfunc' are mutual exclusive. You can set only one of them. Signed-off-by: Masami Hiramatsu (G

[RFC PATCH v2 18/31] function_graph: Add selftest for passing local variables

2023-11-08 Thread Masami Hiramatsu (Google)
From: Steven Rostedt (VMware) Add boot up selftest that passes variables from a function entry to a function exit, and make sure that they do get passed around. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Add reserved size test

[RFC PATCH v2 17/31] function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data()

2023-11-08 Thread Masami Hiramatsu (Google)
x27;s shadow ret_stack and this then can be retrieved by fgraph_retrieve_data() called by the corresponding retfunc(). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Retrieve the reserved size by fgraph_retrieve_data(). - Expand the ma

[RFC PATCH v2 16/31] function_graph: Move graph notrace bit to shadow stack global var

2023-11-08 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Make description lines shorter than 76 chars. --- include/linux/trace_recursion.h |7 --- kernel/trace/trace.h |9 + kernel/trace/trace_functions_graph.c | 10 ++ 3 files chan

[RFC PATCH v2 15/31] function_graph: Move graph depth stored data to shadow stack global var

2023-11-08 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/trace_recursion.h | 29 - kernel/trace/trace.h| 34 -- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/linux/trace_recursion.h b/incl

[RFC PATCH v2 14/31] function_graph: Move set_graph_function tests to shadow stack global var

2023-11-08 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/trace_recursion.h |5 + kernel/trace/trace.h | 32 +--- kernel/trace/trace_functions_graph.c |6 +++--- kernel/trace/trace_irqsoff.c |4 ++-- kernel/tr

[RFC PATCH v2 13/31] function_graph: Add "task variables" per task for fgraph_ops

2023-11-08 Thread Masami Hiramatsu (Google)
atures on a per task basis having a way to maintain state for each task. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Make description lines shorter than 76 chars. --- include/linux/ftrace.h |2 + kernel/trace/f

[RFC PATCH v2 12/31] function_graph: Have the instances use their own ftrace_ops for filtering

2023-11-08 Thread Masami Hiramatsu (Google)
From: Steven Rostedt (VMware) Allow for instances to have their own ftrace_ops part of the fgraph_ops that makes the funtion_graph tracer filter on the set_ftrace_filter file of the instance and not the top instance. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu

[RFC PATCH v2 11/31] ftrace: Allow ftrace startup flags exist without dynamic ftrace

2023-11-08 Thread Masami Hiramatsu (Google)
compile because dynamic ftrace is disabled. This change is needed to move some of the logic of what is passed to ftrace_startup() out of the parameters of ftrace_startup(). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h | 18

[RFC PATCH v2 10/31] ftrace: Allow function_graph tracer to be enabled in instances

2023-11-08 Thread Masami Hiramatsu (Google)
: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Fix to remove set_graph_array() completely. --- include/linux/ftrace.h |1 + kernel/trace/ftrace.c|1 + kernel/trace/trace.h | 13 ++- kernel

[RFC PATCH v2 09/31] ftrace/function_graph: Pass fgraph_ops to function graph callbacks

2023-11-08 Thread Masami Hiramatsu (Google)
to the function graph tracer. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - cleanup to set argument name on function prototype. --- include/linux/ftrace.h | 10 +++--- kernel/trace/fgraph.c| 17

[RFC PATCH v2 08/31] function_graph: Remove logic around ftrace_graph_entry and return

2023-11-08 Thread Masami Hiramatsu (Google)
function_graph tracer. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Fix typo and make lines shorter than 76 chars in the description. - Remove unneeded return from return_run() function. --- kernel/trace/fgraph.c | 71

[RFC PATCH v2 07/31] function_graph: Allow multiple users to attach to function graph

2023-11-08 Thread Masami Hiramatsu (Google)
s when both are called is not completely handled yet, but that shouldn't be too hard to manage. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Check return value of the ftrace_pop_return_trace() instead of 'ret' since '

[RFC PATCH v2 06/31] function_graph: Add an array structure that will allow multiple callbacks

2023-11-08 Thread Masami Hiramatsu (Google)
n the shadow stack. We need to only save the index, because this will allow the fgraph_ops to be freed before the function returns (which may happen if the function call schedule for a long time). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - R

[RFC PATCH v2 05/31] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long

2023-11-08 Thread Masami Hiramatsu (Google)
dt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fgraph.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 30edeb6d4aa9..837daf929d2a 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trac

[RFC PATCH v2 04/31] function_graph: Convert ret_stack to a series of longs

2023-11-08 Thread Masami Hiramatsu (Google)
the return side of the functions. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/sched.h |2 - kernel/trace/fgraph.c | 124 - 2 files changed, 71 insertions(+), 55 deletions(-) diff --git a

[RFC PATCH v2 03/31] seq_buf: Export seq_buf_puts()

2023-11-08 Thread Masami Hiramatsu (Google)
: Steven Rostedt (Google) Signed-off-by: Masami Hiramatsu (Google) --- lib/seq_buf.c |1 + 1 file changed, 1 insertion(+) diff --git a/lib/seq_buf.c b/lib/seq_buf.c index 45c450f423fa..46a1b00c3815 100644 --- a/lib/seq_buf.c +++ b/lib/seq_buf.c @@ -189,6 +189,7 @@ int seq_buf_puts(struct

[RFC PATCH v2 02/31] x86: tracing: Add ftrace_regs definition in the header

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_regs definition for x86_64 in the ftrace header to clarify what register will be accessible from ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Newly added. --- arch/x86/include/asm/ftrace.h |6 ++ 1 file

[RFC PATCH v2 01/31] tracing: Add a comment about ftrace_regs definition

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) To clarify what will be expected on ftrace_regs, add a comment to the architecture independent definition of the ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - newly added. --- include/linux/ftrace.h | 25

[RFC PATCH v2 00/31] tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph

2023-11-08 Thread Masami Hiramatsu (Google)
sers. - Patch [31/31] is a documentation update. This series can be applied against the probes-fixes-v6.6-rc7 on linux-trace tree. This series can also be found below branch. https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git/log/?h=topic/fprobe-on-fgraph Thank you, --

[PATCH v2] tracing: fprobe-event: Fix to check tracepoint event and return

2023-11-08 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Fix to check the tracepoint event is not valid with $retval. The commit 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval") introduced automatic return probe conversion with $retval. But since tracepoint event does not supp

[RFC PATCH 32/32] Documentation: probes: Update fprobe on function-graph tracer

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Update fprobe documentation for the new fprobe on function-graph tracer. This includes some bahvior changes and pt_regs to ftrace_regs interface change. Signed-off-by: Masami Hiramatsu (Google) --- Documentation/trace/fprobe.rst | 42

[RFC PATCH 31/32] bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Enable kprobe_multi feature if CONFIG_FPROBE is enabled. The pt_regs is converted from ftrace_regs by ftrace_partial_regs(), thus some registers may always returns 0. But it should be enough for function entry (access arguments) and exit (access return value

[RFC PATCH 30/32] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Allow fprobe events to be enabled with CONFIG_DYNAMIC_FTRACE_WITH_ARGS. With this change, fprobe events mostly use ftrace_regs instead of pt_regs. Note that if the arch doesn't enable HAVE_PT_REGS_COMPAT_FTRACE_REGS, fprobe events will not be able to be used

[RFC PATCH 29/32] fprobe: Rewrite fprobe on function-graph tracer

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Rewrite fprobe implementation on function-graph tracer. Major API changes are: - 'nr_maxactive' field is deprecated. - This depends on CONFIG_DYNAMIC_FTRACE_WITH_ARGS or !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS, and CONFIG_HAVE_FUNCTION_GRAPH

[RFC PATCH 28/32] tracing: Add ftrace_fill_perf_regs() for perf event

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_fill_perf_regs() which should be compatible with the perf_fetch_caller_regs(). In other words, the pt_regs returned from the ftrace_fill_perf_regs() must satisfy 'user_mode(regs) == false' and can be used for stack tracing. Signed-off-

[RFC PATCH 27/32] tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_partial_regs() which converts the ftrace_regs to pt_regs. If the architecture defines its own ftrace_regs, this copies partial registers to pt_regs and returns it. If not, ftrace_regs is the same as pt_regs and ftrace_partial_regs() will return

[RFC PATCH 26/32] fprobe: Use ftrace_regs in fprobe exit handler

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Change the fprobe exit handler to use ftrace_regs structure instead of pt_regs. This also introduce HAVE_PT_REGS_TO_FTRACE_REGS_CAST which means the ftrace_regs's memory layout is equal to the pt_regs so that those are able to cast. Fprobe introduces

[RFC PATCH 25/32] fprobe: Use ftrace_regs in fprobe entry handler

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) This allows fprobes to be available with CONFIG_DYNAMIC_FTRACE_WITH_ARGS instead of CONFIG_DYNAMIC_FTRACE_WITH_REGS, then we can enable fprobe on arm64. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Florent Revest --- Changes from previous series: NOTHING

[RFC PATCH 24/32] x86/ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Support HAVE_FUNCTION_GRAPH_FREGS on x86-64, which saves ftrace_regs on the stack in ftrace_graph return trampoline so that the callbacks can access registers via ftrace_regs APIs. Note that this only recovers 'rax' and 'rdx' registers because

[RFC PATCH 23/32] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a new return handler to fgraph_ops as 'retregfunc' which takes parent_ip and ftrace_regs instead of ftrace_graph_ret. This handler is available only if the arch support CONFIG_HAVE_FUNCTION_GRAPH_FREGS. Note that the 'retfunc' and &#

[RFC PATCH 22/32] function_graph: Add a new entry handler with parent_ip and ftrace_regs

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a new entry handler to fgraph_ops as 'entryregfunc' which takes parent_ip and ftrace_regs. Note that the 'entryfunc' and 'entryregfunc' are mutual exclusive. You can set only one of them. Signed-off-by: Masami Hiramatsu (G

[RFC PATCH 21/32] function_graph: Expand the max reserved data size

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Expand the maximum reserved data size to 32 from 4. On 64bit system, this will allow reserving 256 bytes on the ret_stack in maximum but that may not happen. Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fgraph.c |4 ++-- 1 file changed, 2

[RFC PATCH 20/32] function_graph: Pass the size of reserved data when retrieving it

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Make the fgraph_retrieve_data() returns the reverved data size via size_byte parameter. Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h|2 +- kernel/trace/fgraph.c |5 - kernel/trace/trace_selftest.c | 10

[RFC PATCH 19/32] function_graph: Fix to check the return value of ftrace_pop_return_trace()

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Fix to check the return value ('ret_stack') of ftrace_pop_return_trace() instead of passed storage ('ret') because ret_stack becomes NULL in error case. Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fgraph.c |2 +- 1 file

[RFC PATCH 18/32] function_graph: Fix to initalize ftrace_ops for fgraph with ftrace_graph_func

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Fix to initialize the ftrace_ops of fgraph_ops with ftrace_graph_func instead of ftrace_stub. Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fgraph.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/fgraph.c b

[RFC PATCH 17/32] function_graph: Fix to update curr_ret_stack with ARRAY entry size

2023-11-05 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) __ftrace_return_to_handler() missed to update the curr_ret_stack when it gets a FGRAPH_TYPE_ARRAY. Since that type entry will follows some data words, it must update curr_ret_stack by entry size value (__get_index(val)) instead of 1. Signed-off-by: Masami

[RFC PATCH 16/32] function_graph: Add selftest for passing local variables

2023-11-05 Thread Masami Hiramatsu (Google)
From: Steven Rostedt (VMware) Add boot up selftest that passes variables from a function entry to a function exit, and make sure that they do get passed around. Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/trace_selftest.c | 161 + 1 file cha

[RFC PATCH 15/32] function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data()

2023-11-05 Thread Masami Hiramatsu (Google)
x27;s shadow ret_stack and this then can be retrived by fgraph_retrieve_data() called by the corresponding retfunc(). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h |3 + kernel/trace/fgraph.c |

[RFC PATCH 14/32] function_graph: Move graph notrace bit to shadow stack global var

2023-11-05 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/trace_recursion.h |7 --- kernel/trace/trace.h |9 + kernel/trace/trace_functions_graph.c | 10 ++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/li

[RFC PATCH 13/32] function_graph: Move graph depth stored data to shadow stack global var

2023-11-05 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/trace_recursion.h | 29 - kernel/trace/trace.h| 34 -- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/linux/trace_recursion.h b/incl

[RFC PATCH 12/32] function_graph: Move set_graph_function tests to shadow stack global var

2023-11-05 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/trace_recursion.h |5 + kernel/trace/trace.h | 32 +--- kernel/trace/trace_functions_graph.c |6 +++--- kernel/trace/trace_irqsoff.c |4 ++-- kernel/tr

[RFC PATCH 11/32] function_graph: Add "task variables" per task for fgraph_ops

2023-11-05 Thread Masami Hiramatsu (Google)
atures on a per task basis having a way to maintain state for each task. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h |2 + kernel/trace/fgraph.c | 73 +++- 2 files changed, 74 i

[RFC PATCH 10/32] function_graph: Have the instances use their own ftrace_ops for filtering

2023-11-05 Thread Masami Hiramatsu (Google)
From: Steven Rostedt (VMware) Allow for instances to have their own ftrace_ops part of the fgraph_ops that makes the funtion_graph tracer filter on the set_ftrace_filter file of the instance and not the top instance. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu

[RFC PATCH 09/32] ftrace: Allow ftrace startup flags exist without dynamic ftrace

2023-11-05 Thread Masami Hiramatsu (Google)
compile because dynamic ftrace is disabled. This change is needed to move some of the logic of what is passed to ftrace_startup() out of the parameters of ftrace_startup(). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h | 18

[RFC PATCH 08/32] ftrace: Allow function_graph tracer to be enabled in instances

2023-11-05 Thread Masami Hiramatsu (Google)
: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h |1 + kernel/trace/ftrace.c|1 + kernel/trace/trace.h | 12 ++ kernel/trace/trace_functions.c |8 kernel/trace

[RFC PATCH 07/32] ftrace/function_graph: Pass fgraph_ops to function graph callbacks

2023-11-05 Thread Masami Hiramatsu (Google)
to the function graph tracer. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h | 10 +++--- kernel/trace/fgraph.c| 17 ++--- kernel/trace/ftrace.c|6 -- kernel

[RFC PATCH 06/32] function_graph: Remove logic around ftrace_graph_entry and return

2023-11-05 Thread Masami Hiramatsu (Google)
function_graph tracer. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fgraph.c | 72 +++- kernel/trace/ftrace.c |2 - kernel/trace/ftrace_internal.h |2 - 3 files changed, 20 insertions(+), 56

[RFC PATCH 05/32] function_graph: Allow multiple users to attach to function graph

2023-11-05 Thread Masami Hiramatsu (Google)
n both are called is not completely handled yet, but that shouldn't be too hard to manage. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fgraph.c | 332 + 1 file changed, 280 insertions(+

[RFC PATCH 04/32] function_graph: Add an array structure that will allow multiple callbacks

2023-11-05 Thread Masami Hiramatsu (Google)
n the shadow stack. We need to only save the index, because this will allow the fgraph_ops to be freed before the function returns (which may happen if the function call schedule for a long time). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fgr

[RFC PATCH 02/32] function_graph: Convert ret_stack to a series of longs

2023-11-05 Thread Masami Hiramatsu (Google)
the return side of the functions. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/sched.h |2 - kernel/trace/fgraph.c | 124 - 2 files changed, 71 insertions(+), 55 deletions(-) diff --git a

[RFC PATCH 03/32] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long

2023-11-05 Thread Masami Hiramatsu (Google)
dt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fgraph.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 30edeb6d4aa9..837daf929d2a 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trac

[RFC PATCH 01/32] seq_buf: Export seq_buf_puts()

2023-11-05 Thread Masami Hiramatsu (Google)
: Steven Rostedt (Google) Signed-off-by: Masami Hiramatsu (Google) --- lib/seq_buf.c |1 + 1 file changed, 1 insertion(+) diff --git a/lib/seq_buf.c b/lib/seq_buf.c index 45c450f423fa..46a1b00c3815 100644 --- a/lib/seq_buf.c +++ b/lib/seq_buf.c @@ -189,6 +189,7 @@ int seq_buf_puts(struct

[RFC PATCH 00/32] tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph

2023-11-05 Thread Masami Hiramatsu (Google)
user. [29/32] to [31/32] rewrites fprobes and updates its users. [32/32] is a documentation update. This series can be applied against the probes-fixes-v6.6-rc7 on linux-trace tree. This series can also be found below branch. https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git

[PATCH] tracing: fprobe-event: Fix to check tracepoint event and return

2023-11-03 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Fix to check the tracepoint event is not valid with $retval. The commit 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval") introduced automatic return probe conversion with $retval. But since tracepoint event does not supp

[PATCH for-next] tracing/kprobes: Add symbol counting check when module loads

2023-10-28 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Check the number of probe target symbols in the target module when the module is loaded. If the probe is not on the unique name symbols in the module, it will be rejected at that point. Note that the symbol which has a unique name in the target module, it will be

[PATCH v2] locking/atomic: sh: Use generic_cmpxchg_local for arch_cmpxchg_local()

2023-10-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Use __generic_cmpxchg_local() for arch_cmpxchg_local() implementation in SH architecture because it does not implement arch_cmpxchg_local(). Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202310241310.ir5uukog-...@intel.com/ Signed

[PATCH] locking/atomic: sh: Use generic_cmpxchg_local for arch_cmpxchg_local()

2023-10-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Use generic_cmpxchg_local() for arch_cmpxchg_local() implementation in SH architecture because it does not implement arch_cmpxchg_local(). Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202310241310.ir5uukog-...@intel.com/ Signed

[PATCH] fprobe: Fix to ensure the number of active retprobes is not zero

2023-10-16 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) The number of active retprobes can be zero but it is not acceptable, so return EINVAL error if detected. Reported-by: wuqiang.matt Closes: https://lore.kernel.org/all/20231016222103.cb9f426edc60220eabd8a...@kernel.org/ Fixes: 5b0ab78998e3 ("fprobe

[PATCH] bpf/btf: Move tracing BTF APIs to the BTF library

2023-10-10 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Move the BTF APIs used in tracing to the BTF library code for sharing it with others. Previously, to avoid complex dependency in a series I made it on the tracing tree, but now it is a good time to move it to BPF tree because these functions are pure BTF functions

[PATCH v5 12/12] Documentation: tracing: Add a note about argument and retval access

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a note about the argument and return value accecss will be best effort. Depending on the type, it will be passed via stack or a pair of the registers, but $argN and $retval only support the single register access. Suggested-by: Alexei Starovoitov Signed-off

[PATCH v5 11/12] Documentation: probes: Update fprobe document to use ftrace_regs

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Update fprobe document so that the entry/exit handler uses ftrace_regs instead of pt_regs. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Florent Revest --- Documentation/trace/fprobe.rst | 14 ++ 1 file changed, 6 insertions(+), 8 deletions

[PATCH v5 10/12] bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Enable kprobe_multi feature if CONFIG_FPROBE is enabled. The pt_regs is converted from ftrace_regs by ftrace_partial_regs(), thus some registers may always returns 0. But it should be enough for function entry (access arguments) and exit (access return value

[PATCH v5 09/12] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Allow fprobe events to be enabled with CONFIG_DYNAMIC_FTRACE_WITH_ARGS. With this change, fprobe events mostly use ftrace_regs instead of pt_regs. Note that if the arch doesn't enable HAVE_PT_REGS_COMPAT_FTRACE_REGS, fprobe events will not be able to be used

[PATCH v5 08/12] tracing: Add ftrace_fill_perf_regs() for perf event

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_fill_perf_regs() which should be compatible with the perf_fetch_caller_regs(). In other words, the pt_regs returned from the ftrace_fill_perf_regs() must satisfy 'user_mode(regs) == false' and can be used for stack tracing. Signed-off-

[PATCH v5 07/12] tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_partial_regs() which converts the ftrace_regs to pt_regs. If the architecture defines its own ftrace_regs, this copies partial registers to pt_regs and returns it. If not, ftrace_regs is the same as pt_regs and ftrace_partial_regs() will return

[PATCH v5 06/12] fprobe: rethook: Use ftrace_regs in fprobe exit handler and rethook

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Change the fprobe exit handler and rethook to use ftrace_regs structure instead of pt_regs. This also introduce HAVE_PT_REGS_TO_FTRACE_REGS_CAST which means the ftrace_regs's memory layout is equal to the pt_regs so that those are able to cast. Only if

[PATCH v5 05/12] tracing: Expose ftrace_regs regardless of CONFIG_FUNCTION_TRACER

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) In order to be able to use ftrace_regs even from features unrelated to function tracer (e.g. kretprobe), expose ftrace_regs structures and APIs even if the CONFIG_FUNCTION_TRACER=n. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Florent Revest --- Changes

[PATCH v5 04/12] fprobe: Use ftrace_regs in fprobe entry handler

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) This allows fprobes to be available with CONFIG_DYNAMIC_FTRACE_WITH_ARGS instead of CONFIG_DYNAMIC_FTRACE_WITH_REGS, then we can enable fprobe on arm64. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Florent Revest --- Changes in v3: - Use

[PATCH v5 03/12] tracing: Add a comment about the requirements of the ftrace_regs

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a comment about the requirements of the ftrace_regs if it is implemented on the arch-dependent code with CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS. Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h |8 1 file changed, 8 insertions

[PATCH v5 02/12] Documentation: probes: Add a new ret_ip callback parameter

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a new ret_ip callback parameter description. Fixes: cb16330d1274 ("fprobe: Pass return address to the handlers") Signed-off-by: Masami Hiramatsu (Google) Acked-by: Florent Revest --- Changes in v4: - Update ret_ip description (Than

[PATCH v5 01/12] riscv: ftrace: Fix to pass correct ftrace_regs to ftrace_func_t functions

2023-09-24 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Since ftrace_func_t requires to pass 'struct ftrace_regs *' as the 4th argument even if FTRACE_OPS_FL_SAVE_REGS is not set, ftrace_caller must pass 'struct ftrace_regs *', which is a partial pt_regs, on the stack to the ftrace_func_t fu

[PATCH v5 00/12] tracing: fprobe: rethook: Use ftrace_regs instead of pt_regs

2023-09-24 Thread Masami Hiramatsu (Google)
new fprobe callbacks. - Add notes for the $argN and $retval. This series can be applied against the trace-v6.6-rc2 on linux-trace tree. This series can also be found below branch. https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git/log/?h=topic/fprobe-ftrace-regs Thank you, --- Masami

Re: [PATCH] tools/bootconfig: Simplify expression

2021-04-16 Thread Masami Hiramatsu
On Wed, 14 Apr 2021 21:46:47 +0800 zuoqil...@163.com wrote: > From: zuoqilin > > It is not necessary to define the variable ret to receive > the return value of the xbc_node_compose_key() method. > > Signed-off-by: zuoqilin Indeed. Acked-by: Masami Hiramatsu Thank yo

Re: [PATCH v2] riscv/kprobe: Restore local irqflag if kprobe is cancelled

2021-04-16 Thread Masami Hiramatsu
in, we overwrite > the saved irqflag by calling kprobe_save_local_irqflag(). Note, > 'SIE' is masked in this new saved irqflag. After kprobe is > serviced, the CPU 'sstatus' is restored with 'SIE' masked. > This overwritten 'sstatus' cause BUG_

Re: [PATCH] x86/kprobes: Simplify alloc_insn_page() with __vmalloc_node_range

2021-04-14 Thread Masami Hiramatsu
robes: Remove MODULES dependency" series look > much better. The last version is v5, I'm not sure whether Jarkko will > send new version to mainline the series. I hope so. If module_alloc() itself is implemented on the generic text_alloc(), I can replace the module_alloc() with text_alloc(). Thank you, -- Masami Hiramatsu

Re: [PATCH] x86/kprobes: Simplify alloc_insn_page() with __vmalloc_node_range

2021-04-13 Thread Masami Hiramatsu
, NUMA_NO_NODE, > + __builtin_return_address(0)); > } > > /* Recover page to RW mode before releasing it */ > -- > 2.31.0 > -- Masami Hiramatsu

Re: [PATCH] arm64: kprobes: Restore local irqflag if kprobes is cancelled

2021-04-12 Thread Masami Hiramatsu
On Mon, 12 Apr 2021 22:11:44 +0900 Masami Hiramatsu wrote: > Hi Jisheng, > > On Mon, 12 Apr 2021 17:41:01 +0800 > Jisheng Zhang wrote: > > > If instruction being single stepped caused a page fault, the kprobes > > is cancelled to let the page fault handler continue

Re: [PATCH] arm64: kprobes: Restore local irqflag if kprobes is cancelled

2021-04-12 Thread Masami Hiramatsu
restore_previous_kprobe(kcb); > - else > + } else { > + kprobes_restore_local_irqflag(kcb, regs); > reset_current_kprobe(); > + } > > break; > case KPROBE_HIT_ACTIVE: > -- > 2.31.0 > -- Masami Hiramatsu

Re: [PATCH] tracing/dynevent: Fix a memory leak in an error handling path

2021-04-12 Thread Masami Hiramatsu
function") > Signed-off-by: Christophe JAILLET Acked-by: Masami Hiramatsu Thank you, > --- > kernel/trace/trace_dynevent.c | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/kernel/trace/trace_dynevent.c b/kernel/trace/trace_dynevent.c > i

Re: [PATCH] riscv: keep interrupts disabled for BREAKPOINT exception

2021-04-08 Thread Masami Hiramatsu
ntent is safe. > > > > > > On Thu, 1 Apr 2021, Masami Hiramatsu wrote: > > > > > > > > Current riscv's kprobe handlers are run with both preemption and > > > > > > interrupt enabled, this violates kprobe requirements. Fix this issu

Re: [RFC PATCH v1 0/4] arm64: Implement stack trace reliability checks

2021-04-05 Thread Masami Hiramatsu
On Mon, 5 Apr 2021 09:56:48 -0500 "Madhavan T. Venkataraman" wrote: > > > On 4/5/21 8:24 AM, Masami Hiramatsu wrote: > > Hi Madhaven, > > > > On Sat, 3 Apr 2021 22:29:12 -0500 > > "Madhavan T. Venkataram

Re: [RFC PATCH v1 0/4] arm64: Implement stack trace reliability checks

2021-04-05 Thread Masami Hiramatsu
On Mon, 5 Apr 2021 12:12:08 -0500 "Madhavan T. Venkataraman" wrote: > > > On 4/5/21 9:56 AM, Madhavan T. Venkataraman wrote: > > > > > > On 4/5/21 8:24 AM, Masami Hiramatsu wrote: > >> Hi Madhaven, > >> > >> On Sat,

Re: [RFC PATCH v1 0/4] arm64: Implement stack trace reliability checks

2021-04-05 Thread Masami Hiramatsu
t; > OK. Until that is available, this case needs to be addressed. Actually, I've done that on arm64 :) See below patch. (and I also have a similar code for arm32, what I'm considering is how to unify x86/arm/arm64 kretprobe_find_ret_addr(), since those are very similar.) This is appl

Re: [PATCH] arm64/kernel/probes: Use BUG_ON instead of if condition followed by BUG.

2021-04-01 Thread Masami Hiramatsu
On Tue, 30 Mar 2021 04:57:50 -0700 zhouchuangao wrote: > It can be optimized at compile time. > Anyway, this seems to make the code simpler. Reviewed-by: Masami Hiramatsu Thanks! > Signed-off-by: zhouchuangao > --- > arch/arm64/kernel/probes/kprobes.c | 3 +-- >

Re: [RFC PATCH -tip 3/3] x86/kprobes,orc: Unwind optprobe trampoline correctly

2021-03-31 Thread Masami Hiramatsu
On Thu, 1 Apr 2021 10:44:52 +0900 Masami Hiramatsu wrote: > On Wed, 31 Mar 2021 10:57:36 -0500 > Josh Poimboeuf wrote: > > > On Wed, Mar 31, 2021 at 02:44:56PM +0900, Masami Hiramatsu wrote: > > > +#ifdef CONFIG_UNWINDER_ORC > > > +unsigned long recover_optpr

Re: [RFC PATCH -tip 3/3] x86/kprobes,orc: Unwind optprobe trampoline correctly

2021-03-31 Thread Masami Hiramatsu
On Wed, 31 Mar 2021 14:44:56 +0900 Masami Hiramatsu wrote: > +#ifdef CONFIG_UNWINDER_ORC > +unsigned long recover_optprobe_trampoline(unsigned long addr, unsigned long > *sp) > +{ > + unsigned long offset, entry, probe_addr; > + struct optimized_kprobe *op; > +

Re: [RFC PATCH -tip 3/3] x86/kprobes,orc: Unwind optprobe trampoline correctly

2021-03-31 Thread Masami Hiramatsu
On Wed, 31 Mar 2021 10:57:36 -0500 Josh Poimboeuf wrote: > On Wed, Mar 31, 2021 at 02:44:56PM +0900, Masami Hiramatsu wrote: > > +#ifdef CONFIG_UNWINDER_ORC > > +unsigned long recover_optprobe_trampoline(unsigned long addr, unsigned > > long *sp) > > +{ > >

Re: [PATCH] riscv: keep interrupts disabled for BREAKPOINT exception

2021-03-31 Thread Masami Hiramatsu
Hi, On Wed, 31 Mar 2021 22:22:44 +0800 Jisheng Zhang wrote: > On Tue, 30 Mar 2021 18:33:16 +0900 > Masami Hiramatsu wrote: > > > Hi Jisheng, > > Hi Masami, > > > > > On Tue, 30 Mar 2021 02:16:24 +0800 > > Jisheng Zhang wrote: > > > &g

[RFC PATCH -tip 3/3] x86/kprobes,orc: Unwind optprobe trampoline correctly

2021-03-30 Thread Masami Hiramatsu
trampoline address. Signed-off-by: Masami Hiramatsu --- arch/x86/include/asm/kprobes.h |6 arch/x86/kernel/kprobes/opt.c | 54 arch/x86/kernel/unwind_orc.c | 15 +-- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a

[RFC PATCH -tip 2/3] kprobes: Add functions to find instruction buffer entry address

2021-03-30 Thread Masami Hiramatsu
Add find_kprobe_{insn,optinsn}_slot_entry() functions to find corresponding entry address of the kprobe instrurction buffer which includes given address. Signed-off-by: Masami Hiramatsu --- include/linux/kprobes.h |8 kernel/kprobes.c| 25 ++--- 2

<    1   2   3   4   5   6   7   8   9   10   >