5 * Dynamic Binary Instrumentation Module based on KProbes
6 * modules/driver/sspt/sspt.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, 2013
24 * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
29 #include "sspt_page.h"
30 #include "sspt_file.h"
31 #include "sspt_proc.h"
32 #include "sspt_debug.h"
33 #include <uprobe/swap_uprobes.h>
36 #include <us_manager/us_manager.h>
37 #include <us_manager/pf/pf_group.h>
38 #include <us_manager/probes/use_probes.h>
41 static inline int check_vma(struct vm_area_struct *vma)
43 return vma->vm_file &&
44 !(vma->vm_pgoff != 0 ||
45 !(vma->vm_flags & VM_EXEC) ||
46 !(vma->vm_flags & (VM_READ | VM_MAYREAD)));
49 static inline int sspt_register_usprobe(struct us_ip *ip)
52 struct uprobe *up = NULL;
54 up = probe_info_get_uprobe(ip->desc->type, ip);
57 printk(KERN_INFO "SWAP US_MANAGER: failed getting uprobe!\n");
61 up->addr = (kprobe_opcode_t *)ip->orig_addr;
62 up->task = ip->page->file->proc->task;
63 up->sm = ip->page->file->proc->sm;
64 up->atomic_ctx = true;
66 ret = probe_info_register(ip->desc->type, ip);
68 struct sspt_file *file = ip->page->file;
69 char *name = file->dentry->d_iname;
70 unsigned long addr = (unsigned long)up->addr;
71 unsigned long offset = addr - file->vm_start;
73 printk(KERN_ERR "probe_info_register failed %d (%s:%lx|%lx)\n",
75 (unsigned long)ip->retprobe.up.opcode);
81 static inline int sspt_unregister_usprobe(struct task_struct *task,
85 struct uprobe *up = NULL;
89 probe_info_unregister(ip->desc->type, ip, 1);
92 up = probe_info_get_uprobe(ip->desc->type, ip);
94 disarm_uprobe(up, task);
97 probe_info_unregister(ip->desc->type, ip, 0);
100 panic("incorrect value flag=%d", flag);
106 #endif /* __SSPT__ */