From: Anatolii Nikulin Date: Wed, 1 Jun 2016 05:43:12 +0000 (+0300) Subject: [IMPROVE] kernel with version > 4.0.0 support X-Git-Tag: accepted/tizen/common/20160610.182109~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba8480343a1b9d3d64a43291bafb165c5bda0f08;p=platform%2Fkernel%2Fswap-modules.git [IMPROVE] kernel with version > 4.0.0 support Change-Id: I185a64e561b85dca01f327ac0db52f5d4e8752b5 Signed-off-by: Anatolii Nikulin --- diff --git a/kprobe/arch/x86/swap-asm/swap_kprobes.c b/kprobe/arch/x86/swap-asm/swap_kprobes.c index d8e615f..9e5d2ed 100644 --- a/kprobe/arch/x86/swap-asm/swap_kprobes.c +++ b/kprobe/arch/x86/swap-asm/swap_kprobes.c @@ -719,7 +719,7 @@ static int kprobe_exceptions_notify(struct notifier_block *self, DBPRINTF("val = %ld, data = 0x%X", val, (unsigned int) data); - if (args->regs == NULL || user_mode_vm(args->regs)) + if (args->regs == NULL || swap_user_mode(args->regs)) return ret; DBPRINTF("switch (val) %lu %d %d", val, DIE_INT3, DIE_TRAP); diff --git a/kprobe/arch/x86/swap-asm/swap_kprobes.h b/kprobe/arch/x86/swap-asm/swap_kprobes.h index 43f0f7a..bd1da71 100644 --- a/kprobe/arch/x86/swap-asm/swap_kprobes.h +++ b/kprobe/arch/x86/swap-asm/swap_kprobes.h @@ -80,6 +80,15 @@ typedef u8 kprobe_opcode_t; #define KPROBES_TRAMP_LEN MAX_INSN_SIZE #define KPROBES_TRAMP_INSN_IDX 0 +static inline int swap_user_mode(struct pt_regs *regs) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) + return user_mode(regs); +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) */ + return user_mode_vm(regs); +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) */ +} + static inline unsigned long arch_get_task_pc(struct task_struct *p) { /* FIXME: Not implemented yet */ diff --git a/kprobe/swap_kprobes_deps.c b/kprobe/swap_kprobes_deps.c index 7ef1056..22561e9 100644 --- a/kprobe/swap_kprobes_deps.c +++ b/kprobe/swap_kprobes_deps.c @@ -294,7 +294,17 @@ static inline int swap_in_gate_area(struct task_struct *task, IMP_MOD_DEP_WRAPPER(in_gate_area, task, addr) #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */ #else /*__HAVE_ARCH_GATE_AREA */ +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) + struct mm_struct *mm; + + if (task == NULL) + return 0; + + mm = task->mm; + return in_gate_area(mm, addr); +#else return in_gate_area(task, addr); +#endif #endif/*__HAVE_ARCH_GATE_AREA */ } diff --git a/loader/loader_module.c b/loader/loader_module.c index d305b96..8b46f5f 100644 --- a/loader/loader_module.c +++ b/loader/loader_module.c @@ -219,7 +219,7 @@ static struct vm_area_struct *__get_linker_vma(struct task_struct *task) for (vma = task->mm->mmap; vma; vma = vma->vm_next) { if (vma->vm_file && vma->vm_flags & VM_EXEC - && vma->vm_file->f_dentry == ld_info->dentry) { + && vma->vm_file->f_path.dentry == ld_info->dentry) { ls_put_linker_info(ld_info); return vma; } @@ -324,7 +324,7 @@ static int mmap_entry_handler(struct kretprobe_instance *ri, if (!file) return 0; - dentry = file->f_dentry; + dentry = file->f_path.dentry; if (dentry == NULL) return 0; diff --git a/preload/preload_module.c b/preload/preload_module.c index 71a7fab..e1c1f0c 100644 --- a/preload/preload_module.c +++ b/preload/preload_module.c @@ -141,9 +141,9 @@ static unsigned long __do_preload_entry(struct uretprobe_instance *ri, /* jump only if caller is instumented and it is not a system lib - * this leads to some errors */ if (cvma != NULL && cvma->vm_file != NULL && - cvma->vm_file->f_dentry != NULL) { + cvma->vm_file->f_path.dentry != NULL) { - struct dentry *dentry = cvma->vm_file->f_dentry; + struct dentry *dentry = cvma->vm_file->f_path.dentry; struct pd_t *pd = lpd_get_parent_pd(hd); if (!pc_check_dentry_is_ignored(dentry) && diff --git a/sampler/swap_sampler_module.c b/sampler/swap_sampler_module.c index c1a2b27..94cb506 100644 --- a/sampler/swap_sampler_module.c +++ b/sampler/swap_sampler_module.c @@ -74,7 +74,7 @@ static void swap_timer_stop(void) put_online_cpus(); } -static int __cpuinit swap_cpu_notify(struct notifier_block *self, +static int swap_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { long cpu = (long) hcpu; diff --git a/uprobe/arch/x86/swap-asm/swap_uprobes.c b/uprobe/arch/x86/swap-asm/swap_uprobes.c index c6b5151..97daf85 100644 --- a/uprobe/arch/x86/swap-asm/swap_uprobes.c +++ b/uprobe/arch/x86/swap-asm/swap_uprobes.c @@ -617,7 +617,7 @@ static int uprobe_exceptions_notify(struct notifier_block *self, struct die_args *args = (struct die_args *)data; int ret = NOTIFY_DONE; - if (args->regs == NULL || !user_mode_vm(args->regs)) + if (args->regs == NULL || !swap_user_mode(args->regs)) return ret; switch (val) {