diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-11-10 04:17:07 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2009-11-10 05:23:29 -0500 |
commit | f60d24d2ad04977b0bd9e3eb35dba2d2fa569af9 (patch) | |
tree | b9335a41bce33a05985634a382a5adcf837dec43 | |
parent | 9f6b3c2c30cfbb1166ce7e74a8f9fd93ae19d2de (diff) |
hw-breakpoints: Fix broken hw-breakpoint sample module
The hw-breakpoint sample module has been broken during the
hw-breakpoint internals refactoring. Propagate the changes
to it.
Reported-by: "K. Prasad" <prasad@linux.vnet.ibm.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
-rw-r--r-- | kernel/hw_breakpoint.c | 3 | ||||
-rw-r--r-- | kernel/kallsyms.c | 1 | ||||
-rw-r--r-- | samples/hw_breakpoint/data_breakpoint.c | 43 |
3 files changed, 27 insertions, 20 deletions
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c index e662dc991c96..9ea9414e0e58 100644 --- a/kernel/hw_breakpoint.c +++ b/kernel/hw_breakpoint.c | |||
@@ -454,6 +454,7 @@ fail: | |||
454 | /* return the error if any */ | 454 | /* return the error if any */ |
455 | return ERR_PTR(err); | 455 | return ERR_PTR(err); |
456 | } | 456 | } |
457 | EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint); | ||
457 | 458 | ||
458 | /** | 459 | /** |
459 | * unregister_wide_hw_breakpoint - unregister a wide breakpoint in the kernel | 460 | * unregister_wide_hw_breakpoint - unregister a wide breakpoint in the kernel |
@@ -470,7 +471,7 @@ void unregister_wide_hw_breakpoint(struct perf_event **cpu_events) | |||
470 | } | 471 | } |
471 | free_percpu(cpu_events); | 472 | free_percpu(cpu_events); |
472 | } | 473 | } |
473 | 474 | EXPORT_SYMBOL_GPL(unregister_wide_hw_breakpoint); | |
474 | 475 | ||
475 | static struct notifier_block hw_breakpoint_exceptions_nb = { | 476 | static struct notifier_block hw_breakpoint_exceptions_nb = { |
476 | .notifier_call = hw_breakpoint_exceptions_notify, | 477 | .notifier_call = hw_breakpoint_exceptions_notify, |
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 8b6b8b697c68..8e5288a8a355 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c | |||
@@ -181,6 +181,7 @@ unsigned long kallsyms_lookup_name(const char *name) | |||
181 | } | 181 | } |
182 | return module_kallsyms_lookup_name(name); | 182 | return module_kallsyms_lookup_name(name); |
183 | } | 183 | } |
184 | EXPORT_SYMBOL_GPL(kallsyms_lookup_name); | ||
184 | 185 | ||
185 | int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, | 186 | int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, |
186 | unsigned long), | 187 | unsigned long), |
diff --git a/samples/hw_breakpoint/data_breakpoint.c b/samples/hw_breakpoint/data_breakpoint.c index 9cbdbb871b7a..5bc9819a819e 100644 --- a/samples/hw_breakpoint/data_breakpoint.c +++ b/samples/hw_breakpoint/data_breakpoint.c | |||
@@ -27,18 +27,19 @@ | |||
27 | #include <linux/module.h> /* Needed by all modules */ | 27 | #include <linux/module.h> /* Needed by all modules */ |
28 | #include <linux/kernel.h> /* Needed for KERN_INFO */ | 28 | #include <linux/kernel.h> /* Needed for KERN_INFO */ |
29 | #include <linux/init.h> /* Needed for the macros */ | 29 | #include <linux/init.h> /* Needed for the macros */ |
30 | #include <linux/kallsyms.h> | ||
30 | 31 | ||
31 | #include <asm/hw_breakpoint.h> | 32 | #include <linux/perf_event.h> |
33 | #include <linux/hw_breakpoint.h> | ||
32 | 34 | ||
33 | struct hw_breakpoint sample_hbp; | 35 | struct perf_event **sample_hbp; |
34 | 36 | ||
35 | static char ksym_name[KSYM_NAME_LEN] = "pid_max"; | 37 | static char ksym_name[KSYM_NAME_LEN] = "pid_max"; |
36 | module_param_string(ksym, ksym_name, KSYM_NAME_LEN, S_IRUGO); | 38 | module_param_string(ksym, ksym_name, KSYM_NAME_LEN, S_IRUGO); |
37 | MODULE_PARM_DESC(ksym, "Kernel symbol to monitor; this module will report any" | 39 | MODULE_PARM_DESC(ksym, "Kernel symbol to monitor; this module will report any" |
38 | " write operations on the kernel symbol"); | 40 | " write operations on the kernel symbol"); |
39 | 41 | ||
40 | void sample_hbp_handler(struct hw_breakpoint *temp, struct pt_regs | 42 | static void sample_hbp_handler(struct perf_event *temp, void *data) |
41 | *temp_regs) | ||
42 | { | 43 | { |
43 | printk(KERN_INFO "%s value is changed\n", ksym_name); | 44 | printk(KERN_INFO "%s value is changed\n", ksym_name); |
44 | dump_stack(); | 45 | dump_stack(); |
@@ -48,30 +49,34 @@ void sample_hbp_handler(struct hw_breakpoint *temp, struct pt_regs | |||
48 | static int __init hw_break_module_init(void) | 49 | static int __init hw_break_module_init(void) |
49 | { | 50 | { |
50 | int ret; | 51 | int ret; |
52 | unsigned long addr; | ||
51 | 53 | ||
52 | #ifdef CONFIG_X86 | 54 | addr = kallsyms_lookup_name(ksym_name); |
53 | sample_hbp.info.name = ksym_name; | ||
54 | sample_hbp.info.type = HW_BREAKPOINT_WRITE; | ||
55 | sample_hbp.info.len = HW_BREAKPOINT_LEN_4; | ||
56 | #endif /* CONFIG_X86 */ | ||
57 | 55 | ||
58 | sample_hbp.triggered = (void *)sample_hbp_handler; | 56 | sample_hbp = register_wide_hw_breakpoint(addr, HW_BREAKPOINT_LEN_4, |
57 | HW_BREAKPOINT_W | HW_BREAKPOINT_R, | ||
58 | sample_hbp_handler, true); | ||
59 | if (IS_ERR(sample_hbp)) { | ||
60 | ret = PTR_ERR(sample_hbp); | ||
61 | goto fail; | ||
62 | } else if (!sample_hbp) { | ||
63 | ret = -EINVAL; | ||
64 | goto fail; | ||
65 | } | ||
59 | 66 | ||
60 | ret = register_kernel_hw_breakpoint(&sample_hbp); | 67 | printk(KERN_INFO "HW Breakpoint for %s write installed\n", ksym_name); |
61 | |||
62 | if (ret < 0) { | ||
63 | printk(KERN_INFO "Breakpoint registration failed\n"); | ||
64 | return ret; | ||
65 | } else | ||
66 | printk(KERN_INFO "HW Breakpoint for %s write installed\n", | ||
67 | ksym_name); | ||
68 | 68 | ||
69 | return 0; | 69 | return 0; |
70 | |||
71 | fail: | ||
72 | printk(KERN_INFO "Breakpoint registration failed\n"); | ||
73 | |||
74 | return ret; | ||
70 | } | 75 | } |
71 | 76 | ||
72 | static void __exit hw_break_module_exit(void) | 77 | static void __exit hw_break_module_exit(void) |
73 | { | 78 | { |
74 | unregister_kernel_hw_breakpoint(&sample_hbp); | 79 | unregister_wide_hw_breakpoint(sample_hbp); |
75 | printk(KERN_INFO "HW Breakpoint for %s write uninstalled\n", ksym_name); | 80 | printk(KERN_INFO "HW Breakpoint for %s write uninstalled\n", ksym_name); |
76 | } | 81 | } |
77 | 82 | ||