|
@@ -42,7 +42,6 @@ struct trace_kprobe {
|
|
(offsetof(struct trace_kprobe, tp.args) + \
|
|
(offsetof(struct trace_kprobe, tp.args) + \
|
|
(sizeof(struct probe_arg) * (n)))
|
|
(sizeof(struct probe_arg) * (n)))
|
|
|
|
|
|
-DEFINE_PER_CPU(int, bpf_kprobe_override);
|
|
|
|
|
|
|
|
static nokprobe_inline bool trace_kprobe_is_return(struct trace_kprobe *tk)
|
|
static nokprobe_inline bool trace_kprobe_is_return(struct trace_kprobe *tk)
|
|
{
|
|
{
|
|
@@ -88,12 +87,6 @@ static nokprobe_inline unsigned long trace_kprobe_nhit(struct trace_kprobe *tk)
|
|
return nhit;
|
|
return nhit;
|
|
}
|
|
}
|
|
|
|
|
|
-int trace_kprobe_ftrace(struct trace_event_call *call)
|
|
|
|
-{
|
|
|
|
- struct trace_kprobe *tk = (struct trace_kprobe *)call->data;
|
|
|
|
- return kprobe_ftrace(&tk->rp.kp);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static int register_kprobe_event(struct trace_kprobe *tk);
|
|
static int register_kprobe_event(struct trace_kprobe *tk);
|
|
static int unregister_kprobe_event(struct trace_kprobe *tk);
|
|
static int unregister_kprobe_event(struct trace_kprobe *tk);
|
|
|
|
|
|
@@ -1177,7 +1170,7 @@ static int kretprobe_event_define_fields(struct trace_event_call *event_call)
|
|
#ifdef CONFIG_PERF_EVENTS
|
|
#ifdef CONFIG_PERF_EVENTS
|
|
|
|
|
|
/* Kprobe profile handler */
|
|
/* Kprobe profile handler */
|
|
-static int
|
|
|
|
|
|
+static void
|
|
kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
|
|
kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
|
|
{
|
|
{
|
|
struct trace_event_call *call = &tk->tp.call;
|
|
struct trace_event_call *call = &tk->tp.call;
|
|
@@ -1186,29 +1179,12 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
|
|
int size, __size, dsize;
|
|
int size, __size, dsize;
|
|
int rctx;
|
|
int rctx;
|
|
|
|
|
|
- if (bpf_prog_array_valid(call)) {
|
|
|
|
- int ret;
|
|
|
|
-
|
|
|
|
- ret = trace_call_bpf(call, regs);
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * We need to check and see if we modified the pc of the
|
|
|
|
- * pt_regs, and if so clear the kprobe and return 1 so that we
|
|
|
|
- * don't do the instruction skipping. Also reset our state so
|
|
|
|
- * we are clean the next pass through.
|
|
|
|
- */
|
|
|
|
- if (__this_cpu_read(bpf_kprobe_override)) {
|
|
|
|
- __this_cpu_write(bpf_kprobe_override, 0);
|
|
|
|
- reset_current_kprobe();
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
- if (!ret)
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
|
|
+ if (bpf_prog_array_valid(call) && !trace_call_bpf(call, regs))
|
|
|
|
+ return;
|
|
|
|
|
|
head = this_cpu_ptr(call->perf_events);
|
|
head = this_cpu_ptr(call->perf_events);
|
|
if (hlist_empty(head))
|
|
if (hlist_empty(head))
|
|
- return 0;
|
|
|
|
|
|
+ return;
|
|
|
|
|
|
dsize = __get_data_size(&tk->tp, regs);
|
|
dsize = __get_data_size(&tk->tp, regs);
|
|
__size = sizeof(*entry) + tk->tp.size + dsize;
|
|
__size = sizeof(*entry) + tk->tp.size + dsize;
|
|
@@ -1217,14 +1193,13 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
|
|
|
|
|
|
entry = perf_trace_buf_alloc(size, NULL, &rctx);
|
|
entry = perf_trace_buf_alloc(size, NULL, &rctx);
|
|
if (!entry)
|
|
if (!entry)
|
|
- return 0;
|
|
|
|
|
|
+ return;
|
|
|
|
|
|
entry->ip = (unsigned long)tk->rp.kp.addr;
|
|
entry->ip = (unsigned long)tk->rp.kp.addr;
|
|
memset(&entry[1], 0, dsize);
|
|
memset(&entry[1], 0, dsize);
|
|
store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize);
|
|
store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize);
|
|
perf_trace_buf_submit(entry, size, rctx, call->event.type, 1, regs,
|
|
perf_trace_buf_submit(entry, size, rctx, call->event.type, 1, regs,
|
|
head, NULL, NULL);
|
|
head, NULL, NULL);
|
|
- return 0;
|
|
|
|
}
|
|
}
|
|
NOKPROBE_SYMBOL(kprobe_perf_func);
|
|
NOKPROBE_SYMBOL(kprobe_perf_func);
|
|
|
|
|
|
@@ -1300,7 +1275,6 @@ static int kprobe_register(struct trace_event_call *event,
|
|
static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs)
|
|
static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs)
|
|
{
|
|
{
|
|
struct trace_kprobe *tk = container_of(kp, struct trace_kprobe, rp.kp);
|
|
struct trace_kprobe *tk = container_of(kp, struct trace_kprobe, rp.kp);
|
|
- int ret = 0;
|
|
|
|
|
|
|
|
raw_cpu_inc(*tk->nhit);
|
|
raw_cpu_inc(*tk->nhit);
|
|
|
|
|
|
@@ -1308,9 +1282,9 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs)
|
|
kprobe_trace_func(tk, regs);
|
|
kprobe_trace_func(tk, regs);
|
|
#ifdef CONFIG_PERF_EVENTS
|
|
#ifdef CONFIG_PERF_EVENTS
|
|
if (tk->tp.flags & TP_FLAG_PROFILE)
|
|
if (tk->tp.flags & TP_FLAG_PROFILE)
|
|
- ret = kprobe_perf_func(tk, regs);
|
|
|
|
|
|
+ kprobe_perf_func(tk, regs);
|
|
#endif
|
|
#endif
|
|
- return ret;
|
|
|
|
|
|
+ return 0; /* We don't tweek kernel, so just return 0 */
|
|
}
|
|
}
|
|
NOKPROBE_SYMBOL(kprobe_dispatcher);
|
|
NOKPROBE_SYMBOL(kprobe_dispatcher);
|
|
|
|
|