xref: /linux/include/linux/kprobes.h (revision f984ba4eb575e4a27ed28a76d4126d2aa9233c32)
11da177e4SLinus Torvalds #ifndef _LINUX_KPROBES_H
21da177e4SLinus Torvalds #define _LINUX_KPROBES_H
31da177e4SLinus Torvalds /*
41da177e4SLinus Torvalds  *  Kernel Probes (KProbes)
51da177e4SLinus Torvalds  *  include/linux/kprobes.h
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  * This program is free software; you can redistribute it and/or modify
81da177e4SLinus Torvalds  * it under the terms of the GNU General Public License as published by
91da177e4SLinus Torvalds  * the Free Software Foundation; either version 2 of the License, or
101da177e4SLinus Torvalds  * (at your option) any later version.
111da177e4SLinus Torvalds  *
121da177e4SLinus Torvalds  * This program is distributed in the hope that it will be useful,
131da177e4SLinus Torvalds  * but WITHOUT ANY WARRANTY; without even the implied warranty of
141da177e4SLinus Torvalds  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
151da177e4SLinus Torvalds  * GNU General Public License for more details.
161da177e4SLinus Torvalds  *
171da177e4SLinus Torvalds  * You should have received a copy of the GNU General Public License
181da177e4SLinus Torvalds  * along with this program; if not, write to the Free Software
191da177e4SLinus Torvalds  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
201da177e4SLinus Torvalds  *
211da177e4SLinus Torvalds  * Copyright (C) IBM Corporation, 2002, 2004
221da177e4SLinus Torvalds  *
231da177e4SLinus Torvalds  * 2002-Oct	Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
241da177e4SLinus Torvalds  *		Probes initial implementation ( includes suggestions from
251da177e4SLinus Torvalds  *		Rusty Russell).
261da177e4SLinus Torvalds  * 2004-July	Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
271da177e4SLinus Torvalds  *		interface to access function arguments.
28b94cce92SHien Nguyen  * 2005-May	Hien Nguyen <hien@us.ibm.com> and Jim Keniston
29b94cce92SHien Nguyen  *		<jkenisto@us.ibm.com>  and Prasanna S Panchamukhi
30b94cce92SHien Nguyen  *		<prasanna@in.ibm.com> added function-return probes.
311da177e4SLinus Torvalds  */
3236dcd67aSIngo Molnar #include <linux/linkage.h>
331da177e4SLinus Torvalds #include <linux/list.h>
341da177e4SLinus Torvalds #include <linux/notifier.h>
351da177e4SLinus Torvalds #include <linux/smp.h>
36e6584523SAnanth N Mavinakayanahalli #include <linux/percpu.h>
373516a460SAnanth N Mavinakayanahalli #include <linux/spinlock.h>
383516a460SAnanth N Mavinakayanahalli #include <linux/rcupdate.h>
397a7d1cf9SIngo Molnar #include <linux/mutex.h>
40b94cce92SHien Nguyen 
4100d7c05aSKeshavamurthy Anil S #ifdef CONFIG_KPROBES
421da177e4SLinus Torvalds #include <asm/kprobes.h>
431da177e4SLinus Torvalds 
44ea32c65cSPrasanna S Panchamukhi /* kprobe_status settings */
45ea32c65cSPrasanna S Panchamukhi #define KPROBE_HIT_ACTIVE	0x00000001
46ea32c65cSPrasanna S Panchamukhi #define KPROBE_HIT_SS		0x00000002
47ea32c65cSPrasanna S Panchamukhi #define KPROBE_REENTER		0x00000004
48ea32c65cSPrasanna S Panchamukhi #define KPROBE_HIT_SSDONE	0x00000008
49ea32c65cSPrasanna S Panchamukhi 
50d0aaff97SPrasanna S Panchamukhi /* Attach to insert probes on any functions which should be ignored*/
51fe832a3aSSteven Rostedt #define __kprobes	__attribute__((__section__(".kprobes.text")))
52dc19835dSMasami Hiramatsu #else /* CONFIG_KPROBES */
53dc19835dSMasami Hiramatsu typedef int kprobe_opcode_t;
54dc19835dSMasami Hiramatsu struct arch_specific_insn {
55dc19835dSMasami Hiramatsu 	int dummy;
56dc19835dSMasami Hiramatsu };
57fe832a3aSSteven Rostedt #define __kprobes
58dc19835dSMasami Hiramatsu #endif /* CONFIG_KPROBES */
59d0aaff97SPrasanna S Panchamukhi 
601da177e4SLinus Torvalds struct kprobe;
611da177e4SLinus Torvalds struct pt_regs;
62b94cce92SHien Nguyen struct kretprobe;
63b94cce92SHien Nguyen struct kretprobe_instance;
641da177e4SLinus Torvalds typedef int (*kprobe_pre_handler_t) (struct kprobe *, struct pt_regs *);
651da177e4SLinus Torvalds typedef int (*kprobe_break_handler_t) (struct kprobe *, struct pt_regs *);
661da177e4SLinus Torvalds typedef void (*kprobe_post_handler_t) (struct kprobe *, struct pt_regs *,
671da177e4SLinus Torvalds 				       unsigned long flags);
681da177e4SLinus Torvalds typedef int (*kprobe_fault_handler_t) (struct kprobe *, struct pt_regs *,
691da177e4SLinus Torvalds 				       int trapnr);
70b94cce92SHien Nguyen typedef int (*kretprobe_handler_t) (struct kretprobe_instance *,
71b94cce92SHien Nguyen 				    struct pt_regs *);
72b94cce92SHien Nguyen 
731da177e4SLinus Torvalds struct kprobe {
741da177e4SLinus Torvalds 	struct hlist_node hlist;
751da177e4SLinus Torvalds 
7664f562c6SAnanth N Mavinakayanahalli 	/* list of kprobes for multi-handler support */
7764f562c6SAnanth N Mavinakayanahalli 	struct list_head list;
7864f562c6SAnanth N Mavinakayanahalli 
79ea32c65cSPrasanna S Panchamukhi 	/*count the number of times this probe was temporarily disarmed */
80ea32c65cSPrasanna S Panchamukhi 	unsigned long nmissed;
81ea32c65cSPrasanna S Panchamukhi 
821da177e4SLinus Torvalds 	/* location of the probe point */
831da177e4SLinus Torvalds 	kprobe_opcode_t *addr;
841da177e4SLinus Torvalds 
853a872d89SAnanth N Mavinakayanahalli 	/* Allow user to indicate symbol name of the probe point */
869b3af29bSAnanth N Mavinakayanahalli 	const char *symbol_name;
873a872d89SAnanth N Mavinakayanahalli 
883a872d89SAnanth N Mavinakayanahalli 	/* Offset into the symbol */
893a872d89SAnanth N Mavinakayanahalli 	unsigned int offset;
903a872d89SAnanth N Mavinakayanahalli 
911da177e4SLinus Torvalds 	/* Called before addr is executed. */
921da177e4SLinus Torvalds 	kprobe_pre_handler_t pre_handler;
931da177e4SLinus Torvalds 
941da177e4SLinus Torvalds 	/* Called after addr is executed, unless... */
951da177e4SLinus Torvalds 	kprobe_post_handler_t post_handler;
961da177e4SLinus Torvalds 
97cc00e9cfSMasami Hiramatsu 	/*
98cc00e9cfSMasami Hiramatsu 	 * ... called if executing addr causes a fault (eg. page fault).
99cc00e9cfSMasami Hiramatsu 	 * Return 1 if it handled fault, otherwise kernel will see it.
100cc00e9cfSMasami Hiramatsu 	 */
1011da177e4SLinus Torvalds 	kprobe_fault_handler_t fault_handler;
1021da177e4SLinus Torvalds 
103cc00e9cfSMasami Hiramatsu 	/*
104cc00e9cfSMasami Hiramatsu 	 * ... called if breakpoint trap occurs in probe handler.
105cc00e9cfSMasami Hiramatsu 	 * Return 1 if it handled break, otherwise kernel will see it.
106cc00e9cfSMasami Hiramatsu 	 */
1071da177e4SLinus Torvalds 	kprobe_break_handler_t break_handler;
1081da177e4SLinus Torvalds 
1091da177e4SLinus Torvalds 	/* Saved opcode (which has been replaced with breakpoint) */
1101da177e4SLinus Torvalds 	kprobe_opcode_t opcode;
1111da177e4SLinus Torvalds 
1121da177e4SLinus Torvalds 	/* copy of the original instruction */
1131da177e4SLinus Torvalds 	struct arch_specific_insn ainsn;
114e8386a0cSMasami Hiramatsu 
115de5bd88dSMasami Hiramatsu 	/*
116de5bd88dSMasami Hiramatsu 	 * Indicates various status flags.
117de5bd88dSMasami Hiramatsu 	 * Protected by kprobe_mutex after this kprobe is registered.
118de5bd88dSMasami Hiramatsu 	 */
119e8386a0cSMasami Hiramatsu 	u32 flags;
1201da177e4SLinus Torvalds };
1211da177e4SLinus Torvalds 
122e8386a0cSMasami Hiramatsu /* Kprobe status flags */
123e8386a0cSMasami Hiramatsu #define KPROBE_FLAG_GONE	1 /* breakpoint has already gone */
124de5bd88dSMasami Hiramatsu #define KPROBE_FLAG_DISABLED	2 /* probe is temporarily disabled */
125afd66255SMasami Hiramatsu #define KPROBE_FLAG_OPTIMIZED	4 /*
126afd66255SMasami Hiramatsu 				   * probe is really optimized.
127afd66255SMasami Hiramatsu 				   * NOTE:
128afd66255SMasami Hiramatsu 				   * this flag is only for optimized_kprobe.
129afd66255SMasami Hiramatsu 				   */
130e8386a0cSMasami Hiramatsu 
131de5bd88dSMasami Hiramatsu /* Has this kprobe gone ? */
132e8386a0cSMasami Hiramatsu static inline int kprobe_gone(struct kprobe *p)
133e8386a0cSMasami Hiramatsu {
134e8386a0cSMasami Hiramatsu 	return p->flags & KPROBE_FLAG_GONE;
135e8386a0cSMasami Hiramatsu }
136e8386a0cSMasami Hiramatsu 
137de5bd88dSMasami Hiramatsu /* Is this kprobe disabled ? */
138de5bd88dSMasami Hiramatsu static inline int kprobe_disabled(struct kprobe *p)
139de5bd88dSMasami Hiramatsu {
140de5bd88dSMasami Hiramatsu 	return p->flags & (KPROBE_FLAG_DISABLED | KPROBE_FLAG_GONE);
141de5bd88dSMasami Hiramatsu }
142afd66255SMasami Hiramatsu 
143afd66255SMasami Hiramatsu /* Is this kprobe really running optimized path ? */
144afd66255SMasami Hiramatsu static inline int kprobe_optimized(struct kprobe *p)
145afd66255SMasami Hiramatsu {
146afd66255SMasami Hiramatsu 	return p->flags & KPROBE_FLAG_OPTIMIZED;
147afd66255SMasami Hiramatsu }
1481da177e4SLinus Torvalds /*
1491da177e4SLinus Torvalds  * Special probe type that uses setjmp-longjmp type tricks to resume
1501da177e4SLinus Torvalds  * execution at a specified entry with a matching prototype corresponding
1511da177e4SLinus Torvalds  * to the probed function - a trick to enable arguments to become
1521da177e4SLinus Torvalds  * accessible seamlessly by probe handling logic.
1531da177e4SLinus Torvalds  * Note:
1541da177e4SLinus Torvalds  * Because of the way compilers allocate stack space for local variables
1551da177e4SLinus Torvalds  * etc upfront, regardless of sub-scopes within a function, this mirroring
1561da177e4SLinus Torvalds  * principle currently works only for probes placed on function entry points.
1571da177e4SLinus Torvalds  */
1581da177e4SLinus Torvalds struct jprobe {
1591da177e4SLinus Torvalds 	struct kprobe kp;
16081eae375SMichael Ellerman 	void *entry;	/* probe handling code to jump to */
1611da177e4SLinus Torvalds };
1621da177e4SLinus Torvalds 
1639e367d85SMichael Ellerman /* For backward compatibility with old code using JPROBE_ENTRY() */
1649e367d85SMichael Ellerman #define JPROBE_ENTRY(handler)	(handler)
1659e367d85SMichael Ellerman 
166b94cce92SHien Nguyen /*
167b94cce92SHien Nguyen  * Function-return probe -
168b94cce92SHien Nguyen  * Note:
169b94cce92SHien Nguyen  * User needs to provide a handler function, and initialize maxactive.
170b94cce92SHien Nguyen  * maxactive - The maximum number of instances of the probed function that
171b94cce92SHien Nguyen  * can be active concurrently.
172b94cce92SHien Nguyen  * nmissed - tracks the number of times the probed function's return was
173b94cce92SHien Nguyen  * ignored, due to maxactive being too low.
174b94cce92SHien Nguyen  *
175b94cce92SHien Nguyen  */
176b94cce92SHien Nguyen struct kretprobe {
177b94cce92SHien Nguyen 	struct kprobe kp;
178b94cce92SHien Nguyen 	kretprobe_handler_t handler;
179f47cd9b5SAbhishek Sagar 	kretprobe_handler_t entry_handler;
180b94cce92SHien Nguyen 	int maxactive;
181b94cce92SHien Nguyen 	int nmissed;
182f47cd9b5SAbhishek Sagar 	size_t data_size;
183b94cce92SHien Nguyen 	struct hlist_head free_instances;
184ef53d9c5SSrinivasa D S 	spinlock_t lock;
185b94cce92SHien Nguyen };
186b94cce92SHien Nguyen 
187b94cce92SHien Nguyen struct kretprobe_instance {
188b94cce92SHien Nguyen 	struct hlist_node hlist;
189b94cce92SHien Nguyen 	struct kretprobe *rp;
190802eae7cSRusty Lynch 	kprobe_opcode_t *ret_addr;
191802eae7cSRusty Lynch 	struct task_struct *task;
192f47cd9b5SAbhishek Sagar 	char data[0];
193b94cce92SHien Nguyen };
194b94cce92SHien Nguyen 
195f438d914SMasami Hiramatsu struct kretprobe_blackpoint {
196f438d914SMasami Hiramatsu 	const char *name;
197f438d914SMasami Hiramatsu 	void *addr;
198f438d914SMasami Hiramatsu };
1993d8d996eSSrinivasa Ds 
2003d8d996eSSrinivasa Ds struct kprobe_blackpoint {
2013d8d996eSSrinivasa Ds 	const char *name;
2023d8d996eSSrinivasa Ds 	unsigned long start_addr;
2033d8d996eSSrinivasa Ds 	unsigned long range;
2043d8d996eSSrinivasa Ds };
2053d8d996eSSrinivasa Ds 
206dc19835dSMasami Hiramatsu #ifdef CONFIG_KPROBES
207dc19835dSMasami Hiramatsu DECLARE_PER_CPU(struct kprobe *, current_kprobe);
208dc19835dSMasami Hiramatsu DECLARE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
209dc19835dSMasami Hiramatsu 
210b1801812SIngo Molnar /*
211b1801812SIngo Molnar  * For #ifdef avoidance:
212b1801812SIngo Molnar  */
213b1801812SIngo Molnar static inline int kprobes_built_in(void)
214b1801812SIngo Molnar {
215b1801812SIngo Molnar 	return 1;
216b1801812SIngo Molnar }
217b1801812SIngo Molnar 
218dc19835dSMasami Hiramatsu #ifdef CONFIG_KRETPROBES
219dc19835dSMasami Hiramatsu extern void arch_prepare_kretprobe(struct kretprobe_instance *ri,
220dc19835dSMasami Hiramatsu 				   struct pt_regs *regs);
221dc19835dSMasami Hiramatsu extern int arch_trampoline_kprobe(struct kprobe *p);
222dc19835dSMasami Hiramatsu #else /* CONFIG_KRETPROBES */
223dc19835dSMasami Hiramatsu static inline void arch_prepare_kretprobe(struct kretprobe *rp,
224dc19835dSMasami Hiramatsu 					struct pt_regs *regs)
225dc19835dSMasami Hiramatsu {
226dc19835dSMasami Hiramatsu }
227dc19835dSMasami Hiramatsu static inline int arch_trampoline_kprobe(struct kprobe *p)
228dc19835dSMasami Hiramatsu {
229dc19835dSMasami Hiramatsu 	return 0;
230dc19835dSMasami Hiramatsu }
231dc19835dSMasami Hiramatsu #endif /* CONFIG_KRETPROBES */
232dc19835dSMasami Hiramatsu 
233f438d914SMasami Hiramatsu extern struct kretprobe_blackpoint kretprobe_blacklist[];
234f438d914SMasami Hiramatsu 
2350f95b7fcSAnanth N Mavinakayanahalli static inline void kretprobe_assert(struct kretprobe_instance *ri,
2360f95b7fcSAnanth N Mavinakayanahalli 	unsigned long orig_ret_address, unsigned long trampoline_address)
2370f95b7fcSAnanth N Mavinakayanahalli {
2380f95b7fcSAnanth N Mavinakayanahalli 	if (!orig_ret_address || (orig_ret_address == trampoline_address)) {
2390f95b7fcSAnanth N Mavinakayanahalli 		printk("kretprobe BUG!: Processing kretprobe %p @ %p\n",
2400f95b7fcSAnanth N Mavinakayanahalli 				ri->rp, ri->rp->kp.addr);
2410f95b7fcSAnanth N Mavinakayanahalli 		BUG();
2420f95b7fcSAnanth N Mavinakayanahalli 	}
2430f95b7fcSAnanth N Mavinakayanahalli }
2440f95b7fcSAnanth N Mavinakayanahalli 
2458c1c9356SAnanth N Mavinakayanahalli #ifdef CONFIG_KPROBES_SANITY_TEST
2468c1c9356SAnanth N Mavinakayanahalli extern int init_test_probes(void);
2478c1c9356SAnanth N Mavinakayanahalli #else
2488c1c9356SAnanth N Mavinakayanahalli static inline int init_test_probes(void)
2498c1c9356SAnanth N Mavinakayanahalli {
2508c1c9356SAnanth N Mavinakayanahalli 	return 0;
2518c1c9356SAnanth N Mavinakayanahalli }
2528c1c9356SAnanth N Mavinakayanahalli #endif /* CONFIG_KPROBES_SANITY_TEST */
2538c1c9356SAnanth N Mavinakayanahalli 
2541da177e4SLinus Torvalds extern int arch_prepare_kprobe(struct kprobe *p);
2557e1048b1SRusty Lynch extern void arch_arm_kprobe(struct kprobe *p);
2567e1048b1SRusty Lynch extern void arch_disarm_kprobe(struct kprobe *p);
2576772926bSRusty Lynch extern int arch_init_kprobes(void);
2581da177e4SLinus Torvalds extern void show_registers(struct pt_regs *regs);
2599ec4b1f3SAnanth N Mavinakayanahalli extern kprobe_opcode_t *get_insn_slot(void);
260b4c6c34aSMasami Hiramatsu extern void free_insn_slot(kprobe_opcode_t *slot, int dirty);
261bf8d5c52SKeshavamurthy Anil S extern void kprobes_inc_nmissed_count(struct kprobe *p);
2621da177e4SLinus Torvalds 
263afd66255SMasami Hiramatsu #ifdef CONFIG_OPTPROBES
264afd66255SMasami Hiramatsu /*
265afd66255SMasami Hiramatsu  * Internal structure for direct jump optimized probe
266afd66255SMasami Hiramatsu  */
267afd66255SMasami Hiramatsu struct optimized_kprobe {
268afd66255SMasami Hiramatsu 	struct kprobe kp;
269afd66255SMasami Hiramatsu 	struct list_head list;	/* list for optimizing queue */
270afd66255SMasami Hiramatsu 	struct arch_optimized_insn optinsn;
271afd66255SMasami Hiramatsu };
272afd66255SMasami Hiramatsu 
273afd66255SMasami Hiramatsu /* Architecture dependent functions for direct jump optimization */
274afd66255SMasami Hiramatsu extern int arch_prepared_optinsn(struct arch_optimized_insn *optinsn);
275afd66255SMasami Hiramatsu extern int arch_check_optimized_kprobe(struct optimized_kprobe *op);
276afd66255SMasami Hiramatsu extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op);
277afd66255SMasami Hiramatsu extern void arch_remove_optimized_kprobe(struct optimized_kprobe *op);
278cd7ebe22SMasami Hiramatsu extern void arch_optimize_kprobes(struct list_head *oplist);
279*f984ba4eSMasami Hiramatsu extern void arch_unoptimize_kprobes(struct list_head *oplist,
280*f984ba4eSMasami Hiramatsu 				    struct list_head *done_list);
281afd66255SMasami Hiramatsu extern void arch_unoptimize_kprobe(struct optimized_kprobe *op);
282afd66255SMasami Hiramatsu extern kprobe_opcode_t *get_optinsn_slot(void);
283afd66255SMasami Hiramatsu extern void free_optinsn_slot(kprobe_opcode_t *slot, int dirty);
284afd66255SMasami Hiramatsu extern int arch_within_optimized_kprobe(struct optimized_kprobe *op,
285afd66255SMasami Hiramatsu 					unsigned long addr);
286afd66255SMasami Hiramatsu 
287afd66255SMasami Hiramatsu extern void opt_pre_handler(struct kprobe *p, struct pt_regs *regs);
288b2be84dfSMasami Hiramatsu 
289b2be84dfSMasami Hiramatsu #ifdef CONFIG_SYSCTL
290b2be84dfSMasami Hiramatsu extern int sysctl_kprobes_optimization;
291b2be84dfSMasami Hiramatsu extern int proc_kprobes_optimization_handler(struct ctl_table *table,
292b2be84dfSMasami Hiramatsu 					     int write, void __user *buffer,
293b2be84dfSMasami Hiramatsu 					     size_t *length, loff_t *ppos);
294b2be84dfSMasami Hiramatsu #endif
295b2be84dfSMasami Hiramatsu 
296afd66255SMasami Hiramatsu #endif /* CONFIG_OPTPROBES */
297afd66255SMasami Hiramatsu 
298d217d545SAnanth N Mavinakayanahalli /* Get the kprobe at this addr (if any) - called with preemption disabled */
2991da177e4SLinus Torvalds struct kprobe *get_kprobe(void *addr);
300ef53d9c5SSrinivasa D S void kretprobe_hash_lock(struct task_struct *tsk,
301ef53d9c5SSrinivasa D S 			 struct hlist_head **head, unsigned long *flags);
302ef53d9c5SSrinivasa D S void kretprobe_hash_unlock(struct task_struct *tsk, unsigned long *flags);
303b94cce92SHien Nguyen struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk);
3041da177e4SLinus Torvalds 
305e6584523SAnanth N Mavinakayanahalli /* kprobe_running() will just return the current_kprobe on this CPU */
306e6584523SAnanth N Mavinakayanahalli static inline struct kprobe *kprobe_running(void)
307e6584523SAnanth N Mavinakayanahalli {
308e6584523SAnanth N Mavinakayanahalli 	return (__get_cpu_var(current_kprobe));
309e6584523SAnanth N Mavinakayanahalli }
310e6584523SAnanth N Mavinakayanahalli 
311e6584523SAnanth N Mavinakayanahalli static inline void reset_current_kprobe(void)
312e6584523SAnanth N Mavinakayanahalli {
313e6584523SAnanth N Mavinakayanahalli 	__get_cpu_var(current_kprobe) = NULL;
314e6584523SAnanth N Mavinakayanahalli }
315e6584523SAnanth N Mavinakayanahalli 
316e6584523SAnanth N Mavinakayanahalli static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
317e6584523SAnanth N Mavinakayanahalli {
318e6584523SAnanth N Mavinakayanahalli 	return (&__get_cpu_var(kprobe_ctlblk));
319e6584523SAnanth N Mavinakayanahalli }
320e6584523SAnanth N Mavinakayanahalli 
3211da177e4SLinus Torvalds int register_kprobe(struct kprobe *p);
3221da177e4SLinus Torvalds void unregister_kprobe(struct kprobe *p);
3239861668fSMasami Hiramatsu int register_kprobes(struct kprobe **kps, int num);
3249861668fSMasami Hiramatsu void unregister_kprobes(struct kprobe **kps, int num);
3251da177e4SLinus Torvalds int setjmp_pre_handler(struct kprobe *, struct pt_regs *);
3261da177e4SLinus Torvalds int longjmp_break_handler(struct kprobe *, struct pt_regs *);
3271da177e4SLinus Torvalds int register_jprobe(struct jprobe *p);
3281da177e4SLinus Torvalds void unregister_jprobe(struct jprobe *p);
32926b31c19SMasami Hiramatsu int register_jprobes(struct jprobe **jps, int num);
33026b31c19SMasami Hiramatsu void unregister_jprobes(struct jprobe **jps, int num);
3311da177e4SLinus Torvalds void jprobe_return(void);
3323d7e3382SMichael Ellerman unsigned long arch_deref_entry_point(void *);
3331da177e4SLinus Torvalds 
334b94cce92SHien Nguyen int register_kretprobe(struct kretprobe *rp);
335b94cce92SHien Nguyen void unregister_kretprobe(struct kretprobe *rp);
3364a296e07SMasami Hiramatsu int register_kretprobes(struct kretprobe **rps, int num);
3374a296e07SMasami Hiramatsu void unregister_kretprobes(struct kretprobe **rps, int num);
338b94cce92SHien Nguyen 
339b94cce92SHien Nguyen void kprobe_flush_task(struct task_struct *tk);
34099219a3fSbibo,mao void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head);
3418c1c9356SAnanth N Mavinakayanahalli 
342de5bd88dSMasami Hiramatsu int disable_kprobe(struct kprobe *kp);
343de5bd88dSMasami Hiramatsu int enable_kprobe(struct kprobe *kp);
344de5bd88dSMasami Hiramatsu 
34524851d24SFrederic Weisbecker void dump_kprobe(struct kprobe *kp);
34624851d24SFrederic Weisbecker 
347b1801812SIngo Molnar #else /* !CONFIG_KPROBES: */
34800d7c05aSKeshavamurthy Anil S 
349b1801812SIngo Molnar static inline int kprobes_built_in(void)
350b1801812SIngo Molnar {
351b1801812SIngo Molnar 	return 0;
352b1801812SIngo Molnar }
353b1801812SIngo Molnar static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
354b1801812SIngo Molnar {
355b1801812SIngo Molnar 	return 0;
356b1801812SIngo Molnar }
357785656a4SAbhishek Sagar static inline struct kprobe *get_kprobe(void *addr)
358785656a4SAbhishek Sagar {
359785656a4SAbhishek Sagar 	return NULL;
360785656a4SAbhishek Sagar }
361e6584523SAnanth N Mavinakayanahalli static inline struct kprobe *kprobe_running(void)
3621da177e4SLinus Torvalds {
363e6584523SAnanth N Mavinakayanahalli 	return NULL;
3641da177e4SLinus Torvalds }
3651da177e4SLinus Torvalds static inline int register_kprobe(struct kprobe *p)
3661da177e4SLinus Torvalds {
3671da177e4SLinus Torvalds 	return -ENOSYS;
3681da177e4SLinus Torvalds }
3699861668fSMasami Hiramatsu static inline int register_kprobes(struct kprobe **kps, int num)
3709861668fSMasami Hiramatsu {
3719861668fSMasami Hiramatsu 	return -ENOSYS;
3729861668fSMasami Hiramatsu }
3731da177e4SLinus Torvalds static inline void unregister_kprobe(struct kprobe *p)
3741da177e4SLinus Torvalds {
3751da177e4SLinus Torvalds }
3769861668fSMasami Hiramatsu static inline void unregister_kprobes(struct kprobe **kps, int num)
3779861668fSMasami Hiramatsu {
3789861668fSMasami Hiramatsu }
3791da177e4SLinus Torvalds static inline int register_jprobe(struct jprobe *p)
3801da177e4SLinus Torvalds {
3811da177e4SLinus Torvalds 	return -ENOSYS;
3821da177e4SLinus Torvalds }
38326b31c19SMasami Hiramatsu static inline int register_jprobes(struct jprobe **jps, int num)
38426b31c19SMasami Hiramatsu {
38526b31c19SMasami Hiramatsu 	return -ENOSYS;
38626b31c19SMasami Hiramatsu }
3871da177e4SLinus Torvalds static inline void unregister_jprobe(struct jprobe *p)
3881da177e4SLinus Torvalds {
3891da177e4SLinus Torvalds }
39026b31c19SMasami Hiramatsu static inline void unregister_jprobes(struct jprobe **jps, int num)
39126b31c19SMasami Hiramatsu {
39226b31c19SMasami Hiramatsu }
3931da177e4SLinus Torvalds static inline void jprobe_return(void)
3941da177e4SLinus Torvalds {
3951da177e4SLinus Torvalds }
396b94cce92SHien Nguyen static inline int register_kretprobe(struct kretprobe *rp)
397b94cce92SHien Nguyen {
398b94cce92SHien Nguyen 	return -ENOSYS;
399b94cce92SHien Nguyen }
4004a296e07SMasami Hiramatsu static inline int register_kretprobes(struct kretprobe **rps, int num)
4014a296e07SMasami Hiramatsu {
4024a296e07SMasami Hiramatsu 	return -ENOSYS;
4034a296e07SMasami Hiramatsu }
404b94cce92SHien Nguyen static inline void unregister_kretprobe(struct kretprobe *rp)
405b94cce92SHien Nguyen {
406b94cce92SHien Nguyen }
4074a296e07SMasami Hiramatsu static inline void unregister_kretprobes(struct kretprobe **rps, int num)
4084a296e07SMasami Hiramatsu {
4094a296e07SMasami Hiramatsu }
410b94cce92SHien Nguyen static inline void kprobe_flush_task(struct task_struct *tk)
411b94cce92SHien Nguyen {
412b94cce92SHien Nguyen }
413de5bd88dSMasami Hiramatsu static inline int disable_kprobe(struct kprobe *kp)
414de5bd88dSMasami Hiramatsu {
415de5bd88dSMasami Hiramatsu 	return -ENOSYS;
416de5bd88dSMasami Hiramatsu }
417de5bd88dSMasami Hiramatsu static inline int enable_kprobe(struct kprobe *kp)
418de5bd88dSMasami Hiramatsu {
419de5bd88dSMasami Hiramatsu 	return -ENOSYS;
420de5bd88dSMasami Hiramatsu }
421b94cce92SHien Nguyen #endif /* CONFIG_KPROBES */
4228f9b1528SMasami Hiramatsu static inline int disable_kretprobe(struct kretprobe *rp)
4238f9b1528SMasami Hiramatsu {
4248f9b1528SMasami Hiramatsu 	return disable_kprobe(&rp->kp);
4258f9b1528SMasami Hiramatsu }
4268f9b1528SMasami Hiramatsu static inline int enable_kretprobe(struct kretprobe *rp)
4278f9b1528SMasami Hiramatsu {
4288f9b1528SMasami Hiramatsu 	return enable_kprobe(&rp->kp);
4298f9b1528SMasami Hiramatsu }
4308f9b1528SMasami Hiramatsu static inline int disable_jprobe(struct jprobe *jp)
4318f9b1528SMasami Hiramatsu {
4328f9b1528SMasami Hiramatsu 	return disable_kprobe(&jp->kp);
4338f9b1528SMasami Hiramatsu }
4348f9b1528SMasami Hiramatsu static inline int enable_jprobe(struct jprobe *jp)
4358f9b1528SMasami Hiramatsu {
4368f9b1528SMasami Hiramatsu 	return enable_kprobe(&jp->kp);
4378f9b1528SMasami Hiramatsu }
4388f9b1528SMasami Hiramatsu 
4391da177e4SLinus Torvalds #endif /* _LINUX_KPROBES_H */
440