2 #ifndef _SRC_ASM_KPROBES_H
3 #define _SRC_ASM_KPROBES_H
5 #include <linux/version.h>
6 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
7 #include <linux/config.h>
11 //#define KPROBES_RET_PROBE_TRAMP
12 //#define KPROBES_PROFILE
17 #define DBPRINTF(format, args...) do { \
20 char *n = strrchr(f, '/'); \
21 printk("%s : %u : %s : " format "\n" , (n) ? n+1 : f, __LINE__, __FUNCTION__, ##args); \
25 #define DBPRINTF(format, args...)
28 #if defined(CONFIG_MIPS)
29 typedef unsigned long kprobe_opcode_t;
30 # define BREAKPOINT_INSTRUCTION 0x0000000d
31 # ifndef KPROBES_RET_PROBE_TRAMP
32 # define UNDEF_INSTRUCTION 0x0000004d
34 #elif defined(CONFIG_ARM)
35 typedef unsigned long kprobe_opcode_t;
36 # ifdef CONFIG_CPU_S3C2443
37 # define BREAKPOINT_INSTRUCTION 0xe1200070
39 # define BREAKPOINT_INSTRUCTION 0xffffffff
41 # ifndef KPROBES_RET_PROBE_TRAMP
42 # ifdef CONFIG_CPU_S3C2443
43 # define UNDEF_INSTRUCTION 0xe1200071
45 # define UNDEF_INSTRUCTION 0xfffffffe
48 #elif defined(CONFIG_X86)
49 typedef u8 kprobe_opcode_t;
50 # define BREAKPOINT_INSTRUCTION 0xcc
51 # define RELATIVEJUMP_INSTRUCTION 0xe9
52 /*# define UNDEF_INSTRUCTION 0xff
53 # warning UNDEF_INSTRUCTION is not defined for x86 arch!!!*/
55 # error BREAKPOINT_INSTRUCTION is not defined for this arch!!!
56 # error UNDEF_INSTRUCTION is not defined for this arch!!!
59 #if defined(CONFIG_X86)
60 # define MAX_INSN_SIZE 16
61 # define MAX_STACK_SIZE 64
62 # define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
63 (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \
65 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
67 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
68 # define EREG(rg) e##rg
69 # define XREG(rg) x##rg
70 # define ORIG_EAX_REG orig_eax
74 # define ORIG_EAX_REG orig_ax
77 # define MAX_INSN_SIZE 1
80 #define flush_insn_slot(p) do { } while (0)
82 #define kprobe_lookup_name(name, addr)
84 /* Architecture specific copy of original instruction */
85 struct arch_specific_insn {
86 /* copy of the original instruction */
87 kprobe_opcode_t *insn;
89 * If this flag is not 0, this kprobe can be boost when its
90 * post_handler and break_handler is not set.
95 #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
100 #if defined(CONFIG_X86)
101 unsigned long old_eflags;
102 unsigned long saved_eflags;
106 /* per-cpu kprobe control block */
107 struct kprobe_ctlblk {
108 unsigned long kprobe_status;
109 struct prev_kprobe prev_kprobe;
110 #if defined(CONFIG_X86)
111 struct pt_regs jprobe_saved_regs;
112 unsigned long kprobe_old_eflags;
113 unsigned long kprobe_saved_eflags;
114 unsigned long *jprobe_saved_esp;
115 kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
119 void kretprobe_trampoline (void);
121 extern int kprobe_handler (struct pt_regs *regs);
122 extern int page_present (struct mm_struct *mm, unsigned long addr);
124 #if defined(CONFIG_X86)
125 extern int kprobe_exceptions_notify (struct notifier_block *self, unsigned long val, void *data);
128 #endif /* _SRC_ASM_KPROBES_H */