1 #ifndef _DBI_KPROBES_DEPS_H
2 #define _DBI_KPROBES_DEPS_H
5 * Dynamic Binary Instrumentation Module based on KProbes
6 * modules/kprobe/dbi_kprobes_deps.h
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.
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.
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.
22 * Copyright (C) Samsung Electronics, 2006-2010
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
30 #include <linux/version.h> // LINUX_VERSION_CODE, KERNEL_VERSION()
31 #include <linux/hugetlb.h>
32 #include <linux/mempolicy.h>
33 #include <linux/highmem.h>
34 #include <linux/pagemap.h>
35 #include "../ksyms/ksyms.h"
37 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
38 #define swap_hlist_for_each_entry_rcu(tpos, pos, head, member) hlist_for_each_entry_rcu(tpos, head, member)
39 #define swap_hlist_for_each_entry_safe(tpos, pos, n, head, member) hlist_for_each_entry_safe(tpos, n, head, member)
40 #define swap_hlist_for_each_entry(tpos, pos, head, member) hlist_for_each_entry(tpos, head, member)
41 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) */
42 #define swap_hlist_for_each_entry_rcu(tpos, pos, head, member) hlist_for_each_entry_rcu(tpos, pos, head, member)
43 #define swap_hlist_for_each_entry_safe(tpos, pos, n, head, member) hlist_for_each_entry_safe(tpos, pos, n, head, member)
44 #define swap_hlist_for_each_entry(tpos, pos, head, member) hlist_for_each_entry(tpos, pos, head, member)
45 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) */
47 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12))
48 #define synchronize_sched synchronize_kernel
51 //--------------------- Declaration of module dependencies ------------------------//
53 #define DECLARE_MOD_FUNC_DEP(name, ret, ...) ret(*__ref_##name)(__VA_ARGS__)
54 #define DECLARE_MOD_CB_DEP(name, ret, ...) ret(*name)(__VA_ARGS__)
57 //----------------- Implementation of module dependencies wrappers -----------------//
59 #define DECLARE_MOD_DEP_WRAPPER(name, ret, ...) ret name(__VA_ARGS__)
60 #define IMP_MOD_DEP_WRAPPER(name, ...) \
62 return __ref_##name(__VA_ARGS__); \
66 //---------------------- Module dependencies initialization --------------------//
68 #define INIT_MOD_DEP_VAR(dep, name) \
70 __ref_##dep = (void *) swap_ksyms (#name); \
73 DBPRINTF (#name " is not found! Oops. Where is it?"); \
78 #define INIT_MOD_DEP_CB(dep, name) \
80 dep = (void *) swap_ksyms (#name); \
83 DBPRINTF (#name " is not found! Oops. Where is it?"); \
89 int init_module_dependencies(void);
91 int access_process_vm_atomic(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
93 #define read_proc_vm_atomic(tsk, addr, buf, len) access_process_vm_atomic (tsk, addr, buf, len, 0)
94 #define write_proc_vm_atomic(tsk, addr, buf, len) access_process_vm_atomic (tsk, addr, buf, len, 1)
95 int page_present (struct mm_struct *mm, unsigned long addr);
97 extern unsigned long sched_addr;
98 extern unsigned long fork_addr;
99 extern unsigned long exit_addr;
102 DECLARE_MOD_DEP_WRAPPER (__flush_anon_page, \
103 void, struct vm_area_struct *vma, \
104 struct page *page, unsigned long vmaddr);
106 DECLARE_MOD_DEP_WRAPPER(flush_ptrace_access, \
107 void, struct vm_area_struct *vma, struct page *page, \
108 unsigned long uaddr, void *kaddr, unsigned long len, int write);
110 #endif /* _DBI_KPROBES_DEPS_H */