From: Vyacheslav Cherkashin Date: Mon, 14 Jan 2013 14:46:34 +0000 (+0400) Subject: us_proc_ip_t --> struct us_ip X-Git-Tag: Tizen_SDK_2.3~716^2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4d39fe3bd3f98504df66b95e4daa668bdc2d60a;p=kernel%2Fswap-modules.git us_proc_ip_t --> struct us_ip --- diff --git a/driver/new_dpf.h b/driver/new_dpf.h index b3d21e3..5b0dada 100644 --- a/driver/new_dpf.h +++ b/driver/new_dpf.h @@ -49,9 +49,9 @@ struct proc_probes { struct list_head file_list; }; -us_proc_ip_t *us_proc_ip_copy(const us_proc_ip_t *ip) +struct us_ip *us_proc_ip_copy(const struct us_ip *ip) { - us_proc_ip_t *ip_out = kmalloc(sizeof(*ip_out), GFP_ATOMIC); + struct us_ip *ip_out = kmalloc(sizeof(*ip_out), GFP_ATOMIC); if (ip_out == NULL) { DPRINTF ("us_proc_ip_copy: No enough memory"); return NULL; @@ -69,27 +69,24 @@ us_proc_ip_t *us_proc_ip_copy(const us_proc_ip_t *ip) ip_out->flag_got = 0; - ip_out->installed = 0; INIT_LIST_HEAD(&ip_out->list); return ip_out; } -us_proc_ip_t *us_proc_ips_copy(const us_proc_ip_t *ips, int cnt) +struct us_ip *us_proc_ips_copy(const struct us_ip *ips, int cnt) { int i; - us_proc_ip_t *ips_out = - kmalloc (cnt * sizeof (us_proc_ip_t), GFP_ATOMIC); + struct us_ip *ips_out = + kmalloc(cnt * sizeof(*ips), GFP_ATOMIC); if (!ips_out) { DPRINTF ("No enough memory for copy_info->p_libs[i].p_ips"); return NULL; } - memcpy (ips_out, ips, cnt * sizeof (us_proc_ip_t)); + memcpy(ips_out, ips, cnt * sizeof(*ips)); for (i = 0; i < cnt; ++i) { - ips_out[i].installed = 0; - // jprobe memset(&ips_out[i].jprobe, 0, sizeof(struct jprobe)); ips_out[i].jprobe.entry = ips[i].jprobe.entry; @@ -124,7 +121,7 @@ static void page_p_del(struct page_probes *page_p) static struct page_probes *page_p_copy(const struct page_probes *page_p) { - us_proc_ip_t *ip_in, *ip_out; + struct us_ip *ip_in, *ip_out; struct page_probes *page_p_out = kmalloc(sizeof(*page_p), GFP_ATOMIC); if (page_p_out) { @@ -149,16 +146,16 @@ static struct page_probes *page_p_copy(const struct page_probes *page_p) return page_p_out; } -static void page_p_add_ip(struct page_probes *page_p, us_proc_ip_t *ip) +static void page_p_add_ip(struct page_probes *page_p, struct us_ip *ip) { ip->offset &= ~PAGE_MASK; INIT_LIST_HEAD(&ip->list); list_add(&ip->list, &page_p->ip_list); } -static us_proc_ip_t *page_p_find_ip(struct page_probes *page_p, unsigned long offset) +static struct us_ip *page_p_find_ip(struct page_probes *page_p, unsigned long offset) { - us_proc_ip_t *ip; + struct us_ip *ip; list_for_each_entry(ip, &page_p->ip_list, list) { if (ip->offset == offset) { @@ -192,7 +189,7 @@ static void page_p_uninstalled(struct page_probes *page_p) } // page_probes -static void set_ip_kp_addr(us_proc_ip_t *ip, struct page_probes *page_p, const struct file_probes *file_p) +static void set_ip_kp_addr(struct us_ip *ip, struct page_probes *page_p, const struct file_probes *file_p) { unsigned long addr = file_p->vm_start + page_p->offset + ip->offset; ip->retprobe.kp.addr = ip->jprobe.kp.addr = addr; @@ -200,7 +197,7 @@ static void set_ip_kp_addr(us_proc_ip_t *ip, struct page_probes *page_p, const s static void page_p_set_all_kp_addr(struct page_probes *page_p, const struct file_probes *file_p) { - us_proc_ip_t *ip; + struct us_ip *ip; unsigned long addr; list_for_each_entry(ip, &page_p->ip_list, list) { @@ -349,7 +346,7 @@ void file_p_add_probe(struct file_probes *file_p, struct probe_data *pd) struct page_probes *page_p = file_p_find_page_p_or_new(file_p, offset); // FIXME: ip - us_proc_ip_t *ip = kmalloc(sizeof(*ip), GFP_ATOMIC); + struct us_ip *ip = kmalloc(sizeof(*ip), GFP_ATOMIC); memset(ip, 0, sizeof(*ip)); INIT_LIST_HEAD(&ip->list); @@ -503,15 +500,12 @@ struct proc_probes *get_file_probes(const inst_us_proc_t *task_inst_info) return proc_p; } -static int register_usprobe_my(struct task_struct *task, us_proc_ip_t *ip) +static int register_usprobe_my(struct task_struct *task, struct us_ip *ip) { - ip->installed = 0; - ip->name = 0; - return register_usprobe(task, ip, 1); } -static int unregister_usprobe_my(struct task_struct *task, us_proc_ip_t *ip, enum US_FLAGS flag) +static int unregister_usprobe_my(struct task_struct *task, struct us_ip *ip, enum US_FLAGS flag) { int err = 0; @@ -548,7 +542,7 @@ static void print_retprobe(struct kretprobe *rp) static void print_page_probes(const struct page_probes *page_p) { int i = 0; - us_proc_ip_t *ip; + struct us_ip *ip; printk("### offset=%x\n", page_p->offset); list_for_each_entry(ip, &page_p->ip_list, list) { @@ -617,7 +611,7 @@ void print_inst_us_proc(const inst_us_proc_t *task_inst_info) printk("### path=%s, cnt_j=%d\n", path, cnt_j); for (j = 0; j < cnt_j; ++j) { - us_proc_ip_t *ips = &lib->p_ips[j]; + struct us_ip *ips = &lib->p_ips[j]; unsigned long offset = ips->offset; printk("### offset=%x\n", offset); } diff --git a/driver/storage.h b/driver/storage.h index 3341d17..9bf1684 100644 --- a/driver/storage.h +++ b/driver/storage.h @@ -155,6 +155,19 @@ typedef struct unsigned flag_got:1; } us_proc_ip_t; +struct us_ip { + struct list_head list; + + struct jprobe jprobe; + struct kretprobe retprobe; + + unsigned long offset; + unsigned long got_addr; + + unsigned flag_retprobe:1; + unsigned flag_got:1; +}; + typedef struct { int installed; diff --git a/driver/us_proc_inst.c b/driver/us_proc_inst.c index ce6043a..eaefe5c 100644 --- a/driver/us_proc_inst.c +++ b/driver/us_proc_inst.c @@ -56,12 +56,12 @@ DEFINE_PER_CPU (struct pt_regs *, gpCurVtpRegs) = NULL; # warning ARCH_REG_VAL is not implemented for this architecture. FBI will work improperly or even crash!!! #endif // ARCH -unsigned long ujprobe_event_pre_handler (us_proc_ip_t * ip, struct pt_regs *regs); +unsigned long ujprobe_event_pre_handler (struct us_ip *ip, struct pt_regs *regs); void ujprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6); -int uretprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *regs, us_proc_ip_t * ip); +int uretprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *regs, struct us_ip *ip); -static int register_usprobe(struct task_struct *task, us_proc_ip_t *ip, int atomic); -static int unregister_usprobe(struct task_struct *task, us_proc_ip_t * ip, int atomic, int no_rp2); +static int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic); +static int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, int no_rp2); #include "new_dpf.h" @@ -607,7 +607,7 @@ int install_otg_ip(unsigned long addr, struct file_probes *file_p = proc_p_find_file_p_by_dentry(proc_p, name, dentry); struct page_probes *page_p = get_page_p(file_p, offset_addr); - us_proc_ip_t *ip = page_p_find_ip(page_p, offset_addr & ~PAGE_MASK); + struct us_ip *ip = page_p_find_ip(page_p, offset_addr & ~PAGE_MASK); if (!file_p->loaded) { set_mapping_file(file_p, proc_p, task, vma); @@ -1038,7 +1038,7 @@ static int register_us_page_probe(struct page_probes *page_p, const struct task_struct *task) { int err = 0; - us_proc_ip_t *ip; + struct us_ip *ip; spin_lock(&page_p->lock); @@ -1071,7 +1071,7 @@ static int unregister_us_page_probe(const struct task_struct *task, struct page_probes *page_p, enum US_FLAGS flag) { int err = 0; - us_proc_ip_t *ip; + struct us_ip *ip; spin_lock(&page_p->lock); if (!page_p_is_install(page_p)) { @@ -1507,13 +1507,13 @@ void copy_process_ret_pre_code(struct task_struct *p) } -DEFINE_PER_CPU (us_proc_ip_t *, gpCurIp) = NULL; +DEFINE_PER_CPU(struct us_ip *, gpCurIp) = NULL; EXPORT_PER_CPU_SYMBOL_GPL(gpCurIp); DEFINE_PER_CPU(struct pt_regs *, gpUserRegs) = NULL; EXPORT_PER_CPU_SYMBOL_GPL(gpUserRegs); -unsigned long ujprobe_event_pre_handler (us_proc_ip_t * ip, struct pt_regs *regs) +unsigned long ujprobe_event_pre_handler(struct us_ip *ip, struct pt_regs *regs) { __get_cpu_var (gpCurIp) = ip; __get_cpu_var (gpUserRegs) = regs; @@ -1569,7 +1569,7 @@ int handle_java_event(unsigned long addr) void ujprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6) { - us_proc_ip_t *ip = __get_cpu_var (gpCurIp); + struct us_ip *ip = __get_cpu_var(gpCurIp); unsigned long addr = (unsigned long)ip->jprobe.kp.addr; #ifdef __ANDROID @@ -1594,7 +1594,7 @@ void ujprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned lon dbi_uprobe_return (); } -void send_plt(us_proc_ip_t *ip) +void send_plt(struct us_ip *ip) { unsigned long addr = (unsigned long)ip->jprobe.kp.addr; struct vm_area_struct *vma = find_vma(current->mm, addr); @@ -1627,7 +1627,7 @@ void send_plt(us_proc_ip_t *ip) } } -int uretprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *regs, us_proc_ip_t * ip) +int uretprobe_event_handler(struct kretprobe_instance *probe, struct pt_regs *regs, struct us_ip *ip) { int retval = regs_return_value(regs); unsigned long addr = (unsigned long)ip->jprobe.kp.addr; @@ -1652,7 +1652,7 @@ int uretprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *r return 0; } -static int register_usprobe(struct task_struct *task, us_proc_ip_t *ip, int atomic) +static int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic) { int ret = 0; ip->jprobe.kp.tgid = task->tgid; @@ -1690,12 +1690,10 @@ static int register_usprobe(struct task_struct *task, us_proc_ip_t *ip, int atom } } - ip->installed = 1; - return 0; } -static int unregister_usprobe(struct task_struct *task, us_proc_ip_t * ip, int atomic, int not_rp2) +static int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, int not_rp2) { dbi_unregister_ujprobe(task, &ip->jprobe, atomic); @@ -1703,8 +1701,6 @@ static int unregister_usprobe(struct task_struct *task, us_proc_ip_t * ip, int a dbi_unregister_uretprobe(task, &ip->retprobe, atomic, not_rp2); } - ip->installed = 0; - return 0; } @@ -1793,7 +1789,7 @@ int dump_backtrace(probe_id_t probe_id, struct task_struct *task, } EXPORT_SYMBOL_GPL(dump_backtrace); -unsigned long get_ret_addr(struct task_struct *task, us_proc_ip_t *ip) +unsigned long get_ret_addr(struct task_struct *task, struct us_ip *ip) { unsigned long retaddr = 0; struct hlist_node *item, *tmp_node; diff --git a/driver/us_proc_inst.h b/driver/us_proc_inst.h index ce0709c..4243201 100644 --- a/driver/us_proc_inst.h +++ b/driver/us_proc_inst.h @@ -76,7 +76,7 @@ extern int dump_backtrace(probe_id_t probe_id, struct task_struct *task, void *addr, struct pt_regs *regs, unsigned long sz); /* Gets current function return address */ -extern unsigned long get_ret_addr(struct task_struct *task, us_proc_ip_t *ip); +extern unsigned long get_ret_addr(struct task_struct *task, struct us_ip *ip); #define user_backtrace(size) \ do { \