a89af747288e258707a8ea4680abe7a42460ef55
[kernel/swap-modules.git] / uprobe / arch / asm-arm / swap_uprobes.h
1 /*
2  *  Dynamic Binary Instrumentation Module based on KProbes
3  *  modules/uprobe/arch/asm-arm/swap_uprobes.h
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Copyright (C) Samsung Electronics, 2006-2010
20  *
21  * 2008-2009    Alexey Gerenkov <a.gerenkov@samsung.com> User-Space
22  *              Probes initial implementation; Support x86/ARM/MIPS for both user and kernel spaces.
23  * 2010         Ekaterina Gorelkina <e.gorelkina@samsung.com>: redesign module for separating core and arch parts
24  *
25  */
26
27
28 #ifndef _ARM_SWAP_UPROBES_H
29 #define _ARM_SWAP_UPROBES_H
30
31
32 struct kprobe;
33 struct task_struct;
34 struct uprobe;
35 struct uretprobe;
36 struct uretprobe_instance;
37
38
39 struct arch_specific_tramp {
40         unsigned long tramp_arm[UPROBES_TRAMP_LEN];
41         unsigned long tramp_thumb[UPROBES_TRAMP_LEN];
42         void *utramp;
43 };
44
45
46 static inline u32 swap_get_urp_float(struct pt_regs *regs)
47 {
48         return regs->ARM_r0;
49 }
50
51 static inline u64 swap_get_urp_double(struct pt_regs *regs)
52 {
53
54         return regs->ARM_r0 | (u64)regs->ARM_r1 << 32;
55 }
56
57 static inline void arch_ujprobe_return(void)
58 {
59 }
60
61 int arch_prepare_uprobe(struct uprobe *up);
62
63 int setjmp_upre_handler(struct kprobe *p, struct pt_regs *regs);
64 static inline int longjmp_break_uhandler(struct kprobe *p, struct pt_regs *regs)
65 {
66         return 0;
67 }
68
69 void arch_opcode_analysis_uretprobe(struct uretprobe *rp);
70 void arch_prepare_uretprobe(struct uretprobe_instance *ri, struct pt_regs *regs);
71 int arch_disarm_urp_inst(struct uretprobe_instance *ri,
72                          struct task_struct *task);
73
74 unsigned long arch_get_trampoline_addr(struct kprobe *p, struct pt_regs *regs);
75 void arch_set_orig_ret_addr(unsigned long orig_ret_addr, struct pt_regs *regs);
76 void arch_remove_uprobe(struct uprobe *up);
77
78 static inline unsigned long swap_get_uarg(struct pt_regs *regs, unsigned long n)
79 {
80         u32 *ptr, addr = 0;
81
82         switch (n) {
83         case 0:
84                 return regs->ARM_r0;
85         case 1:
86                 return regs->ARM_r1;
87         case 2:
88                 return regs->ARM_r2;
89         case 3:
90                 return regs->ARM_r3;
91         }
92
93         ptr = (u32 *)regs->ARM_sp + n - 4;
94         if (get_user(addr, ptr))
95                 printk("failed to dereference a pointer, ptr=%p\n", ptr);
96
97         return addr;
98 }
99
100 int swap_arch_init_uprobes(void);
101 void swap_arch_exit_uprobes(void);
102
103 #endif /* _ARM_SWAP_UPROBES_H */