mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
Change the fprobe exit handler to use ftrace_regs structure instead of pt_regs. This also introduce HAVE_FTRACE_REGS_HAVING_PT_REGS which means the ftrace_regs is including the pt_regs so that ftrace_regs can provide pt_regs without memory allocation. Fprobe introduces a new dependency with that. Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Acked-by: Heiko Carstens <hca@linux.ibm.com> # s390 Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com> Cc: Florent Revest <revest@chromium.org> Cc: bpf <bpf@vger.kernel.org> Cc: Alan Maguire <alan.maguire@oracle.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: x86@kernel.org Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Song Liu <song@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: KP Singh <kpsingh@kernel.org> Cc: Matt Bobrowski <mattbobrowski@google.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Andrii Nakryiko <andrii@kernel.org> Cc: Martin KaFai Lau <martin.lau@linux.dev> Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: Yonghong Song <yonghong.song@linux.dev> Cc: John Fastabend <john.fastabend@gmail.com> Cc: Stanislav Fomichev <sdf@fomichev.me> Cc: Hao Luo <haoluo@google.com> Cc: Andrew Morton <akpm@linux-foundation.org> Link: https://lore.kernel.org/173518995092.391279.6765116450352977627.stgit@devnote2 Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
125 lines
3.3 KiB
C
125 lines
3.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Simple ftrace probe wrapper */
|
|
#ifndef _LINUX_FPROBE_H
|
|
#define _LINUX_FPROBE_H
|
|
|
|
#include <linux/compiler.h>
|
|
#include <linux/ftrace.h>
|
|
#include <linux/rethook.h>
|
|
|
|
struct fprobe;
|
|
|
|
typedef int (*fprobe_entry_cb)(struct fprobe *fp, unsigned long entry_ip,
|
|
unsigned long ret_ip, struct ftrace_regs *regs,
|
|
void *entry_data);
|
|
|
|
typedef void (*fprobe_exit_cb)(struct fprobe *fp, unsigned long entry_ip,
|
|
unsigned long ret_ip, struct ftrace_regs *regs,
|
|
void *entry_data);
|
|
|
|
/**
|
|
* struct fprobe - ftrace based probe.
|
|
* @ops: The ftrace_ops.
|
|
* @nmissed: The counter for missing events.
|
|
* @flags: The status flag.
|
|
* @rethook: The rethook data structure. (internal data)
|
|
* @entry_data_size: The private data storage size.
|
|
* @nr_maxactive: The max number of active functions.
|
|
* @entry_handler: The callback function for function entry.
|
|
* @exit_handler: The callback function for function exit.
|
|
*/
|
|
struct fprobe {
|
|
#ifdef CONFIG_FUNCTION_TRACER
|
|
/*
|
|
* If CONFIG_FUNCTION_TRACER is not set, CONFIG_FPROBE is disabled too.
|
|
* But user of fprobe may keep embedding the struct fprobe on their own
|
|
* code. To avoid build error, this will keep the fprobe data structure
|
|
* defined here, but remove ftrace_ops data structure.
|
|
*/
|
|
struct ftrace_ops ops;
|
|
#endif
|
|
unsigned long nmissed;
|
|
unsigned int flags;
|
|
struct rethook *rethook;
|
|
size_t entry_data_size;
|
|
int nr_maxactive;
|
|
|
|
fprobe_entry_cb entry_handler;
|
|
fprobe_exit_cb exit_handler;
|
|
};
|
|
|
|
/* This fprobe is soft-disabled. */
|
|
#define FPROBE_FL_DISABLED 1
|
|
|
|
/*
|
|
* This fprobe handler will be shared with kprobes.
|
|
* This flag must be set before registering.
|
|
*/
|
|
#define FPROBE_FL_KPROBE_SHARED 2
|
|
|
|
static inline bool fprobe_disabled(struct fprobe *fp)
|
|
{
|
|
return (fp) ? fp->flags & FPROBE_FL_DISABLED : false;
|
|
}
|
|
|
|
static inline bool fprobe_shared_with_kprobes(struct fprobe *fp)
|
|
{
|
|
return (fp) ? fp->flags & FPROBE_FL_KPROBE_SHARED : false;
|
|
}
|
|
|
|
#ifdef CONFIG_FPROBE
|
|
int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter);
|
|
int register_fprobe_ips(struct fprobe *fp, unsigned long *addrs, int num);
|
|
int register_fprobe_syms(struct fprobe *fp, const char **syms, int num);
|
|
int unregister_fprobe(struct fprobe *fp);
|
|
bool fprobe_is_registered(struct fprobe *fp);
|
|
#else
|
|
static inline int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
static inline int register_fprobe_ips(struct fprobe *fp, unsigned long *addrs, int num)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
static inline int register_fprobe_syms(struct fprobe *fp, const char **syms, int num)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
static inline int unregister_fprobe(struct fprobe *fp)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
static inline bool fprobe_is_registered(struct fprobe *fp)
|
|
{
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
/**
|
|
* disable_fprobe() - Disable fprobe
|
|
* @fp: The fprobe to be disabled.
|
|
*
|
|
* This will soft-disable @fp. Note that this doesn't remove the ftrace
|
|
* hooks from the function entry.
|
|
*/
|
|
static inline void disable_fprobe(struct fprobe *fp)
|
|
{
|
|
if (fp)
|
|
fp->flags |= FPROBE_FL_DISABLED;
|
|
}
|
|
|
|
/**
|
|
* enable_fprobe() - Enable fprobe
|
|
* @fp: The fprobe to be enabled.
|
|
*
|
|
* This will soft-enable @fp.
|
|
*/
|
|
static inline void enable_fprobe(struct fprobe *fp)
|
|
{
|
|
if (fp)
|
|
fp->flags &= ~FPROBE_FL_DISABLED;
|
|
}
|
|
|
|
#endif
|