diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2011-06-27 03:27:03 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-07-15 15:45:32 -0400 |
commit | 7f6878a3d707b947603e09d95df0c3a98987e3a4 (patch) | |
tree | aa707653884ae1a7eac99c1b3c772c2eb89eb642 /kernel/trace | |
parent | 614243181050436785f5a621749a7da2336a7916 (diff) |
tracing/kprobe: Update symbol reference when loading module
Since the address of a module-local variable can only be
solved after the target module is loaded, the symbol
fetch-argument should be updated when loading target
module.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: http://lkml.kernel.org/r/20110627072703.6528.75042.stgit@fedora15
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace_kprobe.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index acc6664a6b22..5fb3697bf0e5 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
@@ -343,6 +343,14 @@ DEFINE_BASIC_FETCH_FUNCS(deref) | |||
343 | DEFINE_FETCH_deref(string) | 343 | DEFINE_FETCH_deref(string) |
344 | DEFINE_FETCH_deref(string_size) | 344 | DEFINE_FETCH_deref(string_size) |
345 | 345 | ||
346 | static __kprobes void update_deref_fetch_param(struct deref_fetch_param *data) | ||
347 | { | ||
348 | if (CHECK_FETCH_FUNCS(deref, data->orig.fn)) | ||
349 | update_deref_fetch_param(data->orig.data); | ||
350 | else if (CHECK_FETCH_FUNCS(symbol, data->orig.fn)) | ||
351 | update_symbol_cache(data->orig.data); | ||
352 | } | ||
353 | |||
346 | static __kprobes void free_deref_fetch_param(struct deref_fetch_param *data) | 354 | static __kprobes void free_deref_fetch_param(struct deref_fetch_param *data) |
347 | { | 355 | { |
348 | if (CHECK_FETCH_FUNCS(deref, data->orig.fn)) | 356 | if (CHECK_FETCH_FUNCS(deref, data->orig.fn)) |
@@ -377,6 +385,19 @@ DEFINE_BASIC_FETCH_FUNCS(bitfield) | |||
377 | #define fetch_bitfield_string_size NULL | 385 | #define fetch_bitfield_string_size NULL |
378 | 386 | ||
379 | static __kprobes void | 387 | static __kprobes void |
388 | update_bitfield_fetch_param(struct bitfield_fetch_param *data) | ||
389 | { | ||
390 | /* | ||
391 | * Don't check the bitfield itself, because this must be the | ||
392 | * last fetch function. | ||
393 | */ | ||
394 | if (CHECK_FETCH_FUNCS(deref, data->orig.fn)) | ||
395 | update_deref_fetch_param(data->orig.data); | ||
396 | else if (CHECK_FETCH_FUNCS(symbol, data->orig.fn)) | ||
397 | update_symbol_cache(data->orig.data); | ||
398 | } | ||
399 | |||
400 | static __kprobes void | ||
380 | free_bitfield_fetch_param(struct bitfield_fetch_param *data) | 401 | free_bitfield_fetch_param(struct bitfield_fetch_param *data) |
381 | { | 402 | { |
382 | /* | 403 | /* |
@@ -389,6 +410,7 @@ free_bitfield_fetch_param(struct bitfield_fetch_param *data) | |||
389 | free_symbol_cache(data->orig.data); | 410 | free_symbol_cache(data->orig.data); |
390 | kfree(data); | 411 | kfree(data); |
391 | } | 412 | } |
413 | |||
392 | /* Default (unsigned long) fetch type */ | 414 | /* Default (unsigned long) fetch type */ |
393 | #define __DEFAULT_FETCH_TYPE(t) u##t | 415 | #define __DEFAULT_FETCH_TYPE(t) u##t |
394 | #define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t) | 416 | #define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t) |
@@ -680,6 +702,16 @@ error: | |||
680 | return ERR_PTR(ret); | 702 | return ERR_PTR(ret); |
681 | } | 703 | } |
682 | 704 | ||
705 | static void update_probe_arg(struct probe_arg *arg) | ||
706 | { | ||
707 | if (CHECK_FETCH_FUNCS(bitfield, arg->fetch.fn)) | ||
708 | update_bitfield_fetch_param(arg->fetch.data); | ||
709 | else if (CHECK_FETCH_FUNCS(deref, arg->fetch.fn)) | ||
710 | update_deref_fetch_param(arg->fetch.data); | ||
711 | else if (CHECK_FETCH_FUNCS(symbol, arg->fetch.fn)) | ||
712 | update_symbol_cache(arg->fetch.data); | ||
713 | } | ||
714 | |||
683 | static void free_probe_arg(struct probe_arg *arg) | 715 | static void free_probe_arg(struct probe_arg *arg) |
684 | { | 716 | { |
685 | if (CHECK_FETCH_FUNCS(bitfield, arg->fetch.fn)) | 717 | if (CHECK_FETCH_FUNCS(bitfield, arg->fetch.fn)) |
@@ -749,11 +781,14 @@ static void disable_trace_probe(struct trace_probe *tp, int flag) | |||
749 | /* Internal register function - just handle k*probes and flags */ | 781 | /* Internal register function - just handle k*probes and flags */ |
750 | static int __register_trace_probe(struct trace_probe *tp) | 782 | static int __register_trace_probe(struct trace_probe *tp) |
751 | { | 783 | { |
752 | int ret; | 784 | int i, ret; |
753 | 785 | ||
754 | if (trace_probe_is_registered(tp)) | 786 | if (trace_probe_is_registered(tp)) |
755 | return -EINVAL; | 787 | return -EINVAL; |
756 | 788 | ||
789 | for (i = 0; i < tp->nr_args; i++) | ||
790 | update_probe_arg(&tp->args[i]); | ||
791 | |||
757 | /* Set/clear disabled flag according to tp->flag */ | 792 | /* Set/clear disabled flag according to tp->flag */ |
758 | if (trace_probe_is_enabled(tp)) | 793 | if (trace_probe_is_enabled(tp)) |
759 | tp->rp.kp.flags &= ~KPROBE_FLAG_DISABLED; | 794 | tp->rp.kp.flags &= ~KPROBE_FLAG_DISABLED; |