[REFACTOR] new interface dbi_/un/register_uretprobe()
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Fri, 29 Mar 2013 16:41:37 +0000 (20:41 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Fri, 29 Mar 2013 16:41:37 +0000 (20:41 +0400)
driver/sspt/ip.c
driver/sspt/sspt_debug.h
driver/sspt/sspt_page.c
driver/us_proc_inst.c
uprobe/arch/asm-arm/swap_uprobes.c
uprobe/swap_uprobes.c
uprobe/swap_uprobes.h

index 02511d7..49f6ab2 100644 (file)
@@ -96,5 +96,5 @@ struct us_ip *create_ip_by_ip_data(struct ip_data *ip_d)
 void sspt_set_ip_addr(struct us_ip *ip, const struct sspt_page *page, const struct sspt_file *file)
 {
        unsigned long addr = file->vm_start + page->offset + ip->offset;
-       ip->retprobe.kp.addr = ip->jprobe.up.kp.addr = (kprobe_opcode_t *)addr;
+       ip->retprobe.up.kp.addr = ip->jprobe.up.kp.addr = (kprobe_opcode_t *)addr;
 }
index 2f94c8f..1238e08 100644 (file)
@@ -47,7 +47,7 @@ static inline void print_page_probes(const struct sspt_page *page)
 
                printk("###       addr[%2d]=%lx, J_addr=%lx, R_addr=%lx\n",
                                i, (unsigned long)ip->offset, (unsigned long)ip->jprobe.up.kp.addr,
-                               (unsigned long)ip->retprobe.kp.addr);
+                               (unsigned long)ip->retprobe.up.kp.addr);
                print_jprobe(&ip->jprobe);
                print_retprobe(&ip->retprobe);
                ++i;
index a5943df..6b481a9 100644 (file)
@@ -117,6 +117,6 @@ void sspt_set_all_ip_addr(struct sspt_page *page, const struct sspt_file *file)
 
        list_for_each_entry(ip, &page->ip_list, list) {
                addr = file->vm_start + page->offset + ip->offset;
-               ip->retprobe.kp.addr = ip->jprobe.up.kp.addr = (kprobe_opcode_t *)addr;
+               ip->retprobe.up.kp.addr = ip->jprobe.up.kp.addr = (kprobe_opcode_t *)addr;
        }
 }
