[REFACTOR] move and rename /un/register_us_page_probe()
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Tue, 7 May 2013 06:51:48 +0000 (10:51 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Tue, 7 May 2013 07:24:28 +0000 (11:24 +0400)
move:
from src/modules/driver/us_proc_inst.c
to src/modules/driver/sspt/sspt_page.c

rename:
register_us_page_probe() --> sspt_register_page()
unregister_us_page_probe() --> sspt_unregister_page()

driver/helper.c
driver/sspt/sspt_debug.h
driver/sspt/sspt_page.c
driver/sspt/sspt_page.h
driver/us_proc_inst.c
driver/us_proc_inst.h

index c716d3d..73a8ac0 100644 (file)
@@ -220,7 +220,7 @@ static int remove_unmap_probes(struct task_struct *task, struct sspt_procs *proc
                                for (page_addr = vma->vm_start; page_addr < vma->vm_end; page_addr += PAGE_SIZE) {
                                        page = sspt_find_page_mapped(file, page_addr);
                                        if (page) {
-                                               unregister_us_page_probe(task, page, US_UNREGS_PROBE);
+                                               sspt_unregister_page(page, US_UNREGS_PROBE, task);
                                        }
                                }
 
index 2b6c982..2326cae 100644 (file)
@@ -25,6 +25,8 @@
  *
  */
 
+#include <dbi_kprobes_deps.h>
+
 static inline void print_jprobe(struct jprobe *jp)
 {
        printk("###         JP: entry=%lx, pre_entry=%lx\n",
@@ -94,6 +96,7 @@ static inline void print_proc_probes(const struct sspt_procs *procs)
        printk("### print_proc_probes\n");
 }
 
+/*
 static inline void print_inst_us_proc(const inst_us_proc_t *task_inst_info)
 {
        int i;
@@ -118,5 +121,6 @@ static inline void print_inst_us_proc(const inst_us_proc_t *task_inst_info)
        }
        printk("### BUNDLE PRINT  END  ###\n");
 }
+*/
 
 #endif /* __SSPT_DEBUG__ */
index 26f8e4a..86e791b 100644 (file)
@@ -22,6 +22,7 @@
  *
  */
 
+#include "sspt.h"
 #include "sspt_page.h"
 #include "sspt_file.h"
 #include "ip.h"
@@ -127,3 +128,67 @@ void sspt_set_all_ip_addr(struct sspt_page *page, const struct sspt_file *file)
                ip->retprobe.up.kp.addr = ip->jprobe.up.kp.addr = (kprobe_opcode_t *)addr;
        }
 }
+
+int sspt_register_page(struct sspt_page *page,
+                      struct sspt_file *file,
+                      struct task_struct *task)
+{
+       int err = 0;
+       struct us_ip *ip, *n;
+
+       spin_lock(&page->lock);
+
+       if (sspt_page_is_install(page)) {
+               printk("page %lx in %s task[tgid=%u, pid=%u] already installed\n",
+                               page->offset, file->dentry->d_iname, task->tgid, task->pid);
+               goto unlock;
+       }
+
+       sspt_page_assert_install(page);
+       sspt_set_all_ip_addr(page, file);
+
+       list_for_each_entry_safe(ip, n, &page->ip_list, list) {
+               err = sspt_register_usprobe(task, ip);
+               if (err == -ENOEXEC) {
+                       list_del(&ip->list);
+                       free_ip(ip);
+                       continue;
+               } else if (err) {
+                       printk("Failed to install probe\n");
+               }
+       }
+unlock:
+       sspt_page_installed(page);
+       spin_unlock(&page->lock);
+
+       return 0;
+}
+
+int sspt_unregister_page(struct sspt_page *page,
+                        enum US_FLAGS flag,
+                        struct task_struct *task)
+{
+       int err = 0;
+       struct us_ip *ip;
+
+       spin_lock(&page->lock);
+       if (!sspt_page_is_install(page)) {
+               spin_unlock(&page->lock);
+               return 0;
+       }
+
+       list_for_each_entry(ip, &page->ip_list, list) {
+               err = sspt_unregister_usprobe(task, ip, flag);
+               if (err != 0) {
+                       //TODO: ERROR
+                       break;
+               }
+       }
+
+       if (flag != US_DISARM) {
+               sspt_page_uninstalled(page);
+       }
+       spin_unlock(&page->lock);
+
+       return err;
+}
index 9bc6ceb..1060791 100644 (file)
@@ -30,6 +30,8 @@
 
 struct us_ip;
 struct sspt_file;
+struct task_struct;
+enum US_FLAGS;
 
 struct sspt_page {
        struct list_head ip_list;
@@ -72,4 +74,12 @@ static inline void sspt_page_uninstalled(struct sspt_page *page)
 
 void sspt_set_all_ip_addr(struct sspt_page *page, const struct sspt_file *file);
 
+int sspt_register_page(struct sspt_page *page,
+                      struct sspt_file *file,
+                      struct task_struct *task);
+
+int sspt_unregister_page(struct sspt_page *page,
+                        enum US_FLAGS flag,
+                        struct task_struct *task);
+
 #endif /* __SSPT_PAGE__ */
index d3f84f0..1ba4756 100644 (file)
@@ -339,70 +339,6 @@ static void set_mapping_file(struct sspt_file *file,
 
 void print_vma(struct mm_struct *mm);
 
-static int register_us_page_probe(struct sspt_page *page,
-               const struct sspt_file *file,
-               struct task_struct *task)
-{
-       int err = 0;
-       struct us_ip *ip, *n;
-
-       spin_lock(&page->lock);
-
-       if (sspt_page_is_install(page)) {
-               printk("page %lx in %s task[tgid=%u, pid=%u] already installed\n",
-                               page->offset, file->dentry->d_iname, task->tgid, task->pid);
-               print_vma(task->mm);
-               goto unlock;
-       }
-
-       sspt_page_assert_install(page);
-       sspt_set_all_ip_addr(page, file);
-
-       list_for_each_entry_safe(ip, n, &page->ip_list, list) {
-               err = sspt_register_usprobe(task, ip);
-               if (err == -ENOEXEC) {
-                       list_del(&ip->list);
-                       free_ip(ip);
-                       continue;
-               } else if (err) {
-                       EPRINTF("Failed to install probe");
-               }
-       }
-unlock:
-       sspt_page_installed(page);
-       spin_unlock(&page->lock);
-
-       return 0;
-}
-
-int unregister_us_page_probe(struct task_struct *task,
-                            struct sspt_page *page, enum US_FLAGS flag)
-{
-       int err = 0;
-       struct us_ip *ip;
-
-       spin_lock(&page->lock);
-       if (!sspt_page_is_install(page)) {
-               spin_unlock(&page->lock);
-               return 0;
-       }
-
-       list_for_each_entry(ip, &page->ip_list, list) {
-               err = sspt_unregister_usprobe(task, ip, flag);
-               if (err != 0) {
-                       //TODO: ERROR
-                       break;
-               }
-       }
-
-       if (flag != US_DISARM) {
-               sspt_page_uninstalled(page);
-       }
-       spin_unlock(&page->lock);
-
-       return err;
-}
-
 void install_page_probes(unsigned long page_addr, struct task_struct *task, struct sspt_procs *procs)
 {
        int lock, atomic;
@@ -425,7 +361,7 @@ void install_page_probes(unsigned long page_addr, struct task_struct *task, stru
 
                        page = sspt_find_page_mapped(file, page_addr);
                        if (page) {
-                               register_us_page_probe(page, file, task);
+                               sspt_register_page(page, file, task);
                        }
                }
        }
@@ -443,7 +379,7 @@ static void install_file_probes(struct task_struct *task, struct mm_struct *mm,
        for (i = 0; i < table_size; ++i) {
                head = &file->page_probes_table[i];
                swap_hlist_for_each_entry_rcu(page, node, head, hlist) {
-                       register_us_page_probe(page, file, task);
+                       sspt_register_page(page, file, task);
                }
        }
 }
@@ -506,7 +442,7 @@ int unregister_us_file_probes(struct task_struct *task, struct sspt_file *file,
        for (i = 0; i < table_size; ++i) {
                head = &file->page_probes_table[i];
                swap_hlist_for_each_entry_safe (page, node, tmp, head, hlist) {
-                       err = unregister_us_page_probe(task, page, flag);
+                       err = sspt_unregister_page(page, flag, task);
                        if (err != 0) {
                                // TODO: ERROR
                                return err;
index 8aef81c..d088d08 100644 (file)
@@ -54,8 +54,6 @@ int install_otg_ip(unsigned long addr,
 
 
 int check_install_pages_in_file(struct task_struct *task, struct sspt_file *file);
-int unregister_us_page_probe(struct task_struct *task,
-                            struct sspt_page *page, enum US_FLAGS flag);
 void install_proc_probes(struct task_struct *task, struct sspt_procs *procs);
 pid_t find_proc_by_task(const struct task_struct *task, struct dentry *dentry);
 void install_page_probes(unsigned long page_addr, struct task_struct *task, struct sspt_procs *procs);