Commit bf7a87f1 authored by Jiri Olsa's avatar Jiri Olsa Committed by Alexei Starovoitov

kprobes: Add new KPROBE_FLAG_ON_FUNC_ENTRY kprobe flag

Adding KPROBE_FLAG_ON_FUNC_ENTRY kprobe flag to indicate that
attach address is on function entry. This is used in following
changes in get_func_ip helper to return correct function address.
Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20220926153340.1621984-2-jolsa@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent bec21719
...@@ -103,6 +103,7 @@ struct kprobe { ...@@ -103,6 +103,7 @@ struct kprobe {
* this flag is only for optimized_kprobe. * this flag is only for optimized_kprobe.
*/ */
#define KPROBE_FLAG_FTRACE 8 /* probe is using ftrace */ #define KPROBE_FLAG_FTRACE 8 /* probe is using ftrace */
#define KPROBE_FLAG_ON_FUNC_ENTRY 16 /* probe is on the function entry */
/* Has this kprobe gone ? */ /* Has this kprobe gone ? */
static inline bool kprobe_gone(struct kprobe *p) static inline bool kprobe_gone(struct kprobe *p)
......
...@@ -1606,9 +1606,10 @@ int register_kprobe(struct kprobe *p) ...@@ -1606,9 +1606,10 @@ int register_kprobe(struct kprobe *p)
struct kprobe *old_p; struct kprobe *old_p;
struct module *probed_mod; struct module *probed_mod;
kprobe_opcode_t *addr; kprobe_opcode_t *addr;
bool on_func_entry;
/* Adjust probe address from symbol */ /* Adjust probe address from symbol */
addr = kprobe_addr(p); addr = _kprobe_addr(p->addr, p->symbol_name, p->offset, &on_func_entry);
if (IS_ERR(addr)) if (IS_ERR(addr))
return PTR_ERR(addr); return PTR_ERR(addr);
p->addr = addr; p->addr = addr;
...@@ -1628,6 +1629,9 @@ int register_kprobe(struct kprobe *p) ...@@ -1628,6 +1629,9 @@ int register_kprobe(struct kprobe *p)
mutex_lock(&kprobe_mutex); mutex_lock(&kprobe_mutex);
if (on_func_entry)
p->flags |= KPROBE_FLAG_ON_FUNC_ENTRY;
old_p = get_kprobe(p->addr); old_p = get_kprobe(p->addr);
if (old_p) { if (old_p) {
/* Since this may unoptimize 'old_p', locking 'text_mutex'. */ /* Since this may unoptimize 'old_p', locking 'text_mutex'. */
......
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