index e0a92f3..d9f9153 100644 (file)
@@ -1239,14 +1239,15 @@ int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic)
 
        if (ip->flag_retprobe) {
                // Mr_Nobody: comment for valencia
-               ip->retprobe.kp.tgid = task->tgid;
+               ip->retprobe.up.kp.tgid = task->tgid;
                if (ip->retprobe.handler == NULL) {
                        ip->retprobe.handler = (uretprobe_handler_t)uretprobe_event_handler;
                        DPRINTF("Set default ret event handler for %x\n", ip->offset);
                }
 
                ip->retprobe.priv_arg = ip;
-               ret = dbi_register_uretprobe(task, &ip->retprobe, atomic);
+               ip->retprobe.up.task = task;
+               ret = dbi_register_uretprobe(&ip->retprobe, atomic);
                if (ret) {
                        EPRINTF ("dbi_register_uretprobe() failure %d", ret);
                        return ret;
@@ -1261,7 +1262,7 @@ int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, i
        dbi_unregister_ujprobe(&ip->jprobe, atomic);
 
        if (ip->flag_retprobe) {
-               dbi_unregister_uretprobe(task, &ip->retprobe, atomic, not_rp2);
+               dbi_unregister_uretprobe(&ip->retprobe, atomic, not_rp2);
        }
 
        return 0;
index c32a014..2e68936 100644 (file)
@@ -598,9 +598,9 @@ void arch_prepare_uretprobe_hl(struct uretprobe_instance *ri,
        ri->sp = (kprobe_opcode_t *)((long)ri->sp | !!thumb_mode(regs));
 
        if (thumb_mode(regs)) {
-               regs->ARM_lr = (unsigned long)(ri->rp->kp.ainsn.insn) + 0x1b;
+               regs->ARM_lr = (unsigned long)(ri->rp->up.kp.ainsn.insn) + 0x1b;
        } else {
-               regs->ARM_lr = (unsigned long)(ri->rp->kp.ainsn.insn + UPROBES_TRAMP_RET_BREAK_IDX);
+               regs->ARM_lr = (unsigned long)(ri->rp->up.kp.ainsn.insn + UPROBES_TRAMP_RET_BREAK_IDX);
        }
 }
 
index d9adecc..93c2537 100644 (file)
@@ -729,7 +729,8 @@ int trampoline_uprobe_handler(struct kprobe *p, struct pt_regs *regs)
 
 static int pre_handler_uretprobe(struct kprobe *p, struct pt_regs *regs)
 {
-       struct uretprobe *rp = container_of(p, struct uretprobe, kp);
+       struct uprobe *up = container_of(p, struct uprobe, kp);
+       struct uretprobe *rp = container_of(up, struct uretprobe, up);
        struct uretprobe_instance *ri;
        unsigned long flags;
 
@@ -757,17 +758,17 @@ unlock:
        return 0;
 }
 
-int dbi_register_uretprobe(struct task_struct *task, struct uretprobe *rp, int atomic)
+int dbi_register_uretprobe(struct uretprobe *rp, int atomic)
 {
        int i, ret = 0;
        struct uretprobe_instance *inst;
 
        DBPRINTF ("START\n");
 
-       rp->kp.pre_handler = pre_handler_uretprobe;
-       rp->kp.post_handler = NULL;
-       rp->kp.fault_handler = NULL;
-       rp->kp.break_handler = NULL;
+       rp->up.kp.pre_handler = pre_handler_uretprobe;
+       rp->up.kp.post_handler = NULL;
+       rp->up.kp.fault_handler = NULL;
+       rp->up.kp.break_handler = NULL;
 
        rp->disarm = 0;
 
@@ -798,7 +799,7 @@ int dbi_register_uretprobe(struct task_struct *task, struct uretprobe *rp, int a
        rp->nmissed = 0;
 
        /* Establish function entry probe point */
-       ret = dbi_register_uprobe(&rp->kp, task, atomic);
+       ret = dbi_register_uprobe(&rp->up.kp, rp->up.task, atomic);
        if (ret) {
                free_urp_inst(rp);
                goto out;
@@ -821,10 +822,10 @@ int dbi_disarm_urp_inst(struct uretprobe_instance *ri, struct task_struct *rm_ta
        /* Understand function mode */
        if ((long)ri->sp & 1) {
                tramp = (kprobe_opcode_t *)
-                       ((unsigned long)ri->rp->kp.ainsn.insn + 0x1b);
+                       ((unsigned long)ri->rp->up.kp.ainsn.insn + 0x1b);
        } else {
                tramp = (kprobe_opcode_t *)
-                       (ri->rp->kp.ainsn.insn + UPROBES_TRAMP_RET_BREAK_IDX);
+                       (ri->rp->up.kp.ainsn.insn + UPROBES_TRAMP_RET_BREAK_IDX);
        }
 
        retval = read_proc_vm_atomic(task, (unsigned long)stack, buf, sizeof(buf));
@@ -847,7 +848,7 @@ int dbi_disarm_urp_inst(struct uretprobe_instance *ri, struct task_struct *rm_ta
                printk("---> %s (%d/%d): trampoline found at %08lx (%08lx /%+d) - %p\n",
                                task->comm, task->tgid, task->pid,
                                (unsigned long)found, (unsigned long)sp,
-                               found - sp, ri->rp->kp.addr);
+                               found - sp, ri->rp->up.kp.addr);
                retval = write_proc_vm_atomic(task, (unsigned long)found, &ri->ret_addr,
                                sizeof(ri->ret_addr));
                if (retval != sizeof(ri->ret_addr)) {
@@ -862,13 +863,13 @@ int dbi_disarm_urp_inst(struct uretprobe_instance *ri, struct task_struct *rm_ta
                unsigned long ra = dbi_get_ret_addr(uregs);
                if (ra == (unsigned long)tramp) {
                        printk("---> %s (%d/%d): trampoline found at lr = %08lx - %p\n",
-                                       task->comm, task->tgid, task->pid, ra, ri->rp->kp.addr);
+                                       task->comm, task->tgid, task->pid, ra, ri->rp->up.kp.addr);
                        dbi_set_ret_addr(uregs, (unsigned long)tramp);
                        retval = 0;
                } else {
                        printk("---> %s (%d/%d): trampoline NOT found at sp = %08lx, lr = %08lx - %p\n",
                                        task->comm, task->tgid, task->pid,
-                                       (unsigned long)sp, ra, ri->rp->kp.addr);
+                                       (unsigned long)sp, ra, ri->rp->up.kp.addr);
                        retval = -ENOENT;
                }
        }
@@ -885,7 +886,7 @@ int dbi_disarm_urp_inst_for_task(struct task_struct *parent, struct task_struct
        struct hlist_head *head = uretprobe_inst_table_head(parent->mm);
 
        hlist_for_each_entry_safe(ri, node, tmp, head, hlist) {
-               if (parent == ri->task && ri->rp->kp.tgid) {
+               if (parent == ri->task && ri->rp->up.kp.tgid) {
                        dbi_disarm_urp_inst(ri, task);
                }
        }
@@ -894,7 +895,7 @@ int dbi_disarm_urp_inst_for_task(struct task_struct *parent, struct task_struct
 }
 EXPORT_SYMBOL_GPL(dbi_disarm_urp_inst_for_task);
 
-void dbi_unregister_uretprobe(struct task_struct *task, struct uretprobe *rp, int atomic, int not_rp2)
+void dbi_unregister_uretprobe(struct uretprobe *rp, int atomic, int not_rp2)
 {
        unsigned long flags;
        struct uretprobe_instance *ri;
@@ -905,12 +906,12 @@ void dbi_unregister_uretprobe(struct task_struct *task, struct uretprobe *rp, in
                if (dbi_disarm_urp_inst(ri, NULL) != 0)
                        /*panic*/printk("%s (%d/%d): cannot disarm urp instance (%08lx)\n",
                                        ri->task->comm, ri->task->tgid, ri->task->pid,
-                                       (unsigned long)rp->kp.addr);
+                                       (unsigned long)rp->up.kp.addr);
                recycle_urp_inst(ri);
        }
 
        if (hlist_empty(&rp->used_instances)) {
-               struct kprobe *p = &rp->kp;
+               struct kprobe *p = &rp->up.kp;
 #ifdef CONFIG_ARM
                if (!(hlist_unhashed(&p->is_hlist_arm))) {
                        hlist_del_rcu(&p->is_hlist_arm);
@@ -934,7 +935,7 @@ void dbi_unregister_uretprobe(struct task_struct *task, struct uretprobe *rp, in
        spin_unlock_irqrestore(&uretprobe_lock, flags);
        free_urp_inst(rp);
 
-       dbi_unregister_uprobe(&rp->kp, task, atomic);
+       dbi_unregister_uprobe(&rp->up.kp, rp->up.task, atomic);
 }
 
 void dbi_unregister_all_uprobes(struct task_struct *task, int atomic)
index c13e912..835808c 100644 (file)
@@ -60,7 +60,7 @@ typedef int (*uretprobe_handler_t)(struct uretprobe_instance *, struct pt_regs *
  *
  */
 struct uretprobe {
-       struct kprobe kp;
+       struct uprobe up;
        uretprobe_handler_t handler;
        void *priv_arg;
        int maxactive;
@@ -86,8 +86,8 @@ void dbi_unregister_uprobe(struct kprobe *p, struct task_struct *task, int atomi
 int dbi_register_ujprobe(struct ujprobe *jp, int atomic);
 void dbi_unregister_ujprobe(struct ujprobe *jp, int atomic);
 
-int dbi_register_uretprobe(struct task_struct *task, struct uretprobe *rp, int atomic);
-void dbi_unregister_uretprobe(struct task_struct *task, struct uretprobe *rp, int atomic, int not_rp2);
+int dbi_register_uretprobe(struct uretprobe *rp, int atomic);
+void dbi_unregister_uretprobe(struct uretprobe *rp, int atomic, int not_rp2);
 
 void dbi_unregister_all_uprobes(struct task_struct *task, int atomic);