From 255461c53a91d34e2eddb8c8a2ba39e99065d7c1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 19 Sep 2012 13:05:49 -0400 Subject: mn10300: split ret_from_fork, simplify kernel_thread() Signed-off-by: Al Viro --- arch/mn10300/kernel/process.c | 52 +++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) (limited to 'arch/mn10300/kernel/process.c') diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c index 7dab0cd36466..be87fbee4da5 100644 --- a/arch/mn10300/kernel/process.c +++ b/arch/mn10300/kernel/process.c @@ -166,13 +166,11 @@ void show_regs(struct pt_regs *regs) */ int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) { - struct pt_regs regs; + struct pt_regs regs = { + .a0 = (unsigned long) fn; + .d0 = (unsigned long) arg; + }; - memset(®s, 0, sizeof(regs)); - - regs.a2 = (unsigned long) fn; - regs.d2 = (unsigned long) arg; - regs.pc = (unsigned long) kernel_thread_helper; local_save_flags(regs.epsw); regs.epsw |= EPSW_IE | EPSW_IM_7; @@ -180,7 +178,6 @@ int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); } -EXPORT_SYMBOL(kernel_thread); /* * free current thread data structures etc.. @@ -227,49 +224,36 @@ int copy_thread(unsigned long clone_flags, struct task_struct *p, struct pt_regs *kregs) { struct thread_info *ti = task_thread_info(p); - struct pt_regs *c_uregs, *c_kregs, *uregs; + struct pt_regs *c_regs; unsigned long c_ksp; - uregs = current->thread.uregs; - c_ksp = (unsigned long) task_stack_page(p) + THREAD_SIZE; /* allocate the userspace exception frame and set it up */ c_ksp -= sizeof(struct pt_regs); - c_uregs = (struct pt_regs *) c_ksp; + c_regs = (struct pt_regs *) c_ksp; - p->thread.uregs = c_uregs; - *c_uregs = *uregs; - c_uregs->sp = c_usp; - c_uregs->epsw &= ~EPSW_FE; /* my FPU */ + p->thread.uregs = c_regs; + *c_regs = *kregs; + c_regs->sp = c_usp; + c_regs->epsw &= ~EPSW_FE; /* my FPU */ c_ksp -= 12; /* allocate function call ABI slack */ /* the new TLS pointer is passed in as arg #5 to sys_clone() */ if (clone_flags & CLONE_SETTLS) - c_uregs->e2 = current_frame()->d3; - - /* set up the return kernel frame if called from kernel_thread() */ - c_kregs = c_uregs; - if (kregs != uregs) { - c_ksp -= sizeof(struct pt_regs); - c_kregs = (struct pt_regs *) c_ksp; - *c_kregs = *kregs; - c_kregs->sp = c_usp; - c_kregs->next = c_uregs; -#ifdef CONFIG_MN10300_CURRENT_IN_E2 - c_kregs->e2 = (unsigned long) p; /* current */ -#endif + c_regs->e2 = current_frame()->d3; - c_ksp -= 12; /* allocate function call ABI slack */ - } + if (unlikely(!user_mode(kregs))) + p->thread.pc = (unsigned long) ret_from_kernel_thread; + else + p->thread.pc = (unsigned long) ret_from_fork; /* set up things up so the scheduler can start the new task */ - ti->frame = c_kregs; - p->thread.a3 = (unsigned long) c_kregs; + ti->frame = c_regs; + p->thread.a3 = (unsigned long) c_regs; p->thread.sp = c_ksp; - p->thread.pc = (unsigned long) ret_from_fork; - p->thread.wchan = (unsigned long) ret_from_fork; + p->thread.wchan = p->thread.pc; p->thread.usp = c_usp; return 0; -- cgit v1.2.3 From 8f1597e959a3cfeae8f5cfae26890710f9092443 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 19 Sep 2012 13:08:13 -0400 Subject: mn10300: switch to generic sys_execve() Signed-off-by: Al Viro --- arch/mn10300/kernel/process.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'arch/mn10300/kernel/process.c') diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c index be87fbee4da5..49af5ca89343 100644 --- a/arch/mn10300/kernel/process.c +++ b/arch/mn10300/kernel/process.c @@ -283,22 +283,6 @@ asmlinkage long sys_vfork(void) current_frame(), 0, NULL, NULL); } -asmlinkage long sys_execve(const char __user *name, - const char __user *const __user *argv, - const char __user *const __user *envp) -{ - char *filename; - int error; - - filename = getname(name); - error = PTR_ERR(filename); - if (IS_ERR(filename)) - return error; - error = do_execve(filename, argv, envp, current_frame()); - putname(filename); - return error; -} - unsigned long get_wchan(struct task_struct *p) { return p->thread.wchan; -- cgit v1.2.3 From 61b7fbc3f4ebdcfd34f9438adfab8df936a19e33 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 22 Sep 2012 18:18:23 -0400 Subject: mn10300: convert to generic kernel_thread() Signed-off-by: Al Viro --- arch/mn10300/kernel/process.c | 49 ++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'arch/mn10300/kernel/process.c') diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c index 49af5ca89343..8ee09d828c43 100644 --- a/arch/mn10300/kernel/process.c +++ b/arch/mn10300/kernel/process.c @@ -161,24 +161,6 @@ void show_regs(struct pt_regs *regs) { } -/* - * create a kernel thread - */ -int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) -{ - struct pt_regs regs = { - .a0 = (unsigned long) fn; - .d0 = (unsigned long) arg; - }; - - local_save_flags(regs.epsw); - regs.epsw |= EPSW_IE | EPSW_IM_7; - - /* Ok, create the new process.. */ - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, - NULL, NULL); -} - /* * free current thread data structures etc.. */ @@ -232,29 +214,34 @@ int copy_thread(unsigned long clone_flags, /* allocate the userspace exception frame and set it up */ c_ksp -= sizeof(struct pt_regs); c_regs = (struct pt_regs *) c_ksp; + c_ksp -= 12; /* allocate function call ABI slack */ + /* set up things up so the scheduler can start the new task */ p->thread.uregs = c_regs; + ti->frame = c_regs; + p->thread.a3 = (unsigned long) c_regs; + p->thread.sp = c_ksp; + p->thread.wchan = p->thread.pc; + p->thread.usp = c_usp; + + if (unlikely(!kregs)) { + memset(c_regs, 0, sizeof(struct pt_regs)); + c_regs->a0 = c_usp; /* function */ + c_regs->d0 = ustk_size; /* argument */ + local_save_flags(c_regs->epsw); + c_regs->epsw |= EPSW_IE | EPSW_IM_7; + p->thread.pc = (unsigned long) ret_from_kernel_thread; + return 0; + } *c_regs = *kregs; c_regs->sp = c_usp; c_regs->epsw &= ~EPSW_FE; /* my FPU */ - c_ksp -= 12; /* allocate function call ABI slack */ - /* the new TLS pointer is passed in as arg #5 to sys_clone() */ if (clone_flags & CLONE_SETTLS) c_regs->e2 = current_frame()->d3; - if (unlikely(!user_mode(kregs))) - p->thread.pc = (unsigned long) ret_from_kernel_thread; - else - p->thread.pc = (unsigned long) ret_from_fork; - - /* set up things up so the scheduler can start the new task */ - ti->frame = c_regs; - p->thread.a3 = (unsigned long) c_regs; - p->thread.sp = c_ksp; - p->thread.wchan = p->thread.pc; - p->thread.usp = c_usp; + p->thread.pc = (unsigned long) ret_from_fork; return 0; } -- cgit v1.2.3