aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/hw_breakpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/hw_breakpoint.c')
-rw-r--r--kernel/hw_breakpoint.c35
1 files changed, 4 insertions, 31 deletions
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c
index 2a47514f12fd..cf5ee1628411 100644
--- a/kernel/hw_breakpoint.c
+++ b/kernel/hw_breakpoint.c
@@ -339,42 +339,16 @@ void unregister_hw_breakpoint(struct perf_event *bp)
339} 339}
340EXPORT_SYMBOL_GPL(unregister_hw_breakpoint); 340EXPORT_SYMBOL_GPL(unregister_hw_breakpoint);
341 341
342static struct perf_event *
343register_kernel_hw_breakpoint_cpu(unsigned long addr,
344 int len,
345 int type,
346 perf_callback_t triggered,
347 int cpu,
348 bool active)
349{
350 DEFINE_BREAKPOINT_ATTR(attr);
351
352 attr.bp_addr = addr;
353 attr.bp_len = len;
354 attr.bp_type = type;
355
356 if (!active)
357 attr.disabled = 1;
358
359 return perf_event_create_kernel_counter(&attr, cpu, -1, triggered);
360}
361
362/** 342/**
363 * register_wide_hw_breakpoint - register a wide breakpoint in the kernel 343 * register_wide_hw_breakpoint - register a wide breakpoint in the kernel
364 * @addr: is the memory address that triggers the breakpoint 344 * @attr: breakpoint attributes
365 * @len: the length of the access to the memory (1 byte, 2 bytes etc...)
366 * @type: the type of the access to the memory (read/write/exec)
367 * @triggered: callback to trigger when we hit the breakpoint 345 * @triggered: callback to trigger when we hit the breakpoint
368 * @active: should we activate it while registering it
369 * 346 *
370 * @return a set of per_cpu pointers to perf events 347 * @return a set of per_cpu pointers to perf events
371 */ 348 */
372struct perf_event ** 349struct perf_event **
373register_wide_hw_breakpoint(unsigned long addr, 350register_wide_hw_breakpoint(struct perf_event_attr *attr,
374 int len, 351 perf_callback_t triggered)
375 int type,
376 perf_callback_t triggered,
377 bool active)
378{ 352{
379 struct perf_event **cpu_events, **pevent, *bp; 353 struct perf_event **cpu_events, **pevent, *bp;
380 long err; 354 long err;
@@ -386,8 +360,7 @@ register_wide_hw_breakpoint(unsigned long addr,
386 360
387 for_each_possible_cpu(cpu) { 361 for_each_possible_cpu(cpu) {
388 pevent = per_cpu_ptr(cpu_events, cpu); 362 pevent = per_cpu_ptr(cpu_events, cpu);
389 bp = register_kernel_hw_breakpoint_cpu(addr, len, type, 363 bp = perf_event_create_kernel_counter(attr, cpu, -1, triggered);
390 triggered, cpu, active);
391 364
392 *pevent = bp; 365 *pevent = bp;
393 366