Commit 02afb8d6 authored by Punit Agrawal's avatar Punit Agrawal Committed by Steven Rostedt (VMware)

kprobe: Simplify prepare_kprobe() by dropping redundant version

The function prepare_kprobe() is called during kprobe registration and
is responsible for ensuring any architecture related preparation for
the kprobe is done before returning.

One of two versions of prepare_kprobe() is chosen depending on the
availability of KPROBE_ON_FTRACE in the kernel configuration.

Simplify the code by dropping the version when KPROBE_ON_FTRACE is not
selected - instead relying on kprobe_ftrace() to return false when
KPROBE_ON_FTRACE is not set.

No functional change.

Link: https://lkml.kernel.org/r/163163033696.489837.9264661820279300788.stgit@devnote2Signed-off-by: default avatarPunit Agrawal <punitagrawal@gmail.com>
Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 5d6de7d7
...@@ -354,6 +354,11 @@ static inline void wait_for_kprobe_optimizer(void) { } ...@@ -354,6 +354,11 @@ static inline void wait_for_kprobe_optimizer(void) { }
extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
struct ftrace_ops *ops, struct ftrace_regs *fregs); struct ftrace_ops *ops, struct ftrace_regs *fregs);
extern int arch_prepare_kprobe_ftrace(struct kprobe *p); extern int arch_prepare_kprobe_ftrace(struct kprobe *p);
#else
static inline int arch_prepare_kprobe_ftrace(struct kprobe *p)
{
return -EINVAL;
}
#endif #endif
int arch_check_ftrace_location(struct kprobe *p); int arch_check_ftrace_location(struct kprobe *p);
......
...@@ -1033,15 +1033,6 @@ static struct ftrace_ops kprobe_ipmodify_ops __read_mostly = { ...@@ -1033,15 +1033,6 @@ static struct ftrace_ops kprobe_ipmodify_ops __read_mostly = {
static int kprobe_ipmodify_enabled; static int kprobe_ipmodify_enabled;
static int kprobe_ftrace_enabled; static int kprobe_ftrace_enabled;
/* Must ensure p->addr is really on ftrace */
static int prepare_kprobe(struct kprobe *p)
{
if (!kprobe_ftrace(p))
return arch_prepare_kprobe(p);
return arch_prepare_kprobe_ftrace(p);
}
/* Caller must lock kprobe_mutex */ /* Caller must lock kprobe_mutex */
static int __arm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops, static int __arm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops,
int *cnt) int *cnt)
...@@ -1113,11 +1104,6 @@ static int disarm_kprobe_ftrace(struct kprobe *p) ...@@ -1113,11 +1104,6 @@ static int disarm_kprobe_ftrace(struct kprobe *p)
ipmodify ? &kprobe_ipmodify_enabled : &kprobe_ftrace_enabled); ipmodify ? &kprobe_ipmodify_enabled : &kprobe_ftrace_enabled);
} }
#else /* !CONFIG_KPROBES_ON_FTRACE */ #else /* !CONFIG_KPROBES_ON_FTRACE */
static inline int prepare_kprobe(struct kprobe *p)
{
return arch_prepare_kprobe(p);
}
static inline int arm_kprobe_ftrace(struct kprobe *p) static inline int arm_kprobe_ftrace(struct kprobe *p)
{ {
return -ENODEV; return -ENODEV;
...@@ -1129,6 +1115,15 @@ static inline int disarm_kprobe_ftrace(struct kprobe *p) ...@@ -1129,6 +1115,15 @@ static inline int disarm_kprobe_ftrace(struct kprobe *p)
} }
#endif #endif
static int prepare_kprobe(struct kprobe *p)
{
/* Must ensure p->addr is really on ftrace */
if (kprobe_ftrace(p))
return arch_prepare_kprobe_ftrace(p);
return arch_prepare_kprobe(p);
}
/* Arm a kprobe with text_mutex */ /* Arm a kprobe with text_mutex */
static int arm_kprobe(struct kprobe *kp) static int arm_kprobe(struct kprobe *kp)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment