1 #ifndef _LINUX_HW_BREAKPOINT_H
2 #define _LINUX_HW_BREAKPOINT_H
4 #include <linux/perf_event.h>
5 #include <uapi/linux/hw_breakpoint.h>
7 #ifdef CONFIG_HAVE_HW_BREAKPOINT
9 extern int __init init_hw_breakpoint(void);
11 static inline void hw_breakpoint_init(struct perf_event_attr *attr)
13 memset(attr, 0, sizeof(*attr));
15 attr->type = PERF_TYPE_BREAKPOINT;
16 attr->size = sizeof(*attr);
18 * As it's for in-kernel or ptrace use, we want it to be pinned
19 * and to call its callback every hits.
22 attr->sample_period = 1;
25 static inline void ptrace_breakpoint_init(struct perf_event_attr *attr)
27 hw_breakpoint_init(attr);
28 attr->exclude_kernel = 1;
31 static inline unsigned long hw_breakpoint_addr(struct perf_event *bp)
33 return bp->attr.bp_addr;
36 static inline int hw_breakpoint_type(struct perf_event *bp)
38 return bp->attr.bp_type;
41 static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
43 return bp->attr.bp_len;
46 extern struct perf_event *
47 register_user_hw_breakpoint(struct perf_event_attr *attr,
48 perf_overflow_handler_t triggered,
50 struct task_struct *tsk);
52 /* FIXME: only change from the attr, and don't unregister */
54 modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr);
57 * Kernel breakpoints are not associated with any particular thread.
59 extern struct perf_event *
60 register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
61 perf_overflow_handler_t triggered,
65 extern struct perf_event * __percpu *
66 register_wide_hw_breakpoint(struct perf_event_attr *attr,
67 perf_overflow_handler_t triggered,
70 extern int register_perf_hw_breakpoint(struct perf_event *bp);
71 extern int __register_perf_hw_breakpoint(struct perf_event *bp);
72 extern void unregister_hw_breakpoint(struct perf_event *bp);
73 extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events);
75 extern int dbg_reserve_bp_slot(struct perf_event *bp);
76 extern int dbg_release_bp_slot(struct perf_event *bp);
77 extern int reserve_bp_slot(struct perf_event *bp);
78 extern void release_bp_slot(struct perf_event *bp);
80 extern void flush_ptrace_hw_breakpoint(struct task_struct *tsk);
82 static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
87 #else /* !CONFIG_HAVE_HW_BREAKPOINT */
89 static inline int __init init_hw_breakpoint(void) { return 0; }
91 static inline struct perf_event *
92 register_user_hw_breakpoint(struct perf_event_attr *attr,
93 perf_overflow_handler_t triggered,
95 struct task_struct *tsk) { return NULL; }
97 modify_user_hw_breakpoint(struct perf_event *bp,
98 struct perf_event_attr *attr) { return -ENOSYS; }
99 static inline struct perf_event *
100 register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
101 perf_overflow_handler_t triggered,
103 int cpu) { return NULL; }
104 static inline struct perf_event * __percpu *
105 register_wide_hw_breakpoint(struct perf_event_attr *attr,
106 perf_overflow_handler_t triggered,
107 void *context) { return NULL; }
109 register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
111 __register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
112 static inline void unregister_hw_breakpoint(struct perf_event *bp) { }
114 unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) { }
116 reserve_bp_slot(struct perf_event *bp) {return -ENOSYS; }
117 static inline void release_bp_slot(struct perf_event *bp) { }
119 static inline void flush_ptrace_hw_breakpoint(struct task_struct *tsk) { }
121 static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
126 #endif /* CONFIG_HAVE_HW_BREAKPOINT */
127 #endif /* _LINUX_HW_BREAKPOINT_H */