From 02ce496f152df87be081a64796498942c433a2fd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 18 Sep 2012 22:18:51 -0400 Subject: frv: split ret_from_fork, simplify kernel_thread() a lot Acked-by: David Howells Signed-off-by: Al Viro --- arch/frv/kernel/process.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'arch/frv/kernel/process.c') diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c index ff95f50efea5..0f02dee25e26 100644 --- a/arch/frv/kernel/process.c +++ b/arch/frv/kernel/process.c @@ -37,6 +37,7 @@ #include "local.h" asmlinkage void ret_from_fork(void); +asmlinkage void ret_from_kernel_thread(void); #include @@ -172,29 +173,21 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long topstk, struct task_struct *p, struct pt_regs *regs) { - struct pt_regs *childregs0, *childregs, *regs0; + struct pt_regs *childregs; - regs0 = __kernel_frame0_ptr; - childregs0 = (struct pt_regs *) + childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE - FRV_FRAME0_SIZE); - childregs = childregs0; /* set up the userspace frame (the only place that the USP is stored) */ - *childregs0 = *regs0; - - childregs0->gr8 = 0; - childregs0->sp = usp; - childregs0->next_frame = NULL; - - /* set up the return kernel frame if called from kernel_thread() */ - if (regs != regs0) { - childregs--; - *childregs = *regs; - childregs->sp = (unsigned long) childregs0; - childregs->next_frame = childregs0; - childregs->gr15 = (unsigned long) task_thread_info(p); - childregs->gr29 = (unsigned long) p; - } + *childregs = *regs; + + childregs->sp = usp; + childregs->next_frame = NULL; + + if (unlikely(!user_mode(regs))) + p->thread.pc = (unsigned long) ret_from_kernel_thread; + else + p->thread.pc = (unsigned long) ret_from_fork; p->set_child_tid = p->clear_child_tid = NULL; @@ -203,8 +196,7 @@ int copy_thread(unsigned long clone_flags, p->thread.sp = (unsigned long) childregs; p->thread.fp = 0; p->thread.lr = 0; - p->thread.pc = (unsigned long) ret_from_fork; - p->thread.frame0 = childregs0; + p->thread.frame0 = childregs; /* the new TLS pointer is passed in as arg #5 to sys_clone() */ if (clone_flags & CLONE_SETTLS) @@ -347,3 +339,13 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs) sizeof(current->thread.user->f)); return 1; } + +int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) +{ + struct pt_regs regs = { + .gr8 = (unsigned long)arg; + .gr9 = (unsigned long)fn; + .psr = PSR_S; + }; + return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); +} -- cgit v1.2.3 From 460dabab73f2f60198c37ed7bf6d192d23eaa286 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 18 Sep 2012 22:25:02 -0400 Subject: frv: switch to generic sys_execve() current_pt_regs() here is simply __frame Acked-by: David Howells Signed-off-by: Al Viro --- arch/frv/kernel/process.c | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'arch/frv/kernel/process.c') diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c index 0f02dee25e26..7ff4dbef0567 100644 --- a/arch/frv/kernel/process.c +++ b/arch/frv/kernel/process.c @@ -207,25 +207,6 @@ int copy_thread(unsigned long clone_flags, return 0; } /* end copy_thread() */ -/* - * sys_execve() executes a new program. - */ -asmlinkage int sys_execve(const char __user *name, - const char __user *const __user *argv, - const char __user *const __user *envp) -{ - int error; - char * filename; - - filename = getname(name); - error = PTR_ERR(filename); - if (IS_ERR(filename)) - return error; - error = do_execve(filename, argv, envp, __frame); - putname(filename); - return error; -} - unsigned long get_wchan(struct task_struct *p) { struct pt_regs *regs0; -- cgit v1.2.3 From 49ed3398b75c98c087537a7d5a1a23f86a8c8746 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 22 Sep 2012 18:10:15 -0400 Subject: frv: switch to generic kernel_thread() --- arch/frv/kernel/process.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'arch/frv/kernel/process.c') diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c index 7ff4dbef0567..014f855362b9 100644 --- a/arch/frv/kernel/process.c +++ b/arch/frv/kernel/process.c @@ -170,7 +170,7 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, * set up the kernel stack and exception frames for a new process */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long topstk, + unsigned long usp, unsigned long arg, struct task_struct *p, struct pt_regs *regs) { struct pt_regs *childregs; @@ -178,17 +178,6 @@ int copy_thread(unsigned long clone_flags, childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE - FRV_FRAME0_SIZE); - /* set up the userspace frame (the only place that the USP is stored) */ - *childregs = *regs; - - childregs->sp = usp; - childregs->next_frame = NULL; - - if (unlikely(!user_mode(regs))) - p->thread.pc = (unsigned long) ret_from_kernel_thread; - else - p->thread.pc = (unsigned long) ret_from_fork; - p->set_child_tid = p->clear_child_tid = NULL; p->thread.frame = childregs; @@ -198,6 +187,24 @@ int copy_thread(unsigned long clone_flags, p->thread.lr = 0; p->thread.frame0 = childregs; + if (unlikely(!regs)) { + memset(childregs, 0, sizeof(struct pt_regs)); + childregs->gr9 = usp; /* function */ + childregs->gr8 = arg; + chilregs->psr = PSR_S; + p->thread.pc = (unsigned long) ret_from_kernel_thread; + save_user_regs(p->thread.user); + return 0; + } + + /* set up the userspace frame (the only place that the USP is stored) */ + *childregs = *regs; + + childregs->sp = usp; + childregs->next_frame = NULL; + + p->thread.pc = (unsigned long) ret_from_fork; + /* the new TLS pointer is passed in as arg #5 to sys_clone() */ if (clone_flags & CLONE_SETTLS) childregs->gr29 = childregs->gr12; @@ -320,13 +327,3 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs) sizeof(current->thread.user->f)); return 1; } - -int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) -{ - struct pt_regs regs = { - .gr8 = (unsigned long)arg; - .gr9 = (unsigned long)fn; - .psr = PSR_S; - }; - return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); -} -- cgit v1.2.3