Commit | Line | Data |
---|---|---|
413d37d1 | 1 | /* |
77b44d1b | 2 | * Kprobes-based tracing events |
413d37d1 MH |
3 | * |
4 | * Created by Masami Hiramatsu <mhiramat@redhat.com> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 as | |
8 | * published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | */ | |
19 | ||
20 | #include <linux/module.h> | |
21 | #include <linux/uaccess.h> | |
413d37d1 | 22 | |
8ab83f56 | 23 | #include "trace_probe.h" |
1ff511e3 | 24 | |
8ab83f56 | 25 | #define KPROBE_EVENT_SYSTEM "kprobes" |
e09c8614 | 26 | |
413d37d1 | 27 | /** |
77b44d1b | 28 | * Kprobe event core functions |
413d37d1 | 29 | */ |
c31ffb3f | 30 | struct trace_kprobe { |
413d37d1 | 31 | struct list_head list; |
4a846b44 | 32 | struct kretprobe rp; /* Use rp.kp for kprobe use */ |
cd7e7bd5 | 33 | unsigned long nhit; |
413d37d1 | 34 | const char *symbol; /* symbol name */ |
c31ffb3f | 35 | struct trace_probe tp; |
413d37d1 MH |
36 | }; |
37 | ||
b04d52e3 ON |
38 | struct event_file_link { |
39 | struct ftrace_event_file *file; | |
40 | struct list_head list; | |
41 | }; | |
42 | ||
c31ffb3f NK |
43 | #define SIZEOF_TRACE_KPROBE(n) \ |
44 | (offsetof(struct trace_kprobe, tp.args) + \ | |
eca0d916 | 45 | (sizeof(struct probe_arg) * (n))) |
a82378d8 | 46 | |
93ccae7a | 47 | |
c31ffb3f | 48 | static __kprobes bool trace_kprobe_is_return(struct trace_kprobe *tk) |
413d37d1 | 49 | { |
c31ffb3f | 50 | return tk->rp.handler != NULL; |
413d37d1 MH |
51 | } |
52 | ||
c31ffb3f | 53 | static __kprobes const char *trace_kprobe_symbol(struct trace_kprobe *tk) |
413d37d1 | 54 | { |
c31ffb3f | 55 | return tk->symbol ? tk->symbol : "unknown"; |
413d37d1 MH |
56 | } |
57 | ||
c31ffb3f | 58 | static __kprobes unsigned long trace_kprobe_offset(struct trace_kprobe *tk) |
61424318 | 59 | { |
c31ffb3f | 60 | return tk->rp.kp.offset; |
61424318 MH |
61 | } |
62 | ||
c31ffb3f | 63 | static __kprobes bool trace_kprobe_has_gone(struct trace_kprobe *tk) |
61424318 | 64 | { |
c31ffb3f | 65 | return !!(kprobe_gone(&tk->rp.kp)); |
61424318 MH |
66 | } |
67 | ||
c31ffb3f NK |
68 | static __kprobes bool trace_kprobe_within_module(struct trace_kprobe *tk, |
69 | struct module *mod) | |
61424318 MH |
70 | { |
71 | int len = strlen(mod->name); | |
c31ffb3f | 72 | const char *name = trace_kprobe_symbol(tk); |
61424318 MH |
73 | return strncmp(mod->name, name, len) == 0 && name[len] == ':'; |
74 | } | |
75 | ||
c31ffb3f | 76 | static __kprobes bool trace_kprobe_is_on_module(struct trace_kprobe *tk) |
61424318 | 77 | { |
c31ffb3f | 78 | return !!strchr(trace_kprobe_symbol(tk), ':'); |
61424318 MH |
79 | } |
80 | ||
c31ffb3f NK |
81 | static int register_kprobe_event(struct trace_kprobe *tk); |
82 | static int unregister_kprobe_event(struct trace_kprobe *tk); | |
413d37d1 MH |
83 | |
84 | static DEFINE_MUTEX(probe_lock); | |
85 | static LIST_HEAD(probe_list); | |
86 | ||
50d78056 MH |
87 | static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs); |
88 | static int kretprobe_dispatcher(struct kretprobe_instance *ri, | |
89 | struct pt_regs *regs); | |
90 | ||
1301a44e NK |
91 | /* Memory fetching by symbol */ |
92 | struct symbol_cache { | |
93 | char *symbol; | |
94 | long offset; | |
95 | unsigned long addr; | |
96 | }; | |
97 | ||
98 | unsigned long update_symbol_cache(struct symbol_cache *sc) | |
99 | { | |
100 | sc->addr = (unsigned long)kallsyms_lookup_name(sc->symbol); | |
101 | ||
102 | if (sc->addr) | |
103 | sc->addr += sc->offset; | |
104 | ||
105 | return sc->addr; | |
106 | } | |
107 | ||
108 | void free_symbol_cache(struct symbol_cache *sc) | |
109 | { | |
110 | kfree(sc->symbol); | |
111 | kfree(sc); | |
112 | } | |
113 | ||
114 | struct symbol_cache *alloc_symbol_cache(const char *sym, long offset) | |
115 | { | |
116 | struct symbol_cache *sc; | |
117 | ||
118 | if (!sym || strlen(sym) == 0) | |
119 | return NULL; | |
120 | ||
121 | sc = kzalloc(sizeof(struct symbol_cache), GFP_KERNEL); | |
122 | if (!sc) | |
123 | return NULL; | |
124 | ||
125 | sc->symbol = kstrdup(sym, GFP_KERNEL); | |
126 | if (!sc->symbol) { | |
127 | kfree(sc); | |
128 | return NULL; | |
129 | } | |
130 | sc->offset = offset; | |
131 | update_symbol_cache(sc); | |
132 | ||
133 | return sc; | |
134 | } | |
135 | ||
3fd996a2 NK |
136 | /* |
137 | * Kprobes-specific fetch functions | |
138 | */ | |
139 | #define DEFINE_FETCH_stack(type) \ | |
140 | static __kprobes void FETCH_FUNC_NAME(stack, type)(struct pt_regs *regs,\ | |
141 | void *offset, void *dest) \ | |
142 | { \ | |
143 | *(type *)dest = (type)regs_get_kernel_stack_nth(regs, \ | |
144 | (unsigned int)((unsigned long)offset)); \ | |
145 | } | |
146 | DEFINE_BASIC_FETCH_FUNCS(stack) | |
147 | /* No string on the stack entry */ | |
148 | #define fetch_stack_string NULL | |
149 | #define fetch_stack_string_size NULL | |
150 | ||
1301a44e NK |
151 | #define DEFINE_FETCH_symbol(type) \ |
152 | __kprobes void FETCH_FUNC_NAME(symbol, type)(struct pt_regs *regs, \ | |
153 | void *data, void *dest) \ | |
154 | { \ | |
155 | struct symbol_cache *sc = data; \ | |
156 | if (sc->addr) \ | |
157 | fetch_memory_##type(regs, (void *)sc->addr, dest); \ | |
158 | else \ | |
159 | *(type *)dest = 0; \ | |
160 | } | |
161 | DEFINE_BASIC_FETCH_FUNCS(symbol) | |
162 | DEFINE_FETCH_symbol(string) | |
163 | DEFINE_FETCH_symbol(string_size) | |
164 | ||
34fee3a1 NK |
165 | /* Fetch type information table */ |
166 | const struct fetch_type kprobes_fetch_type_table[] = { | |
167 | /* Special types */ | |
168 | [FETCH_TYPE_STRING] = __ASSIGN_FETCH_TYPE("string", string, string, | |
169 | sizeof(u32), 1, "__data_loc char[]"), | |
170 | [FETCH_TYPE_STRSIZE] = __ASSIGN_FETCH_TYPE("string_size", u32, | |
171 | string_size, sizeof(u32), 0, "u32"), | |
172 | /* Basic types */ | |
173 | ASSIGN_FETCH_TYPE(u8, u8, 0), | |
174 | ASSIGN_FETCH_TYPE(u16, u16, 0), | |
175 | ASSIGN_FETCH_TYPE(u32, u32, 0), | |
176 | ASSIGN_FETCH_TYPE(u64, u64, 0), | |
177 | ASSIGN_FETCH_TYPE(s8, u8, 1), | |
178 | ASSIGN_FETCH_TYPE(s16, u16, 1), | |
179 | ASSIGN_FETCH_TYPE(s32, u32, 1), | |
180 | ASSIGN_FETCH_TYPE(s64, u64, 1), | |
181 | ||
182 | ASSIGN_FETCH_TYPE_END | |
183 | }; | |
184 | ||
4a846b44 MH |
185 | /* |
186 | * Allocate new trace_probe and initialize it (including kprobes). | |
187 | */ | |
c31ffb3f | 188 | static struct trace_kprobe *alloc_trace_kprobe(const char *group, |
f52487e9 | 189 | const char *event, |
4a846b44 MH |
190 | void *addr, |
191 | const char *symbol, | |
192 | unsigned long offs, | |
3a6b7666 | 193 | int nargs, bool is_return) |
413d37d1 | 194 | { |
c31ffb3f | 195 | struct trace_kprobe *tk; |
6f3cf440 | 196 | int ret = -ENOMEM; |
413d37d1 | 197 | |
c31ffb3f NK |
198 | tk = kzalloc(SIZEOF_TRACE_KPROBE(nargs), GFP_KERNEL); |
199 | if (!tk) | |
6f3cf440 | 200 | return ERR_PTR(ret); |
413d37d1 MH |
201 | |
202 | if (symbol) { | |
c31ffb3f NK |
203 | tk->symbol = kstrdup(symbol, GFP_KERNEL); |
204 | if (!tk->symbol) | |
413d37d1 | 205 | goto error; |
c31ffb3f NK |
206 | tk->rp.kp.symbol_name = tk->symbol; |
207 | tk->rp.kp.offset = offs; | |
4a846b44 | 208 | } else |
c31ffb3f | 209 | tk->rp.kp.addr = addr; |
4a846b44 MH |
210 | |
211 | if (is_return) | |
c31ffb3f | 212 | tk->rp.handler = kretprobe_dispatcher; |
4a846b44 | 213 | else |
c31ffb3f | 214 | tk->rp.kp.pre_handler = kprobe_dispatcher; |
4a846b44 | 215 | |
da34634f | 216 | if (!event || !is_good_name(event)) { |
6f3cf440 | 217 | ret = -EINVAL; |
4263565d | 218 | goto error; |
6f3cf440 MH |
219 | } |
220 | ||
c31ffb3f NK |
221 | tk->tp.call.class = &tk->tp.class; |
222 | tk->tp.call.name = kstrdup(event, GFP_KERNEL); | |
223 | if (!tk->tp.call.name) | |
4263565d | 224 | goto error; |
413d37d1 | 225 | |
da34634f | 226 | if (!group || !is_good_name(group)) { |
6f3cf440 | 227 | ret = -EINVAL; |
f52487e9 | 228 | goto error; |
6f3cf440 MH |
229 | } |
230 | ||
c31ffb3f NK |
231 | tk->tp.class.system = kstrdup(group, GFP_KERNEL); |
232 | if (!tk->tp.class.system) | |
f52487e9 MH |
233 | goto error; |
234 | ||
c31ffb3f NK |
235 | INIT_LIST_HEAD(&tk->list); |
236 | INIT_LIST_HEAD(&tk->tp.files); | |
237 | return tk; | |
413d37d1 | 238 | error: |
c31ffb3f NK |
239 | kfree(tk->tp.call.name); |
240 | kfree(tk->symbol); | |
241 | kfree(tk); | |
6f3cf440 | 242 | return ERR_PTR(ret); |
413d37d1 MH |
243 | } |
244 | ||
c31ffb3f | 245 | static void free_trace_kprobe(struct trace_kprobe *tk) |
413d37d1 MH |
246 | { |
247 | int i; | |
248 | ||
c31ffb3f NK |
249 | for (i = 0; i < tk->tp.nr_args; i++) |
250 | traceprobe_free_probe_arg(&tk->tp.args[i]); | |
413d37d1 | 251 | |
c31ffb3f NK |
252 | kfree(tk->tp.call.class->system); |
253 | kfree(tk->tp.call.name); | |
254 | kfree(tk->symbol); | |
255 | kfree(tk); | |
413d37d1 MH |
256 | } |
257 | ||
c31ffb3f NK |
258 | static struct trace_kprobe *find_trace_kprobe(const char *event, |
259 | const char *group) | |
413d37d1 | 260 | { |
c31ffb3f | 261 | struct trace_kprobe *tk; |
413d37d1 | 262 | |
c31ffb3f NK |
263 | list_for_each_entry(tk, &probe_list, list) |
264 | if (strcmp(tk->tp.call.name, event) == 0 && | |
265 | strcmp(tk->tp.call.class->system, group) == 0) | |
266 | return tk; | |
413d37d1 MH |
267 | return NULL; |
268 | } | |
269 | ||
41a7dd42 MH |
270 | /* |
271 | * Enable trace_probe | |
272 | * if the file is NULL, enable "perf" handler, or enable "trace" handler. | |
273 | */ | |
274 | static int | |
c31ffb3f | 275 | enable_trace_kprobe(struct trace_kprobe *tk, struct ftrace_event_file *file) |
1538f888 MH |
276 | { |
277 | int ret = 0; | |
278 | ||
41a7dd42 | 279 | if (file) { |
b04d52e3 ON |
280 | struct event_file_link *link; |
281 | ||
282 | link = kmalloc(sizeof(*link), GFP_KERNEL); | |
283 | if (!link) { | |
41a7dd42 | 284 | ret = -ENOMEM; |
3fe3d619 | 285 | goto out; |
41a7dd42 | 286 | } |
41a7dd42 | 287 | |
b04d52e3 | 288 | link->file = file; |
c31ffb3f | 289 | list_add_tail_rcu(&link->list, &tk->tp.files); |
41a7dd42 | 290 | |
c31ffb3f | 291 | tk->tp.flags |= TP_FLAG_TRACE; |
41a7dd42 | 292 | } else |
c31ffb3f | 293 | tk->tp.flags |= TP_FLAG_PROFILE; |
41a7dd42 | 294 | |
c31ffb3f NK |
295 | if (trace_probe_is_registered(&tk->tp) && !trace_kprobe_has_gone(tk)) { |
296 | if (trace_kprobe_is_return(tk)) | |
297 | ret = enable_kretprobe(&tk->rp); | |
1538f888 | 298 | else |
c31ffb3f | 299 | ret = enable_kprobe(&tk->rp.kp); |
1538f888 | 300 | } |
3fe3d619 | 301 | out: |
1538f888 MH |
302 | return ret; |
303 | } | |
304 | ||
b04d52e3 ON |
305 | static struct event_file_link * |
306 | find_event_file_link(struct trace_probe *tp, struct ftrace_event_file *file) | |
41a7dd42 | 307 | { |
b04d52e3 | 308 | struct event_file_link *link; |
41a7dd42 | 309 | |
b04d52e3 ON |
310 | list_for_each_entry(link, &tp->files, list) |
311 | if (link->file == file) | |
312 | return link; | |
41a7dd42 | 313 | |
b04d52e3 | 314 | return NULL; |
41a7dd42 MH |
315 | } |
316 | ||
317 | /* | |
318 | * Disable trace_probe | |
319 | * if the file is NULL, disable "perf" handler, or disable "trace" handler. | |
320 | */ | |
321 | static int | |
c31ffb3f | 322 | disable_trace_kprobe(struct trace_kprobe *tk, struct ftrace_event_file *file) |
1538f888 | 323 | { |
a232e270 MH |
324 | struct event_file_link *link = NULL; |
325 | int wait = 0; | |
41a7dd42 MH |
326 | int ret = 0; |
327 | ||
41a7dd42 | 328 | if (file) { |
c31ffb3f | 329 | link = find_event_file_link(&tk->tp, file); |
b04d52e3 | 330 | if (!link) { |
41a7dd42 | 331 | ret = -EINVAL; |
3fe3d619 | 332 | goto out; |
41a7dd42 MH |
333 | } |
334 | ||
b04d52e3 | 335 | list_del_rcu(&link->list); |
a232e270 | 336 | wait = 1; |
c31ffb3f | 337 | if (!list_empty(&tk->tp.files)) |
b04d52e3 | 338 | goto out; |
41a7dd42 | 339 | |
c31ffb3f | 340 | tk->tp.flags &= ~TP_FLAG_TRACE; |
41a7dd42 | 341 | } else |
c31ffb3f | 342 | tk->tp.flags &= ~TP_FLAG_PROFILE; |
41a7dd42 | 343 | |
c31ffb3f NK |
344 | if (!trace_probe_is_enabled(&tk->tp) && trace_probe_is_registered(&tk->tp)) { |
345 | if (trace_kprobe_is_return(tk)) | |
346 | disable_kretprobe(&tk->rp); | |
1538f888 | 347 | else |
c31ffb3f | 348 | disable_kprobe(&tk->rp.kp); |
a232e270 | 349 | wait = 1; |
1538f888 | 350 | } |
3fe3d619 | 351 | out: |
a232e270 MH |
352 | if (wait) { |
353 | /* | |
354 | * Synchronize with kprobe_trace_func/kretprobe_trace_func | |
355 | * to ensure disabled (all running handlers are finished). | |
356 | * This is not only for kfree(), but also the caller, | |
357 | * trace_remove_event_call() supposes it for releasing | |
358 | * event_call related objects, which will be accessed in | |
359 | * the kprobe_trace_func/kretprobe_trace_func. | |
360 | */ | |
361 | synchronize_sched(); | |
362 | kfree(link); /* Ignored if link == NULL */ | |
363 | } | |
364 | ||
41a7dd42 | 365 | return ret; |
1538f888 MH |
366 | } |
367 | ||
61424318 | 368 | /* Internal register function - just handle k*probes and flags */ |
c31ffb3f | 369 | static int __register_trace_kprobe(struct trace_kprobe *tk) |
413d37d1 | 370 | { |
7f6878a3 | 371 | int i, ret; |
61424318 | 372 | |
c31ffb3f | 373 | if (trace_probe_is_registered(&tk->tp)) |
61424318 MH |
374 | return -EINVAL; |
375 | ||
c31ffb3f NK |
376 | for (i = 0; i < tk->tp.nr_args; i++) |
377 | traceprobe_update_arg(&tk->tp.args[i]); | |
7f6878a3 | 378 | |
61424318 | 379 | /* Set/clear disabled flag according to tp->flag */ |
c31ffb3f NK |
380 | if (trace_probe_is_enabled(&tk->tp)) |
381 | tk->rp.kp.flags &= ~KPROBE_FLAG_DISABLED; | |
61424318 | 382 | else |
c31ffb3f | 383 | tk->rp.kp.flags |= KPROBE_FLAG_DISABLED; |
61424318 | 384 | |
c31ffb3f NK |
385 | if (trace_kprobe_is_return(tk)) |
386 | ret = register_kretprobe(&tk->rp); | |
413d37d1 | 387 | else |
c31ffb3f | 388 | ret = register_kprobe(&tk->rp.kp); |
61424318 MH |
389 | |
390 | if (ret == 0) | |
c31ffb3f | 391 | tk->tp.flags |= TP_FLAG_REGISTERED; |
61424318 MH |
392 | else { |
393 | pr_warning("Could not insert probe at %s+%lu: %d\n", | |
c31ffb3f NK |
394 | trace_kprobe_symbol(tk), trace_kprobe_offset(tk), ret); |
395 | if (ret == -ENOENT && trace_kprobe_is_on_module(tk)) { | |
61424318 MH |
396 | pr_warning("This probe might be able to register after" |
397 | "target module is loaded. Continue.\n"); | |
398 | ret = 0; | |
399 | } else if (ret == -EILSEQ) { | |
400 | pr_warning("Probing address(0x%p) is not an " | |
401 | "instruction boundary.\n", | |
c31ffb3f | 402 | tk->rp.kp.addr); |
61424318 MH |
403 | ret = -EINVAL; |
404 | } | |
405 | } | |
406 | ||
407 | return ret; | |
408 | } | |
409 | ||
410 | /* Internal unregister function - just handle k*probes and flags */ | |
c31ffb3f | 411 | static void __unregister_trace_kprobe(struct trace_kprobe *tk) |
61424318 | 412 | { |
c31ffb3f NK |
413 | if (trace_probe_is_registered(&tk->tp)) { |
414 | if (trace_kprobe_is_return(tk)) | |
415 | unregister_kretprobe(&tk->rp); | |
61424318 | 416 | else |
c31ffb3f NK |
417 | unregister_kprobe(&tk->rp.kp); |
418 | tk->tp.flags &= ~TP_FLAG_REGISTERED; | |
61424318 | 419 | /* Cleanup kprobe for reuse */ |
c31ffb3f NK |
420 | if (tk->rp.kp.symbol_name) |
421 | tk->rp.kp.addr = NULL; | |
61424318 MH |
422 | } |
423 | } | |
424 | ||
425 | /* Unregister a trace_probe and probe_event: call with locking probe_lock */ | |
c31ffb3f | 426 | static int unregister_trace_kprobe(struct trace_kprobe *tk) |
61424318 | 427 | { |
02ca1521 | 428 | /* Enabled event can not be unregistered */ |
c31ffb3f | 429 | if (trace_probe_is_enabled(&tk->tp)) |
02ca1521 MH |
430 | return -EBUSY; |
431 | ||
40c32592 | 432 | /* Will fail if probe is being used by ftrace or perf */ |
c31ffb3f | 433 | if (unregister_kprobe_event(tk)) |
40c32592 SRRH |
434 | return -EBUSY; |
435 | ||
c31ffb3f NK |
436 | __unregister_trace_kprobe(tk); |
437 | list_del(&tk->list); | |
02ca1521 MH |
438 | |
439 | return 0; | |
413d37d1 MH |
440 | } |
441 | ||
442 | /* Register a trace_probe and probe_event */ | |
c31ffb3f | 443 | static int register_trace_kprobe(struct trace_kprobe *tk) |
413d37d1 | 444 | { |
c31ffb3f | 445 | struct trace_kprobe *old_tk; |
413d37d1 MH |
446 | int ret; |
447 | ||
448 | mutex_lock(&probe_lock); | |
449 | ||
61424318 | 450 | /* Delete old (same name) event if exist */ |
c31ffb3f NK |
451 | old_tk = find_trace_kprobe(tk->tp.call.name, tk->tp.call.class->system); |
452 | if (old_tk) { | |
453 | ret = unregister_trace_kprobe(old_tk); | |
02ca1521 MH |
454 | if (ret < 0) |
455 | goto end; | |
c31ffb3f | 456 | free_trace_kprobe(old_tk); |
2d5e067e | 457 | } |
61424318 MH |
458 | |
459 | /* Register new event */ | |
c31ffb3f | 460 | ret = register_kprobe_event(tk); |
2d5e067e | 461 | if (ret) { |
426d3107 | 462 | pr_warning("Failed to register probe event(%d)\n", ret); |
2d5e067e MH |
463 | goto end; |
464 | } | |
465 | ||
61424318 | 466 | /* Register k*probe */ |
c31ffb3f | 467 | ret = __register_trace_kprobe(tk); |
61424318 | 468 | if (ret < 0) |
c31ffb3f | 469 | unregister_kprobe_event(tk); |
61424318 | 470 | else |
c31ffb3f | 471 | list_add_tail(&tk->list, &probe_list); |
61424318 | 472 | |
413d37d1 MH |
473 | end: |
474 | mutex_unlock(&probe_lock); | |
475 | return ret; | |
476 | } | |
477 | ||
61424318 | 478 | /* Module notifier call back, checking event on the module */ |
c31ffb3f | 479 | static int trace_kprobe_module_callback(struct notifier_block *nb, |
61424318 MH |
480 | unsigned long val, void *data) |
481 | { | |
482 | struct module *mod = data; | |
c31ffb3f | 483 | struct trace_kprobe *tk; |
61424318 MH |
484 | int ret; |
485 | ||
486 | if (val != MODULE_STATE_COMING) | |
487 | return NOTIFY_DONE; | |
488 | ||
489 | /* Update probes on coming module */ | |
490 | mutex_lock(&probe_lock); | |
c31ffb3f NK |
491 | list_for_each_entry(tk, &probe_list, list) { |
492 | if (trace_kprobe_within_module(tk, mod)) { | |
02ca1521 | 493 | /* Don't need to check busy - this should have gone. */ |
c31ffb3f NK |
494 | __unregister_trace_kprobe(tk); |
495 | ret = __register_trace_kprobe(tk); | |
61424318 MH |
496 | if (ret) |
497 | pr_warning("Failed to re-register probe %s on" | |
498 | "%s: %d\n", | |
c31ffb3f | 499 | tk->tp.call.name, mod->name, ret); |
61424318 MH |
500 | } |
501 | } | |
502 | mutex_unlock(&probe_lock); | |
503 | ||
504 | return NOTIFY_DONE; | |
505 | } | |
506 | ||
c31ffb3f NK |
507 | static struct notifier_block trace_kprobe_module_nb = { |
508 | .notifier_call = trace_kprobe_module_callback, | |
61424318 MH |
509 | .priority = 1 /* Invoked after kprobe module callback */ |
510 | }; | |
511 | ||
c31ffb3f | 512 | static int create_trace_kprobe(int argc, char **argv) |
413d37d1 MH |
513 | { |
514 | /* | |
515 | * Argument syntax: | |
61424318 MH |
516 | * - Add kprobe: p[:[GRP/]EVENT] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS] |
517 | * - Add kretprobe: r[:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS] | |
413d37d1 | 518 | * Fetch args: |
2e06ff63 MH |
519 | * $retval : fetch return value |
520 | * $stack : fetch stack address | |
521 | * $stackN : fetch Nth of stack (N:0-) | |
413d37d1 MH |
522 | * @ADDR : fetch memory at ADDR (ADDR should be in kernel) |
523 | * @SYM[+|-offs] : fetch memory at SYM +|- offs (SYM is a data symbol) | |
524 | * %REG : fetch register REG | |
93ccae7a | 525 | * Dereferencing memory fetch: |
413d37d1 | 526 | * +|-offs(ARG) : fetch memory at ARG +|- offs address. |
eca0d916 MH |
527 | * Alias name of args: |
528 | * NAME=FETCHARG : set NAME as alias of FETCHARG. | |
93ccae7a MH |
529 | * Type of args: |
530 | * FETCHARG:TYPE : use TYPE instead of unsigned long. | |
413d37d1 | 531 | */ |
c31ffb3f | 532 | struct trace_kprobe *tk; |
413d37d1 | 533 | int i, ret = 0; |
3a6b7666 | 534 | bool is_return = false, is_delete = false; |
93ccae7a | 535 | char *symbol = NULL, *event = NULL, *group = NULL; |
da34634f | 536 | char *arg; |
2fba0c88 | 537 | unsigned long offset = 0; |
413d37d1 | 538 | void *addr = NULL; |
4a846b44 | 539 | char buf[MAX_EVENT_NAME_LEN]; |
413d37d1 | 540 | |
a7c312be | 541 | /* argc must be >= 1 */ |
413d37d1 | 542 | if (argv[0][0] == 'p') |
3a6b7666 | 543 | is_return = false; |
413d37d1 | 544 | else if (argv[0][0] == 'r') |
3a6b7666 | 545 | is_return = true; |
a7c312be | 546 | else if (argv[0][0] == '-') |
3a6b7666 | 547 | is_delete = true; |
e63cc239 | 548 | else { |
a7c312be MH |
549 | pr_info("Probe definition must be started with 'p', 'r' or" |
550 | " '-'.\n"); | |
413d37d1 | 551 | return -EINVAL; |
e63cc239 | 552 | } |
413d37d1 MH |
553 | |
554 | if (argv[0][1] == ':') { | |
555 | event = &argv[0][2]; | |
f52487e9 MH |
556 | if (strchr(event, '/')) { |
557 | group = event; | |
558 | event = strchr(group, '/') + 1; | |
559 | event[-1] = '\0'; | |
560 | if (strlen(group) == 0) { | |
a5efd925 | 561 | pr_info("Group name is not specified\n"); |
f52487e9 MH |
562 | return -EINVAL; |
563 | } | |
564 | } | |
413d37d1 | 565 | if (strlen(event) == 0) { |
a5efd925 | 566 | pr_info("Event name is not specified\n"); |
413d37d1 MH |
567 | return -EINVAL; |
568 | } | |
569 | } | |
a7c312be MH |
570 | if (!group) |
571 | group = KPROBE_EVENT_SYSTEM; | |
413d37d1 | 572 | |
a7c312be MH |
573 | if (is_delete) { |
574 | if (!event) { | |
575 | pr_info("Delete command needs an event name.\n"); | |
576 | return -EINVAL; | |
577 | } | |
9da79ab8 | 578 | mutex_lock(&probe_lock); |
c31ffb3f NK |
579 | tk = find_trace_kprobe(event, group); |
580 | if (!tk) { | |
9da79ab8 | 581 | mutex_unlock(&probe_lock); |
a7c312be MH |
582 | pr_info("Event %s/%s doesn't exist.\n", group, event); |
583 | return -ENOENT; | |
584 | } | |
585 | /* delete an event */ | |
c31ffb3f | 586 | ret = unregister_trace_kprobe(tk); |
02ca1521 | 587 | if (ret == 0) |
c31ffb3f | 588 | free_trace_kprobe(tk); |
9da79ab8 | 589 | mutex_unlock(&probe_lock); |
02ca1521 | 590 | return ret; |
a7c312be MH |
591 | } |
592 | ||
593 | if (argc < 2) { | |
594 | pr_info("Probe point is not specified.\n"); | |
595 | return -EINVAL; | |
596 | } | |
413d37d1 | 597 | if (isdigit(argv[1][0])) { |
e63cc239 MH |
598 | if (is_return) { |
599 | pr_info("Return probe point must be a symbol.\n"); | |
413d37d1 | 600 | return -EINVAL; |
e63cc239 | 601 | } |
413d37d1 | 602 | /* an address specified */ |
bcd83ea6 | 603 | ret = kstrtoul(&argv[1][0], 0, (unsigned long *)&addr); |
e63cc239 MH |
604 | if (ret) { |
605 | pr_info("Failed to parse address.\n"); | |
413d37d1 | 606 | return ret; |
e63cc239 | 607 | } |
413d37d1 MH |
608 | } else { |
609 | /* a symbol specified */ | |
610 | symbol = argv[1]; | |
611 | /* TODO: support .init module functions */ | |
8ab83f56 | 612 | ret = traceprobe_split_symbol_offset(symbol, &offset); |
e63cc239 MH |
613 | if (ret) { |
614 | pr_info("Failed to parse symbol.\n"); | |
413d37d1 | 615 | return ret; |
e63cc239 MH |
616 | } |
617 | if (offset && is_return) { | |
618 | pr_info("Return probe must be used without offset.\n"); | |
413d37d1 | 619 | return -EINVAL; |
e63cc239 | 620 | } |
413d37d1 | 621 | } |
a82378d8 | 622 | argc -= 2; argv += 2; |
413d37d1 MH |
623 | |
624 | /* setup a probe */ | |
4263565d MH |
625 | if (!event) { |
626 | /* Make a new event name */ | |
4263565d | 627 | if (symbol) |
6f3cf440 | 628 | snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_%ld", |
4263565d MH |
629 | is_return ? 'r' : 'p', symbol, offset); |
630 | else | |
6f3cf440 | 631 | snprintf(buf, MAX_EVENT_NAME_LEN, "%c_0x%p", |
4263565d | 632 | is_return ? 'r' : 'p', addr); |
4a846b44 MH |
633 | event = buf; |
634 | } | |
c31ffb3f | 635 | tk = alloc_trace_kprobe(group, event, addr, symbol, offset, argc, |
f52487e9 | 636 | is_return); |
c31ffb3f | 637 | if (IS_ERR(tk)) { |
e63cc239 | 638 | pr_info("Failed to allocate trace_probe.(%d)\n", |
c31ffb3f NK |
639 | (int)PTR_ERR(tk)); |
640 | return PTR_ERR(tk); | |
e63cc239 | 641 | } |
413d37d1 | 642 | |
413d37d1 | 643 | /* parse arguments */ |
a82378d8 MH |
644 | ret = 0; |
645 | for (i = 0; i < argc && i < MAX_TRACE_ARGS; i++) { | |
c31ffb3f NK |
646 | struct probe_arg *parg = &tk->tp.args[i]; |
647 | ||
61a52736 | 648 | /* Increment count for freeing args in error case */ |
c31ffb3f | 649 | tk->tp.nr_args++; |
61a52736 | 650 | |
eca0d916 MH |
651 | /* Parse argument name */ |
652 | arg = strchr(argv[i], '='); | |
aba91595 | 653 | if (arg) { |
eca0d916 | 654 | *arg++ = '\0'; |
c31ffb3f | 655 | parg->name = kstrdup(argv[i], GFP_KERNEL); |
aba91595 | 656 | } else { |
eca0d916 | 657 | arg = argv[i]; |
aba91595 MH |
658 | /* If argument name is omitted, set "argN" */ |
659 | snprintf(buf, MAX_EVENT_NAME_LEN, "arg%d", i + 1); | |
c31ffb3f | 660 | parg->name = kstrdup(buf, GFP_KERNEL); |
aba91595 | 661 | } |
a703d946 | 662 | |
c31ffb3f | 663 | if (!parg->name) { |
aba91595 | 664 | pr_info("Failed to allocate argument[%d] name.\n", i); |
ba8665d7 | 665 | ret = -ENOMEM; |
413d37d1 MH |
666 | goto error; |
667 | } | |
da34634f | 668 | |
c31ffb3f | 669 | if (!is_good_name(parg->name)) { |
da34634f | 670 | pr_info("Invalid argument[%d] name: %s\n", |
c31ffb3f | 671 | i, parg->name); |
da34634f MH |
672 | ret = -EINVAL; |
673 | goto error; | |
674 | } | |
93ccae7a | 675 | |
c31ffb3f NK |
676 | if (traceprobe_conflict_field_name(parg->name, |
677 | tk->tp.args, i)) { | |
aba91595 | 678 | pr_info("Argument[%d] name '%s' conflicts with " |
93ccae7a MH |
679 | "another field.\n", i, argv[i]); |
680 | ret = -EINVAL; | |
681 | goto error; | |
682 | } | |
ba8665d7 MH |
683 | |
684 | /* Parse fetch argument */ | |
c31ffb3f | 685 | ret = traceprobe_parse_probe_arg(arg, &tk->tp.size, parg, |
f3f096cf | 686 | is_return, true); |
e63cc239 | 687 | if (ret) { |
aba91595 | 688 | pr_info("Parse error at argument[%d]. (%d)\n", i, ret); |
413d37d1 | 689 | goto error; |
e63cc239 | 690 | } |
413d37d1 | 691 | } |
413d37d1 | 692 | |
c31ffb3f | 693 | ret = register_trace_kprobe(tk); |
413d37d1 MH |
694 | if (ret) |
695 | goto error; | |
696 | return 0; | |
697 | ||
698 | error: | |
c31ffb3f | 699 | free_trace_kprobe(tk); |
413d37d1 MH |
700 | return ret; |
701 | } | |
702 | ||
c31ffb3f | 703 | static int release_all_trace_kprobes(void) |
413d37d1 | 704 | { |
c31ffb3f | 705 | struct trace_kprobe *tk; |
02ca1521 | 706 | int ret = 0; |
413d37d1 MH |
707 | |
708 | mutex_lock(&probe_lock); | |
02ca1521 | 709 | /* Ensure no probe is in use. */ |
c31ffb3f NK |
710 | list_for_each_entry(tk, &probe_list, list) |
711 | if (trace_probe_is_enabled(&tk->tp)) { | |
02ca1521 MH |
712 | ret = -EBUSY; |
713 | goto end; | |
714 | } | |
413d37d1 MH |
715 | /* TODO: Use batch unregistration */ |
716 | while (!list_empty(&probe_list)) { | |
c31ffb3f NK |
717 | tk = list_entry(probe_list.next, struct trace_kprobe, list); |
718 | ret = unregister_trace_kprobe(tk); | |
40c32592 SRRH |
719 | if (ret) |
720 | goto end; | |
c31ffb3f | 721 | free_trace_kprobe(tk); |
413d37d1 | 722 | } |
02ca1521 MH |
723 | |
724 | end: | |
413d37d1 | 725 | mutex_unlock(&probe_lock); |
02ca1521 MH |
726 | |
727 | return ret; | |
413d37d1 MH |
728 | } |
729 | ||
413d37d1 MH |
730 | /* Probes listing interfaces */ |
731 | static void *probes_seq_start(struct seq_file *m, loff_t *pos) | |
732 | { | |
733 | mutex_lock(&probe_lock); | |
734 | return seq_list_start(&probe_list, *pos); | |
735 | } | |
736 | ||
737 | static void *probes_seq_next(struct seq_file *m, void *v, loff_t *pos) | |
738 | { | |
739 | return seq_list_next(v, &probe_list, pos); | |
740 | } | |
741 | ||
742 | static void probes_seq_stop(struct seq_file *m, void *v) | |
743 | { | |
744 | mutex_unlock(&probe_lock); | |
745 | } | |
746 | ||
747 | static int probes_seq_show(struct seq_file *m, void *v) | |
748 | { | |
c31ffb3f | 749 | struct trace_kprobe *tk = v; |
93ccae7a | 750 | int i; |
413d37d1 | 751 | |
c31ffb3f NK |
752 | seq_printf(m, "%c", trace_kprobe_is_return(tk) ? 'r' : 'p'); |
753 | seq_printf(m, ":%s/%s", tk->tp.call.class->system, tk->tp.call.name); | |
413d37d1 | 754 | |
c31ffb3f NK |
755 | if (!tk->symbol) |
756 | seq_printf(m, " 0x%p", tk->rp.kp.addr); | |
757 | else if (tk->rp.kp.offset) | |
758 | seq_printf(m, " %s+%u", trace_kprobe_symbol(tk), | |
759 | tk->rp.kp.offset); | |
413d37d1 | 760 | else |
c31ffb3f | 761 | seq_printf(m, " %s", trace_kprobe_symbol(tk)); |
413d37d1 | 762 | |
c31ffb3f NK |
763 | for (i = 0; i < tk->tp.nr_args; i++) |
764 | seq_printf(m, " %s=%s", tk->tp.args[i].name, tk->tp.args[i].comm); | |
413d37d1 | 765 | seq_printf(m, "\n"); |
93ccae7a | 766 | |
413d37d1 MH |
767 | return 0; |
768 | } | |
769 | ||
770 | static const struct seq_operations probes_seq_op = { | |
771 | .start = probes_seq_start, | |
772 | .next = probes_seq_next, | |
773 | .stop = probes_seq_stop, | |
774 | .show = probes_seq_show | |
775 | }; | |
776 | ||
777 | static int probes_open(struct inode *inode, struct file *file) | |
778 | { | |
02ca1521 MH |
779 | int ret; |
780 | ||
781 | if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) { | |
c31ffb3f | 782 | ret = release_all_trace_kprobes(); |
02ca1521 MH |
783 | if (ret < 0) |
784 | return ret; | |
785 | } | |
413d37d1 MH |
786 | |
787 | return seq_open(file, &probes_seq_op); | |
788 | } | |
789 | ||
413d37d1 MH |
790 | static ssize_t probes_write(struct file *file, const char __user *buffer, |
791 | size_t count, loff_t *ppos) | |
792 | { | |
8ab83f56 | 793 | return traceprobe_probes_write(file, buffer, count, ppos, |
c31ffb3f | 794 | create_trace_kprobe); |
413d37d1 MH |
795 | } |
796 | ||
797 | static const struct file_operations kprobe_events_ops = { | |
798 | .owner = THIS_MODULE, | |
799 | .open = probes_open, | |
800 | .read = seq_read, | |
801 | .llseek = seq_lseek, | |
802 | .release = seq_release, | |
803 | .write = probes_write, | |
804 | }; | |
805 | ||
cd7e7bd5 MH |
806 | /* Probes profiling interfaces */ |
807 | static int probes_profile_seq_show(struct seq_file *m, void *v) | |
808 | { | |
c31ffb3f | 809 | struct trace_kprobe *tk = v; |
cd7e7bd5 | 810 | |
c31ffb3f NK |
811 | seq_printf(m, " %-44s %15lu %15lu\n", tk->tp.call.name, tk->nhit, |
812 | tk->rp.kp.nmissed); | |
cd7e7bd5 MH |
813 | |
814 | return 0; | |
815 | } | |
816 | ||
817 | static const struct seq_operations profile_seq_op = { | |
818 | .start = probes_seq_start, | |
819 | .next = probes_seq_next, | |
820 | .stop = probes_seq_stop, | |
821 | .show = probes_profile_seq_show | |
822 | }; | |
823 | ||
824 | static int profile_open(struct inode *inode, struct file *file) | |
825 | { | |
826 | return seq_open(file, &profile_seq_op); | |
827 | } | |
828 | ||
829 | static const struct file_operations kprobe_profile_ops = { | |
830 | .owner = THIS_MODULE, | |
831 | .open = profile_open, | |
832 | .read = seq_read, | |
833 | .llseek = seq_lseek, | |
834 | .release = seq_release, | |
835 | }; | |
836 | ||
413d37d1 | 837 | /* Kprobe handler */ |
2b106aab | 838 | static __kprobes void |
c31ffb3f | 839 | __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs, |
41a7dd42 | 840 | struct ftrace_event_file *ftrace_file) |
413d37d1 | 841 | { |
93ccae7a | 842 | struct kprobe_trace_entry_head *entry; |
413d37d1 | 843 | struct ring_buffer_event *event; |
8f8ffe24 | 844 | struct ring_buffer *buffer; |
e09c8614 | 845 | int size, dsize, pc; |
413d37d1 | 846 | unsigned long irq_flags; |
c31ffb3f | 847 | struct ftrace_event_call *call = &tk->tp.call; |
413d37d1 | 848 | |
41a7dd42 MH |
849 | WARN_ON(call != ftrace_file->event_call); |
850 | ||
b8820084 MH |
851 | if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags)) |
852 | return; | |
853 | ||
413d37d1 MH |
854 | local_save_flags(irq_flags); |
855 | pc = preempt_count(); | |
856 | ||
c31ffb3f NK |
857 | dsize = __get_data_size(&tk->tp, regs); |
858 | size = sizeof(*entry) + tk->tp.size + dsize; | |
413d37d1 | 859 | |
41a7dd42 MH |
860 | event = trace_event_buffer_lock_reserve(&buffer, ftrace_file, |
861 | call->event.type, | |
862 | size, irq_flags, pc); | |
413d37d1 | 863 | if (!event) |
1e12a4a7 | 864 | return; |
413d37d1 MH |
865 | |
866 | entry = ring_buffer_event_data(event); | |
c31ffb3f NK |
867 | entry->ip = (unsigned long)tk->rp.kp.addr; |
868 | store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize); | |
413d37d1 | 869 | |
f306cc82 | 870 | if (!filter_check_discard(ftrace_file, entry, buffer, event)) |
0d5c6e1c SR |
871 | trace_buffer_unlock_commit_regs(buffer, event, |
872 | irq_flags, pc, regs); | |
413d37d1 MH |
873 | } |
874 | ||
41a7dd42 | 875 | static __kprobes void |
c31ffb3f | 876 | kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs) |
41a7dd42 | 877 | { |
b04d52e3 | 878 | struct event_file_link *link; |
41a7dd42 | 879 | |
c31ffb3f NK |
880 | list_for_each_entry_rcu(link, &tk->tp.files, list) |
881 | __kprobe_trace_func(tk, regs, link->file); | |
41a7dd42 MH |
882 | } |
883 | ||
413d37d1 | 884 | /* Kretprobe handler */ |
2b106aab | 885 | static __kprobes void |
c31ffb3f | 886 | __kretprobe_trace_func(struct trace_kprobe *tk, struct kretprobe_instance *ri, |
41a7dd42 MH |
887 | struct pt_regs *regs, |
888 | struct ftrace_event_file *ftrace_file) | |
413d37d1 | 889 | { |
93ccae7a | 890 | struct kretprobe_trace_entry_head *entry; |
413d37d1 | 891 | struct ring_buffer_event *event; |
8f8ffe24 | 892 | struct ring_buffer *buffer; |
e09c8614 | 893 | int size, pc, dsize; |
413d37d1 | 894 | unsigned long irq_flags; |
c31ffb3f | 895 | struct ftrace_event_call *call = &tk->tp.call; |
413d37d1 | 896 | |
41a7dd42 MH |
897 | WARN_ON(call != ftrace_file->event_call); |
898 | ||
b8820084 MH |
899 | if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags)) |
900 | return; | |
901 | ||
413d37d1 MH |
902 | local_save_flags(irq_flags); |
903 | pc = preempt_count(); | |
904 | ||
c31ffb3f NK |
905 | dsize = __get_data_size(&tk->tp, regs); |
906 | size = sizeof(*entry) + tk->tp.size + dsize; | |
413d37d1 | 907 | |
41a7dd42 MH |
908 | event = trace_event_buffer_lock_reserve(&buffer, ftrace_file, |
909 | call->event.type, | |
910 | size, irq_flags, pc); | |
413d37d1 | 911 | if (!event) |
1e12a4a7 | 912 | return; |
413d37d1 MH |
913 | |
914 | entry = ring_buffer_event_data(event); | |
c31ffb3f | 915 | entry->func = (unsigned long)tk->rp.kp.addr; |
413d37d1 | 916 | entry->ret_ip = (unsigned long)ri->ret_addr; |
c31ffb3f | 917 | store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize); |
413d37d1 | 918 | |
f306cc82 | 919 | if (!filter_check_discard(ftrace_file, entry, buffer, event)) |
0d5c6e1c SR |
920 | trace_buffer_unlock_commit_regs(buffer, event, |
921 | irq_flags, pc, regs); | |
413d37d1 MH |
922 | } |
923 | ||
41a7dd42 | 924 | static __kprobes void |
c31ffb3f | 925 | kretprobe_trace_func(struct trace_kprobe *tk, struct kretprobe_instance *ri, |
41a7dd42 MH |
926 | struct pt_regs *regs) |
927 | { | |
b04d52e3 | 928 | struct event_file_link *link; |
41a7dd42 | 929 | |
c31ffb3f NK |
930 | list_for_each_entry_rcu(link, &tk->tp.files, list) |
931 | __kretprobe_trace_func(tk, ri, regs, link->file); | |
41a7dd42 MH |
932 | } |
933 | ||
413d37d1 | 934 | /* Event entry printers */ |
b62fdd97 | 935 | static enum print_line_t |
a9a57763 SR |
936 | print_kprobe_event(struct trace_iterator *iter, int flags, |
937 | struct trace_event *event) | |
413d37d1 | 938 | { |
93ccae7a | 939 | struct kprobe_trace_entry_head *field; |
413d37d1 | 940 | struct trace_seq *s = &iter->seq; |
eca0d916 | 941 | struct trace_probe *tp; |
93ccae7a | 942 | u8 *data; |
413d37d1 MH |
943 | int i; |
944 | ||
93ccae7a | 945 | field = (struct kprobe_trace_entry_head *)iter->ent; |
80decc70 | 946 | tp = container_of(event, struct trace_probe, call.event); |
413d37d1 | 947 | |
6e9f23d1 MH |
948 | if (!trace_seq_printf(s, "%s: (", tp->call.name)) |
949 | goto partial; | |
950 | ||
413d37d1 MH |
951 | if (!seq_print_ip_sym(s, field->ip, flags | TRACE_ITER_SYM_OFFSET)) |
952 | goto partial; | |
953 | ||
6e9f23d1 | 954 | if (!trace_seq_puts(s, ")")) |
413d37d1 MH |
955 | goto partial; |
956 | ||
93ccae7a MH |
957 | data = (u8 *)&field[1]; |
958 | for (i = 0; i < tp->nr_args; i++) | |
959 | if (!tp->args[i].type->print(s, tp->args[i].name, | |
e09c8614 | 960 | data + tp->args[i].offset, field)) |
413d37d1 MH |
961 | goto partial; |
962 | ||
963 | if (!trace_seq_puts(s, "\n")) | |
964 | goto partial; | |
965 | ||
966 | return TRACE_TYPE_HANDLED; | |
967 | partial: | |
968 | return TRACE_TYPE_PARTIAL_LINE; | |
969 | } | |
970 | ||
b62fdd97 | 971 | static enum print_line_t |
a9a57763 SR |
972 | print_kretprobe_event(struct trace_iterator *iter, int flags, |
973 | struct trace_event *event) | |
413d37d1 | 974 | { |
93ccae7a | 975 | struct kretprobe_trace_entry_head *field; |
413d37d1 | 976 | struct trace_seq *s = &iter->seq; |
eca0d916 | 977 | struct trace_probe *tp; |
93ccae7a | 978 | u8 *data; |
413d37d1 MH |
979 | int i; |
980 | ||
93ccae7a | 981 | field = (struct kretprobe_trace_entry_head *)iter->ent; |
80decc70 | 982 | tp = container_of(event, struct trace_probe, call.event); |
413d37d1 | 983 | |
6e9f23d1 MH |
984 | if (!trace_seq_printf(s, "%s: (", tp->call.name)) |
985 | goto partial; | |
986 | ||
413d37d1 MH |
987 | if (!seq_print_ip_sym(s, field->ret_ip, flags | TRACE_ITER_SYM_OFFSET)) |
988 | goto partial; | |
989 | ||
990 | if (!trace_seq_puts(s, " <- ")) | |
991 | goto partial; | |
992 | ||
993 | if (!seq_print_ip_sym(s, field->func, flags & ~TRACE_ITER_SYM_OFFSET)) | |
994 | goto partial; | |
995 | ||
6e9f23d1 | 996 | if (!trace_seq_puts(s, ")")) |
413d37d1 MH |
997 | goto partial; |
998 | ||
93ccae7a MH |
999 | data = (u8 *)&field[1]; |
1000 | for (i = 0; i < tp->nr_args; i++) | |
1001 | if (!tp->args[i].type->print(s, tp->args[i].name, | |
e09c8614 | 1002 | data + tp->args[i].offset, field)) |
413d37d1 MH |
1003 | goto partial; |
1004 | ||
1005 | if (!trace_seq_puts(s, "\n")) | |
1006 | goto partial; | |
1007 | ||
1008 | return TRACE_TYPE_HANDLED; | |
1009 | partial: | |
1010 | return TRACE_TYPE_PARTIAL_LINE; | |
1011 | } | |
1012 | ||
413d37d1 MH |
1013 | |
1014 | static int kprobe_event_define_fields(struct ftrace_event_call *event_call) | |
1015 | { | |
1016 | int ret, i; | |
93ccae7a | 1017 | struct kprobe_trace_entry_head field; |
c31ffb3f | 1018 | struct trace_kprobe *tk = (struct trace_kprobe *)event_call->data; |
413d37d1 | 1019 | |
a703d946 | 1020 | DEFINE_FIELD(unsigned long, ip, FIELD_STRING_IP, 0); |
eca0d916 | 1021 | /* Set argument names as fields */ |
c31ffb3f NK |
1022 | for (i = 0; i < tk->tp.nr_args; i++) { |
1023 | struct probe_arg *parg = &tk->tp.args[i]; | |
1024 | ||
1025 | ret = trace_define_field(event_call, parg->type->fmttype, | |
1026 | parg->name, | |
1027 | sizeof(field) + parg->offset, | |
1028 | parg->type->size, | |
1029 | parg->type->is_signed, | |
93ccae7a MH |
1030 | FILTER_OTHER); |
1031 | if (ret) | |
1032 | return ret; | |
1033 | } | |
413d37d1 MH |
1034 | return 0; |
1035 | } | |
1036 | ||
1037 | static int kretprobe_event_define_fields(struct ftrace_event_call *event_call) | |
1038 | { | |
1039 | int ret, i; | |
93ccae7a | 1040 | struct kretprobe_trace_entry_head field; |
c31ffb3f | 1041 | struct trace_kprobe *tk = (struct trace_kprobe *)event_call->data; |
413d37d1 | 1042 | |
a703d946 MH |
1043 | DEFINE_FIELD(unsigned long, func, FIELD_STRING_FUNC, 0); |
1044 | DEFINE_FIELD(unsigned long, ret_ip, FIELD_STRING_RETIP, 0); | |
eca0d916 | 1045 | /* Set argument names as fields */ |
c31ffb3f NK |
1046 | for (i = 0; i < tk->tp.nr_args; i++) { |
1047 | struct probe_arg *parg = &tk->tp.args[i]; | |
1048 | ||
1049 | ret = trace_define_field(event_call, parg->type->fmttype, | |
1050 | parg->name, | |
1051 | sizeof(field) + parg->offset, | |
1052 | parg->type->size, | |
1053 | parg->type->is_signed, | |
93ccae7a MH |
1054 | FILTER_OTHER); |
1055 | if (ret) | |
1056 | return ret; | |
1057 | } | |
413d37d1 MH |
1058 | return 0; |
1059 | } | |
1060 | ||
07b139c8 | 1061 | #ifdef CONFIG_PERF_EVENTS |
e08d1c65 MH |
1062 | |
1063 | /* Kprobe profile handler */ | |
2b106aab | 1064 | static __kprobes void |
c31ffb3f | 1065 | kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs) |
e08d1c65 | 1066 | { |
c31ffb3f | 1067 | struct ftrace_event_call *call = &tk->tp.call; |
93ccae7a | 1068 | struct kprobe_trace_entry_head *entry; |
1c024eca | 1069 | struct hlist_head *head; |
e09c8614 | 1070 | int size, __size, dsize; |
4ed7c92d | 1071 | int rctx; |
e08d1c65 | 1072 | |
288e984e ON |
1073 | head = this_cpu_ptr(call->perf_events); |
1074 | if (hlist_empty(head)) | |
1075 | return; | |
1076 | ||
c31ffb3f NK |
1077 | dsize = __get_data_size(&tk->tp, regs); |
1078 | __size = sizeof(*entry) + tk->tp.size + dsize; | |
74ebb63e MH |
1079 | size = ALIGN(__size + sizeof(u32), sizeof(u64)); |
1080 | size -= sizeof(u32); | |
ce71b9df | 1081 | |
ff5f149b | 1082 | entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); |
430ad5a6 | 1083 | if (!entry) |
1e12a4a7 | 1084 | return; |
a1a138d0 | 1085 | |
c31ffb3f | 1086 | entry->ip = (unsigned long)tk->rp.kp.addr; |
e09c8614 | 1087 | memset(&entry[1], 0, dsize); |
c31ffb3f | 1088 | store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize); |
cf6735a4 | 1089 | perf_trace_buf_submit(entry, size, rctx, 0, 1, regs, head, NULL); |
e08d1c65 MH |
1090 | } |
1091 | ||
1092 | /* Kretprobe profile handler */ | |
2b106aab | 1093 | static __kprobes void |
c31ffb3f | 1094 | kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri, |
2b106aab | 1095 | struct pt_regs *regs) |
e08d1c65 | 1096 | { |
c31ffb3f | 1097 | struct ftrace_event_call *call = &tk->tp.call; |
93ccae7a | 1098 | struct kretprobe_trace_entry_head *entry; |
1c024eca | 1099 | struct hlist_head *head; |
e09c8614 | 1100 | int size, __size, dsize; |
4ed7c92d | 1101 | int rctx; |
e08d1c65 | 1102 | |
288e984e ON |
1103 | head = this_cpu_ptr(call->perf_events); |
1104 | if (hlist_empty(head)) | |
1105 | return; | |
1106 | ||
c31ffb3f NK |
1107 | dsize = __get_data_size(&tk->tp, regs); |
1108 | __size = sizeof(*entry) + tk->tp.size + dsize; | |
74ebb63e MH |
1109 | size = ALIGN(__size + sizeof(u32), sizeof(u64)); |
1110 | size -= sizeof(u32); | |
444a2a3b | 1111 | |
ff5f149b | 1112 | entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); |
430ad5a6 | 1113 | if (!entry) |
1e12a4a7 | 1114 | return; |
e08d1c65 | 1115 | |
c31ffb3f | 1116 | entry->func = (unsigned long)tk->rp.kp.addr; |
a1a138d0 | 1117 | entry->ret_ip = (unsigned long)ri->ret_addr; |
c31ffb3f | 1118 | store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize); |
cf6735a4 | 1119 | perf_trace_buf_submit(entry, size, rctx, 0, 1, regs, head, NULL); |
e08d1c65 | 1120 | } |
07b139c8 | 1121 | #endif /* CONFIG_PERF_EVENTS */ |
50d78056 | 1122 | |
3fe3d619 ON |
1123 | /* |
1124 | * called by perf_trace_init() or __ftrace_set_clr_event() under event_mutex. | |
1125 | * | |
1126 | * kprobe_trace_self_tests_init() does enable_trace_probe/disable_trace_probe | |
1127 | * lockless, but we can't race with this __init function. | |
1128 | */ | |
2239291a | 1129 | static __kprobes |
ceec0b6f JO |
1130 | int kprobe_register(struct ftrace_event_call *event, |
1131 | enum trace_reg type, void *data) | |
2239291a | 1132 | { |
c31ffb3f | 1133 | struct trace_kprobe *tk = (struct trace_kprobe *)event->data; |
41a7dd42 | 1134 | struct ftrace_event_file *file = data; |
1538f888 | 1135 | |
2239291a SR |
1136 | switch (type) { |
1137 | case TRACE_REG_REGISTER: | |
c31ffb3f | 1138 | return enable_trace_kprobe(tk, file); |
2239291a | 1139 | case TRACE_REG_UNREGISTER: |
c31ffb3f | 1140 | return disable_trace_kprobe(tk, file); |
2239291a SR |
1141 | |
1142 | #ifdef CONFIG_PERF_EVENTS | |
1143 | case TRACE_REG_PERF_REGISTER: | |
c31ffb3f | 1144 | return enable_trace_kprobe(tk, NULL); |
2239291a | 1145 | case TRACE_REG_PERF_UNREGISTER: |
c31ffb3f | 1146 | return disable_trace_kprobe(tk, NULL); |
ceec0b6f JO |
1147 | case TRACE_REG_PERF_OPEN: |
1148 | case TRACE_REG_PERF_CLOSE: | |
489c75c3 JO |
1149 | case TRACE_REG_PERF_ADD: |
1150 | case TRACE_REG_PERF_DEL: | |
ceec0b6f | 1151 | return 0; |
2239291a SR |
1152 | #endif |
1153 | } | |
1154 | return 0; | |
1155 | } | |
50d78056 MH |
1156 | |
1157 | static __kprobes | |
1158 | int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs) | |
1159 | { | |
c31ffb3f | 1160 | struct trace_kprobe *tk = container_of(kp, struct trace_kprobe, rp.kp); |
e08d1c65 | 1161 | |
c31ffb3f | 1162 | tk->nhit++; |
48182bd2 | 1163 | |
c31ffb3f NK |
1164 | if (tk->tp.flags & TP_FLAG_TRACE) |
1165 | kprobe_trace_func(tk, regs); | |
07b139c8 | 1166 | #ifdef CONFIG_PERF_EVENTS |
c31ffb3f NK |
1167 | if (tk->tp.flags & TP_FLAG_PROFILE) |
1168 | kprobe_perf_func(tk, regs); | |
07b139c8 | 1169 | #endif |
50d78056 MH |
1170 | return 0; /* We don't tweek kernel, so just return 0 */ |
1171 | } | |
1172 | ||
1173 | static __kprobes | |
1174 | int kretprobe_dispatcher(struct kretprobe_instance *ri, struct pt_regs *regs) | |
1175 | { | |
c31ffb3f | 1176 | struct trace_kprobe *tk = container_of(ri->rp, struct trace_kprobe, rp); |
50d78056 | 1177 | |
c31ffb3f | 1178 | tk->nhit++; |
48182bd2 | 1179 | |
c31ffb3f NK |
1180 | if (tk->tp.flags & TP_FLAG_TRACE) |
1181 | kretprobe_trace_func(tk, ri, regs); | |
07b139c8 | 1182 | #ifdef CONFIG_PERF_EVENTS |
c31ffb3f NK |
1183 | if (tk->tp.flags & TP_FLAG_PROFILE) |
1184 | kretprobe_perf_func(tk, ri, regs); | |
07b139c8 | 1185 | #endif |
50d78056 MH |
1186 | return 0; /* We don't tweek kernel, so just return 0 */ |
1187 | } | |
e08d1c65 | 1188 | |
a9a57763 SR |
1189 | static struct trace_event_functions kretprobe_funcs = { |
1190 | .trace = print_kretprobe_event | |
1191 | }; | |
1192 | ||
1193 | static struct trace_event_functions kprobe_funcs = { | |
1194 | .trace = print_kprobe_event | |
1195 | }; | |
1196 | ||
c31ffb3f | 1197 | static int register_kprobe_event(struct trace_kprobe *tk) |
413d37d1 | 1198 | { |
c31ffb3f | 1199 | struct ftrace_event_call *call = &tk->tp.call; |
413d37d1 MH |
1200 | int ret; |
1201 | ||
1202 | /* Initialize ftrace_event_call */ | |
ffb9f995 | 1203 | INIT_LIST_HEAD(&call->class->fields); |
c31ffb3f | 1204 | if (trace_kprobe_is_return(tk)) { |
80decc70 | 1205 | call->event.funcs = &kretprobe_funcs; |
2e33af02 | 1206 | call->class->define_fields = kretprobe_event_define_fields; |
413d37d1 | 1207 | } else { |
80decc70 | 1208 | call->event.funcs = &kprobe_funcs; |
2e33af02 | 1209 | call->class->define_fields = kprobe_event_define_fields; |
413d37d1 | 1210 | } |
5bf652aa | 1211 | if (set_print_fmt(&tk->tp, trace_kprobe_is_return(tk)) < 0) |
a342a028 | 1212 | return -ENOMEM; |
32c0edae SR |
1213 | ret = register_ftrace_event(&call->event); |
1214 | if (!ret) { | |
a342a028 | 1215 | kfree(call->print_fmt); |
ff50d991 | 1216 | return -ENODEV; |
a342a028 | 1217 | } |
553552ce | 1218 | call->flags = 0; |
2239291a | 1219 | call->class->reg = kprobe_register; |
c31ffb3f | 1220 | call->data = tk; |
413d37d1 | 1221 | ret = trace_add_event_call(call); |
ff50d991 | 1222 | if (ret) { |
413d37d1 | 1223 | pr_info("Failed to register kprobe event: %s\n", call->name); |
a342a028 | 1224 | kfree(call->print_fmt); |
80decc70 | 1225 | unregister_ftrace_event(&call->event); |
ff50d991 | 1226 | } |
413d37d1 MH |
1227 | return ret; |
1228 | } | |
1229 | ||
c31ffb3f | 1230 | static int unregister_kprobe_event(struct trace_kprobe *tk) |
413d37d1 | 1231 | { |
40c32592 SRRH |
1232 | int ret; |
1233 | ||
ff50d991 | 1234 | /* tp->event is unregistered in trace_remove_event_call() */ |
c31ffb3f | 1235 | ret = trace_remove_event_call(&tk->tp.call); |
40c32592 | 1236 | if (!ret) |
c31ffb3f | 1237 | kfree(tk->tp.call.print_fmt); |
40c32592 | 1238 | return ret; |
413d37d1 MH |
1239 | } |
1240 | ||
25985edc | 1241 | /* Make a debugfs interface for controlling probe points */ |
413d37d1 MH |
1242 | static __init int init_kprobe_trace(void) |
1243 | { | |
1244 | struct dentry *d_tracer; | |
1245 | struct dentry *entry; | |
413d37d1 | 1246 | |
c31ffb3f | 1247 | if (register_module_notifier(&trace_kprobe_module_nb)) |
61424318 MH |
1248 | return -EINVAL; |
1249 | ||
413d37d1 MH |
1250 | d_tracer = tracing_init_dentry(); |
1251 | if (!d_tracer) | |
1252 | return 0; | |
1253 | ||
1254 | entry = debugfs_create_file("kprobe_events", 0644, d_tracer, | |
1255 | NULL, &kprobe_events_ops); | |
1256 | ||
cd7e7bd5 | 1257 | /* Event list interface */ |
413d37d1 MH |
1258 | if (!entry) |
1259 | pr_warning("Could not create debugfs " | |
1260 | "'kprobe_events' entry\n"); | |
cd7e7bd5 MH |
1261 | |
1262 | /* Profile interface */ | |
1263 | entry = debugfs_create_file("kprobe_profile", 0444, d_tracer, | |
1264 | NULL, &kprobe_profile_ops); | |
1265 | ||
1266 | if (!entry) | |
1267 | pr_warning("Could not create debugfs " | |
1268 | "'kprobe_profile' entry\n"); | |
413d37d1 MH |
1269 | return 0; |
1270 | } | |
1271 | fs_initcall(init_kprobe_trace); | |
1272 | ||
1273 | ||
1274 | #ifdef CONFIG_FTRACE_STARTUP_TEST | |
1275 | ||
265a5b7e SR |
1276 | /* |
1277 | * The "__used" keeps gcc from removing the function symbol | |
1278 | * from the kallsyms table. | |
1279 | */ | |
1280 | static __used int kprobe_trace_selftest_target(int a1, int a2, int a3, | |
1281 | int a4, int a5, int a6) | |
413d37d1 MH |
1282 | { |
1283 | return a1 + a2 + a3 + a4 + a5 + a6; | |
1284 | } | |
1285 | ||
41a7dd42 | 1286 | static struct ftrace_event_file * |
c31ffb3f | 1287 | find_trace_probe_file(struct trace_kprobe *tk, struct trace_array *tr) |
41a7dd42 MH |
1288 | { |
1289 | struct ftrace_event_file *file; | |
1290 | ||
1291 | list_for_each_entry(file, &tr->events, list) | |
c31ffb3f | 1292 | if (file->event_call == &tk->tp.call) |
41a7dd42 MH |
1293 | return file; |
1294 | ||
1295 | return NULL; | |
1296 | } | |
1297 | ||
3fe3d619 | 1298 | /* |
c31ffb3f | 1299 | * Nobody but us can call enable_trace_kprobe/disable_trace_kprobe at this |
3fe3d619 ON |
1300 | * stage, we can do this lockless. |
1301 | */ | |
413d37d1 MH |
1302 | static __init int kprobe_trace_self_tests_init(void) |
1303 | { | |
231e36f4 | 1304 | int ret, warn = 0; |
413d37d1 | 1305 | int (*target)(int, int, int, int, int, int); |
c31ffb3f | 1306 | struct trace_kprobe *tk; |
41a7dd42 | 1307 | struct ftrace_event_file *file; |
413d37d1 MH |
1308 | |
1309 | target = kprobe_trace_selftest_target; | |
1310 | ||
1311 | pr_info("Testing kprobe tracing: "); | |
1312 | ||
8ab83f56 SD |
1313 | ret = traceprobe_command("p:testprobe kprobe_trace_selftest_target " |
1314 | "$stack $stack0 +0($stack)", | |
c31ffb3f | 1315 | create_trace_kprobe); |
231e36f4 | 1316 | if (WARN_ON_ONCE(ret)) { |
41a7dd42 | 1317 | pr_warn("error on probing function entry.\n"); |
231e36f4 MH |
1318 | warn++; |
1319 | } else { | |
1320 | /* Enable trace point */ | |
c31ffb3f NK |
1321 | tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM); |
1322 | if (WARN_ON_ONCE(tk == NULL)) { | |
41a7dd42 | 1323 | pr_warn("error on getting new probe.\n"); |
231e36f4 | 1324 | warn++; |
41a7dd42 | 1325 | } else { |
c31ffb3f | 1326 | file = find_trace_probe_file(tk, top_trace_array()); |
41a7dd42 MH |
1327 | if (WARN_ON_ONCE(file == NULL)) { |
1328 | pr_warn("error on getting probe file.\n"); | |
1329 | warn++; | |
1330 | } else | |
c31ffb3f | 1331 | enable_trace_kprobe(tk, file); |
41a7dd42 | 1332 | } |
231e36f4 | 1333 | } |
413d37d1 | 1334 | |
8ab83f56 | 1335 | ret = traceprobe_command("r:testprobe2 kprobe_trace_selftest_target " |
c31ffb3f | 1336 | "$retval", create_trace_kprobe); |
231e36f4 | 1337 | if (WARN_ON_ONCE(ret)) { |
41a7dd42 | 1338 | pr_warn("error on probing function return.\n"); |
231e36f4 MH |
1339 | warn++; |
1340 | } else { | |
1341 | /* Enable trace point */ | |
c31ffb3f NK |
1342 | tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM); |
1343 | if (WARN_ON_ONCE(tk == NULL)) { | |
41a7dd42 | 1344 | pr_warn("error on getting 2nd new probe.\n"); |
231e36f4 | 1345 | warn++; |
41a7dd42 | 1346 | } else { |
c31ffb3f | 1347 | file = find_trace_probe_file(tk, top_trace_array()); |
41a7dd42 MH |
1348 | if (WARN_ON_ONCE(file == NULL)) { |
1349 | pr_warn("error on getting probe file.\n"); | |
1350 | warn++; | |
1351 | } else | |
c31ffb3f | 1352 | enable_trace_kprobe(tk, file); |
41a7dd42 | 1353 | } |
231e36f4 MH |
1354 | } |
1355 | ||
1356 | if (warn) | |
1357 | goto end; | |
413d37d1 MH |
1358 | |
1359 | ret = target(1, 2, 3, 4, 5, 6); | |
1360 | ||
02ca1521 | 1361 | /* Disable trace points before removing it */ |
c31ffb3f NK |
1362 | tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM); |
1363 | if (WARN_ON_ONCE(tk == NULL)) { | |
41a7dd42 | 1364 | pr_warn("error on getting test probe.\n"); |
02ca1521 | 1365 | warn++; |
41a7dd42 | 1366 | } else { |
c31ffb3f | 1367 | file = find_trace_probe_file(tk, top_trace_array()); |
41a7dd42 MH |
1368 | if (WARN_ON_ONCE(file == NULL)) { |
1369 | pr_warn("error on getting probe file.\n"); | |
1370 | warn++; | |
1371 | } else | |
c31ffb3f | 1372 | disable_trace_kprobe(tk, file); |
41a7dd42 | 1373 | } |
02ca1521 | 1374 | |
c31ffb3f NK |
1375 | tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM); |
1376 | if (WARN_ON_ONCE(tk == NULL)) { | |
41a7dd42 | 1377 | pr_warn("error on getting 2nd test probe.\n"); |
02ca1521 | 1378 | warn++; |
41a7dd42 | 1379 | } else { |
c31ffb3f | 1380 | file = find_trace_probe_file(tk, top_trace_array()); |
41a7dd42 MH |
1381 | if (WARN_ON_ONCE(file == NULL)) { |
1382 | pr_warn("error on getting probe file.\n"); | |
1383 | warn++; | |
1384 | } else | |
c31ffb3f | 1385 | disable_trace_kprobe(tk, file); |
41a7dd42 | 1386 | } |
02ca1521 | 1387 | |
c31ffb3f | 1388 | ret = traceprobe_command("-:testprobe", create_trace_kprobe); |
231e36f4 | 1389 | if (WARN_ON_ONCE(ret)) { |
41a7dd42 | 1390 | pr_warn("error on deleting a probe.\n"); |
231e36f4 MH |
1391 | warn++; |
1392 | } | |
1393 | ||
c31ffb3f | 1394 | ret = traceprobe_command("-:testprobe2", create_trace_kprobe); |
231e36f4 | 1395 | if (WARN_ON_ONCE(ret)) { |
41a7dd42 | 1396 | pr_warn("error on deleting a probe.\n"); |
231e36f4 MH |
1397 | warn++; |
1398 | } | |
413d37d1 | 1399 | |
231e36f4 | 1400 | end: |
c31ffb3f | 1401 | release_all_trace_kprobes(); |
231e36f4 MH |
1402 | if (warn) |
1403 | pr_cont("NG: Some tests are failed. Please check them.\n"); | |
1404 | else | |
1405 | pr_cont("OK\n"); | |
413d37d1 MH |
1406 | return 0; |
1407 | } | |
1408 | ||
1409 | late_initcall(kprobe_trace_self_tests_init); | |
1410 | ||
1411 | #endif |