summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--us_manager/helper.c37
-rw-r--r--us_manager/pf/pf_group.c15
-rw-r--r--us_manager/sspt/sspt_proc.c50
3 files changed, 18 insertions, 84 deletions
diff --git a/us_manager/helper.c b/us_manager/helper.c
index 5b5d01aa..68599996 100644
--- a/us_manager/helper.c
+++ b/us_manager/helper.c
@@ -49,20 +49,21 @@ struct pf_data {
unsigned long addr;
};
-static int entry_handler_mf(struct kretprobe_instance *ri, struct pt_regs *regs)
+static int entry_handler_pf(struct kretprobe_instance *ri, struct pt_regs *regs)
{
struct pf_data *data = (struct pf_data *)ri->data;
-#ifdef CONFIG_ARM
+#if defined(CONFIG_ARM)
data->addr = swap_get_karg(regs, 0);
-#else /* CONFIG_ARM */
- data->addr = swap_get_karg(regs, 2);
-#endif /* CONFIG_ARM */
+#elif defined(CONFIG_X86_32)
+ data->addr = read_cr2();
+#else
+ #error "this architecture is not supported"
+#endif /* CONFIG_arch */
return 0;
}
-#ifdef CONFIG_ARM
static unsigned long cb_pf(void *data)
{
unsigned long page_addr = *(unsigned long *)data;
@@ -71,34 +72,31 @@ static unsigned long cb_pf(void *data)
return 0;
}
-#endif /* CONFIG_ARM */
/* Detects when IPs are really loaded into phy mem and installs probes. */
-static int ret_handler_mf(struct kretprobe_instance *ri, struct pt_regs *regs)
+static int ret_handler_pf(struct kretprobe_instance *ri, struct pt_regs *regs)
{
struct task_struct *task = current;
unsigned long page_addr;
+ int ret;
if (is_kthread(task))
return 0;
/* TODO: check return value */
page_addr = ((struct pf_data *)ri->data)->addr & PAGE_MASK;
+ ret = set_jump_cb((unsigned long)ri->ret_addr, regs, cb_pf,
+ &page_addr, sizeof(page_addr));
-#ifdef CONFIG_ARM
- set_jump_cb((unsigned long)ri->ret_addr, regs, cb_pf,
- &page_addr, sizeof(page_addr));
- ri->ret_addr = (unsigned long *)get_jump_addr();
-#else /* CONFIG_ARM */
- call_page_fault(task, page_addr);
-#endif /* CONFIG_ARM */
+ if (ret == 0)
+ ri->ret_addr = (unsigned long *)get_jump_addr();
return 0;
}
static struct kretprobe mf_kretprobe = {
- .entry_handler = entry_handler_mf,
- .handler = ret_handler_mf,
+ .entry_handler = entry_handler_pf,
+ .handler = ret_handler_pf,
.data_size = sizeof(struct pf_data)
};
@@ -656,12 +654,7 @@ int init_helper(void)
{
unsigned long addr;
-#ifdef CONFIG_ARM
addr = swap_ksyms("do_page_fault");
-#else /* CONFIG_ARM */
- addr = swap_ksyms("handle_mm_fault");
-#endif /* CONFIG_ARM */
-
if (addr == 0) {
printk("Cannot find address for handle_mm_fault function!\n");
return -EINVAL;
diff --git a/us_manager/pf/pf_group.c b/us_manager/pf/pf_group.c
index e5667b00..d967d6bd 100644
--- a/us_manager/pf/pf_group.c
+++ b/us_manager/pf/pf_group.c
@@ -190,31 +190,18 @@ static void first_install(struct task_struct *task, struct sspt_proc *proc,
NULL;
}
- down_read(&task->mm->mmap_sem);
- proc_info_msg(task, dentry);
- up_read(&task->mm->mmap_sem);
-
-#ifdef CONFIG_ARM
down_write(&task->mm->mmap_sem);
+ proc_info_msg(task, dentry);
sspt_proc_install(proc);
up_write(&task->mm->mmap_sem);
-#else /* CONFIG_ARM */
- sspt_proc_install(proc);
-#endif /* CONFIG_ARM */
}
static void subsequent_install(struct task_struct *task,
struct sspt_proc *proc, unsigned long page_addr)
{
- if (!page_addr)
- return;
-#ifdef CONFIG_ARM
down_write(&task->mm->mmap_sem);
sspt_proc_install_page(proc, page_addr);
up_write(&task->mm->mmap_sem);
-#else /* CONFIG_ARM */
- sspt_proc_install_page(proc, page_addr);
-#endif /* CONFIG_ARM */
}
/**
diff --git a/us_manager/sspt/sspt_proc.c b/us_manager/sspt/sspt_proc.c
index b76b136e..baa09684 100644
--- a/us_manager/sspt/sspt_proc.c
+++ b/us_manager/sspt/sspt_proc.c
@@ -34,38 +34,6 @@
#include <writer/swap_writer_module.h>
-#ifdef CONFIG_ARM
-#define mm_read_lock(task, mm, atomic, lock) \
- mm = task->mm; \
- lock = 0
-
-#define mm_read_unlock(mm, atomic, lock)
-#else /* CONFIG_ARM */
-#define mm_read_lock(task, mm, atomic, lock) \
- mm = atomic ? task->active_mm : get_task_mm(task); \
- if (mm == NULL) { \
- /* FIXME: */ \
- panic("ERRR mm_read_lock: mm == NULL\n"); \
- } \
- \
- if (atomic) { \
- lock = down_read_trylock(&mm->mmap_sem); \
- } else { \
- lock = 1; \
- down_read(&mm->mmap_sem); \
- }
-
-#define mm_read_unlock(mm, atomic, lock) \
- if (lock) { \
- up_read(&mm->mmap_sem); \
- } \
- \
- if (!atomic) { \
- mmput(mm); \
- }
-#endif /* CONFIG_ARM */
-
-
static LIST_HEAD(proc_probes_list);
static DEFINE_RWLOCK(sspt_proc_rwlock);
@@ -311,13 +279,8 @@ struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc, struct dentry *den
*/
void sspt_proc_install_page(struct sspt_proc *proc, unsigned long page_addr)
{
- int lock, atomic;
- struct mm_struct *mm;
+ struct mm_struct *mm = proc->task->mm;
struct vm_area_struct *vma;
- struct task_struct *task = proc->task;
-
- atomic = in_atomic();
- mm_read_lock(task, mm, atomic, lock);
vma = find_vma_intersection(mm, page_addr, page_addr + 1);
if (vma && check_vma(vma)) {
@@ -336,8 +299,6 @@ void sspt_proc_install_page(struct sspt_proc *proc, unsigned long page_addr)
}
}
}
-
- mm_read_unlock(mm, atomic, lock);
}
/**
@@ -348,16 +309,11 @@ void sspt_proc_install_page(struct sspt_proc *proc, unsigned long page_addr)
*/
void sspt_proc_install(struct sspt_proc *proc)
{
- int lock, atomic;
struct vm_area_struct *vma;
- struct task_struct *task = proc->task;
- struct mm_struct *mm;
+ struct mm_struct *mm = proc->task->mm;
proc->first_install = 1;
- atomic = in_atomic();
- mm_read_lock(task, mm, atomic, lock);
-
for (vma = mm->mmap; vma; vma = vma->vm_next) {
if (check_vma(vma)) {
struct dentry *dentry = vma->vm_file->f_dentry;
@@ -372,8 +328,6 @@ void sspt_proc_install(struct sspt_proc *proc)
}
}
}
-
- mm_read_unlock(mm, atomic, lock);
}
/**