57b9f64771eb24133edac7ae5454a84cb1ce7538
[kernel/swap-modules.git] / kprobe / dbi_kprobes_deps.h
1 #ifndef _DBI_KPROBES_DEPS_H
2 #define _DBI_KPROBES_DEPS_H
3
4 /*
5  *  Dynamic Binary Instrumentation Module based on KProbes
6  *  modules/kprobe/dbi_kprobes_deps.h
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  *
22  * Copyright (C) Samsung Electronics, 2006-2010
23  *
24  * 2008-2009    Alexey Gerenkov <a.gerenkov@samsung.com> User-Space
25  *              Probes initial implementation; Support x86/ARM/MIPS for both user and kernel spaces.
26  * 2010         Ekaterina Gorelkina <e.gorelkina@samsung.com>: redesign module for separating core and arch parts 
27  *
28
29  */
30
31 #include <linux/version.h>      // LINUX_VERSION_CODE, KERNEL_VERSION()
32 #include <linux/hugetlb.h>
33 #include <linux/mempolicy.h>
34 #include <linux/highmem.h>
35 #include <linux/pagemap.h>
36
37
38 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12))
39 #define synchronize_sched       synchronize_kernel
40 #endif
41
42 //--------------------- Declaration of module dependencies ------------------------//
43
44 #define DECLARE_MOD_FUNC_DEP(name, ret, ...) ret(*__ref_##name)(__VA_ARGS__)
45 #define DECLARE_MOD_CB_DEP(name, ret, ...) ret(*name)(__VA_ARGS__)
46
47
48 //----------------- Implementation of module dependencies wrappers -----------------//
49
50 #define DECLARE_MOD_DEP_WRAPPER(name, ret, ...) ret name(__VA_ARGS__)
51 #define IMP_MOD_DEP_WRAPPER(name, ...) \
52 { \
53         return __ref_##name(__VA_ARGS__); \
54 }
55
56
57 //---------------------- Module dependencies initialization --------------------//
58
59 #define INIT_MOD_DEP_VAR(dep, name) \
60 { \
61         __ref_##dep = (void *) kallsyms_search (#name); \
62         if (!__ref_##dep) \
63         { \
64                 DBPRINTF (#name " is not found! Oops. Where is it?"); \
65                 return -ESRCH; \
66         } \
67 }
68
69 #define INIT_MOD_DEP_CB(dep, name) \
70 { \
71         dep = (void *) kallsyms_search (#name); \
72         if (!dep) \
73         { \
74                 DBPRINTF (#name " is not found! Oops. Where is it?"); \
75                 return -ESRCH; \
76         } \
77 }
78
79
80 int init_module_dependencies(void);
81
82 int access_process_vm_atomic(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
83 int get_user_pages_uprobe(struct task_struct *tsk, struct mm_struct *mm,
84                 unsigned long start, int len, int write, int force,
85                 struct page **pages, struct vm_area_struct **vmas);
86
87 #define read_proc_vm_atomic(tsk, addr, buf, len)        access_process_vm_atomic (tsk, addr, buf, len, 0)
88 #define write_proc_vm_atomic(tsk, addr, buf, len)       access_process_vm_atomic (tsk, addr, buf, len, 1)
89 int page_present (struct mm_struct *mm, unsigned long addr);
90
91 #define get_user_pages_atomic  get_user_pages_uprobe
92
93
94
95 #endif /* _DBI_KPROBES_DEPS_H */