[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)
/kernel/git/mhiramat/linux.git/log/?h=topic/fprobe-on-fgraph Thank you, --- Christophe JAILLET (1): seq_buf: Export seq_buf_puts() Masami Hiramatsu (Google) (15): tracing: Add a comment about ftrace_regs definition x86: tracing: Add ftrace_regs definition in the header

[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 from

[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_FREGS. So

[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-by: Masami

[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 a new

[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 other registers

[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 'reregfunc' are mutual

[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 (Google) --- arch/arm64/kernel

[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 changed, 1 insertion

[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

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

2023-11-05 Thread Masami Hiramatsu (Google)
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 | 244

[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)
s 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 insert

[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)
to 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)
-by: 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)
into the 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)
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(+), 52 deletions

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

2023-11-05 Thread Masami Hiramatsu (Google)
on 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/fgraph.c

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

2023-11-05 Thread Masami Hiramatsu (Google)
for 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

[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)
-by: 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)
below branch. https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git/log/?h=topic/fprobe-on-fgraph Thank you, --- Christophe JAILLET (1): seq_buf: Export seq_buf_puts() Masami Hiramatsu (Google) (16): function_graph: Fix to update curr_ret_stack with ARRAY entry size

[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

[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] riscv: ftrace: Fix to pass correct ftrace_regs to ftrace_func_t functions

2023-10-02 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 functions, so

[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 from

[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-by: Masami

[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

[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 functions, so

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

2023-09-24 Thread Masami Hiramatsu (Google)
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 Hiramatsu

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
flag 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_ON() in __find_get_block. > > This bug is already fixed on arm64 by

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

2021-04-14 Thread Masami Hiramatsu
S 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
on") > 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 > index dc971

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

2021-04-08 Thread Masami Hiramatsu
er and know the content 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 requi

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
til 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 applicable on my x86 series v

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

[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

[RFC PATCH -tip 1/3] x86/kprobes: Add ORC information to optprobe template

2021-03-30 Thread Masami Hiramatsu
As same as kretprobe_trampoline, move the optprobe template code in the text for making ORC information on that. Signed-off-by: Masami Hiramatsu --- arch/x86/kernel/kprobes/opt.c | 18 +- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/kprobes

[RFC PATCH -tip 0/3] x86/kprobes,orc: Fix ORC unwinder to unwind stack with optimized probe

2021-03-30 Thread Masami Hiramatsu
> do_syscall_64+0x33/0x40 => entry_SYSCALL_64_after_hwframe+0x44/0xae => 0 => 0 Thank you, --- Masami Hiramatsu (3): x86/kprobes: Add ORC information to optprobe template kprobes: Add functions to find instruction buffer entry address x86/kprobes,orc: Unwind optprobe

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

2021-03-30 Thread Masami Hiramatsu
0,6 +130,8 @@ skip_context_tracking: >*/ > andi t0, s1, SR_PIE > beqz t0, 1f > + li t0, EXC_BREAKPOINT > + beq s4, t0, 1f > #ifdef CONFIG_TRACE_IRQFLAGS > call trace_hardirqs_on > #endif > -- > 2.31.0 > > -- Masami Hiramatsu

Re: [PATCH] samples/kprobes: Add riscv support

2021-03-30 Thread Masami Hiramatsu
On Tue, 30 Mar 2021 02:04:16 +0800 Jisheng Zhang wrote: > From: Jisheng Zhang > > Add riscv specific info dump in both handler_pre() and handler_post(). > Looks good to me. Acked-by: Masami Hiramatsu Thanks! > Signed-off-by: Jisheng Zhang > --- > samples/kprobes

Re: [PATCH] riscv: add do_page_fault and do_trap_break into the kprobes blacklist

2021-03-30 Thread Masami Hiramatsu
On Tue, 30 Mar 2021 02:12:26 +0800 Jisheng Zhang wrote: > From: Jisheng Zhang > > These two functions are used to implement the kprobes feature so they > can't be kprobed. > Looks good to me. Reviewed-by: Masami Hiramatsu Thanks, > Fixes: c22b0bcb1dd0 ("riscv

Re: linux-next: Fixes tag needs some work in the tip tree

2021-03-28 Thread Masami Hiramatsu
just making sure it is not set (or set to "auto"). Sorry, it was my mistake. this is the correct tag. Fixes: 6256e668b7af ("x86/kprobes: Use int3 instead of debug trap for single-step") Thanks, > > -- > Cheers, > Stephen Rothwell -- Masami Hiramatsu

Re: [PATCH -tip v5 00/12] kprobes: Fix stacktrace with kretprobes on x86

2021-03-26 Thread Masami Hiramatsu
On Fri, 26 Mar 2021 21:28:26 +0900 Masami Hiramatsu wrote: > Hello, > > Here is the 5th version of the series to fix the stacktrace with kretprobe > on x86. After merging this, I'll fix other architectures. > > The previous version is; > > htt

[PATCH -tip v5 12/12] tracing: Show kretprobe unknown indicator only for kretprobe_trampoline

2021-03-26 Thread Masami Hiramatsu
ftrace shows "[unknown/kretprobe'd]" indicator all addresses in the kretprobe_trampoline, but the modified address by kretprobe should be only kretprobe_trampoline+0. Signed-off-by: Masami Hiramatsu Acked-by: Steven Rostedt (VMware) --- kernel/trace/trace_output.c | 17 --

[PATCH -tip v5 11/12] x86/unwind: Recover kretprobe trampoline entry

2021-03-26 Thread Masami Hiramatsu
x5f/0xe0 => do_syscall_64+0x33/0x40 => entry_SYSCALL_64_after_hwframe+0x44/0xae Reported-by: Daniel Xu Signed-off-by: Masami Hiramatsu Suggested-by: Josh Poimboeuf --- Changes in v5: - Fix the case of interrupt happens on kretprobe_trampoline+0. Changes in v3: - Split out the kret

[PATCH -tip v5 10/12] x86/kprobes: Push a fake return address at kretprobe_trampoline

2021-03-26 Thread Masami Hiramatsu
This changes x86/kretprobe stack frame on kretprobe_trampoline a bit, which now push the kretprobe_trampoline as a fake return address at the bottom of the stack frame. With this fix, the ORC unwinder will see the kretprobe_trampoline as a return address. Signed-off-by: Masami Hiramatsu

[PATCH -tip v5 08/12] arm: kprobes: Make a space for regs->ARM_pc at kretprobe_trampoline

2021-03-26 Thread Masami Hiramatsu
Change kretprobe_trampoline to make a space for regs->ARM_pc so that kretprobe_trampoline_handler can call instruction_pointer_set() safely. Signed-off-by: Masami Hiramatsu --- arch/arm/probes/kprobes/core.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/probes/kprobes/cor

[PATCH -tip v5 09/12] kprobes: Setup instruction pointer in __kretprobe_trampoline_handler

2021-03-26 Thread Masami Hiramatsu
To simplify the stacktrace with pt_regs from kretprobe handler, set the correct return address to the instruction pointer in the pt_regs before calling kretprobe handlers. Suggested-by: Josh Poimboeuf Signed-off-by: Masami Hiramatsu --- Changes in v3: - Cast the correct_ret_addr to unsigned

[PATCH -tip v5 07/12] ia64: Add instruction_pointer_set() API

2021-03-26 Thread Masami Hiramatsu
Add instruction_pointer_set() API for ia64. Signed-off-by: Masami Hiramatsu --- Changes in v4: - Make the API macro for avoiding a build error. --- arch/ia64/include/asm/ptrace.h |5 + 1 file changed, 5 insertions(+) diff --git a/arch/ia64/include/asm/ptrace.h b/arch/ia64/include

[PATCH -tip v5 06/12] ARC: Add instruction_pointer_set() API

2021-03-26 Thread Masami Hiramatsu
Add instruction_pointer_set() API for arc. Signed-off-by: Masami Hiramatsu --- arch/arc/include/asm/ptrace.h |5 + 1 file changed, 5 insertions(+) diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h index 4c3c9be5bd16..cca8d6583e31 100644 --- a/arch/arc/include

[PATCH -tip v5 05/12] x86/kprobes: Add UNWIND_HINT_FUNC on kretprobe_trampoline code

2021-03-26 Thread Masami Hiramatsu
seems non-standard. So this marks it is STACK_FRAME_NON_STANDARD() and undefine UNWIND_HINT_FUNC. Anyway, with the frame pointer, FP unwinder can unwind the stack frame correctly without that hint. Signed-off-by: Josh Poimboeuf Signed-off-by: Masami Hiramatsu --- Changes in v4: - Apply

[PATCH -tip v5 04/12] kprobes: Add kretprobe_find_ret_addr() for searching return address

2021-03-26 Thread Masami Hiramatsu
Add kretprobe_find_ret_addr() for searching correct return address from kretprobe instance list. Signed-off-by: Masami Hiramatsu --- Changes in v3: - Remove generic stacktrace fixup. Instead, it should be solved in each unwinder. This just provide the generic interface. Changes in v2

[PATCH -tip v5 03/12] kprobes: treewide: Remove trampoline_address from kretprobe_trampoline_handler()

2021-03-26 Thread Masami Hiramatsu
Remove trampoline_address from kretprobe_trampoline_handler(). Instead of passing the address, kretprobe_trampoline_handler() can use new kretprobe_trampoline_addr(). Signed-off-by: Masami Hiramatsu --- Changes in v3: - Remove wrong kretprobe_trampoline declaration from arch/x86/include

[PATCH -tip v5 02/12] kprobes: treewide: Replace arch_deref_entry_point() with dereference_function_descriptor()

2021-03-26 Thread Masami Hiramatsu
Replace arch_deref_entry_point() with dereference_function_descriptor() because those are doing same thing. Signed-off-by: Masami Hiramatsu --- arch/ia64/kernel/kprobes.c|5 - arch/powerpc/kernel/kprobes.c | 11 --- include/linux/kprobes.h |1 - kernel/kprobes.c

[PATCH -tip v5 01/12] ia64: kprobes: Fix to pass correct trampoline address to the handler

2021-03-26 Thread Masami Hiramatsu
so changes to use correct symbol dereference function to get the function address from the kretprobe_trampoline. Fixes: e792ff804f49 ("ia64: kprobes: Use generic kretprobe trampoline handler") Signed-off-by: Masami Hiramatsu --- Changes in v5: - Fix a compile error typo. --- arch/i

[PATCH -tip v5 00/12] kprobes: Fix stacktrace with kretprobes on x86

2021-03-26 Thread Masami Hiramatsu
API. You can also get this series from git://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git kprobes/kretprobe-stackfix-v5 Thank you, --- Josh Poimboeuf (1): x86/kprobes: Add UNWIND_HINT_FUNC on kretprobe_trampoline code Masami Hiramatsu (11): ia64: kprobes:

Re: [PATCH -tip v4 10/12] x86/kprobes: Push a fake return address at kretprobe_trampoline

2021-03-26 Thread Masami Hiramatsu
On Fri, 26 Mar 2021 03:05:03 +0900 Masami Hiramatsu wrote: > On Wed, 24 Mar 2021 10:40:58 +0900 > Masami Hiramatsu wrote: > > > On Tue, 23 Mar 2021 23:30:07 +0100 > > Peter Zijlstra wrote: > > > > > On Mon, Mar 22, 2021 at 03:41:40PM +0900, Masami Hiram

Re: [PATCH -tip v4 10/12] x86/kprobes: Push a fake return address at kretprobe_trampoline

2021-03-25 Thread Masami Hiramatsu
On Wed, 24 Mar 2021 10:40:58 +0900 Masami Hiramatsu wrote: > On Tue, 23 Mar 2021 23:30:07 +0100 > Peter Zijlstra wrote: > > > On Mon, Mar 22, 2021 at 03:41:40PM +0900, Masami Hiramatsu wrote: > > > ".global kretprobe_trampoline\n" > > >

[tip: x86/core] x86/kprobes: Fix to check non boostable prefixes correctly

2021-03-25 Thread tip-bot2 for Masami Hiramatsu
The following commit has been merged into the x86/core branch of tip: Commit-ID: 6dd3b8c9f58816a1354be39559f630cd1bd12159 Gitweb: https://git.kernel.org/tip/6dd3b8c9f58816a1354be39559f630cd1bd12159 Author:Masami Hiramatsu AuthorDate:Thu, 25 Mar 2021 19:08:31 +09:00

[tip: x86/core] x86/kprobes: Fix to identify indirect jmp and others using range case

2021-03-25 Thread tip-bot2 for Masami Hiramatsu
The following commit has been merged into the x86/core branch of tip: Commit-ID: 2f706e0e5e263c0d204e37ea496cbb0e98aac2d2 Gitweb: https://git.kernel.org/tip/2f706e0e5e263c0d204e37ea496cbb0e98aac2d2 Author:Masami Hiramatsu AuthorDate:Thu, 25 Mar 2021 19:08:43 +09:00

[PATCH -tip 1/2] x86/kprobes: Fix to check non boostable prefixes correctly

2021-03-25 Thread Masami Hiramatsu
lse. Fix those by checking each prefix bytes with for_each_insn_prefix loop and getting the correct attribute for each prefix byte. Also, this removes unlikely, because this is a slow path. Fixes: a8d11cd0714f ("kprobes/x86: Consolidate insn decoder users for copying code") Signed-off-b

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