@@ -123,8 +123,11 @@ EXPORT_SYMBOL(dump_fpu);
asmlinkage void ret_from_fork(void);
asmlinkage void ret_from_kernel_thread(void);
+/*
+ * Copy architecture-specific thread state
+ */
int copy_thread(unsigned long clone_flags, unsigned long usp,
- unsigned long arg, struct task_struct *p)
+ unsigned long kthread_arg, struct task_struct *p)
{
struct thread_info *ti = task_thread_info(p);
struct pt_regs *childregs;
@@ -146,9 +149,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
childregs = task_pt_regs(p);
p->thread.sp = (unsigned long) childregs;
if (unlikely(p->flags & PF_KTHREAD)) {
+ /* kernel thread */
memset(childregs, 0, sizeof(struct pt_regs));
p->thread.pc = (unsigned long) ret_from_kernel_thread;
- childregs->regs[4] = arg;
+ childregs->regs[4] = kthread_arg;
childregs->regs[5] = usp;
childregs->sr = SR_MD;
#if defined(CONFIG_SH_FPU)
@@ -159,6 +163,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
p->thread.fpu_counter = 0;
return 0;
}
+
+ /* user thread */
*childregs = *current_pt_regs();
if (usp)
@@ -371,8 +371,11 @@ EXPORT_SYMBOL(dump_fpu);
asmlinkage void ret_from_fork(void);
asmlinkage void ret_from_kernel_thread(void);
+/*
+ * Copy architecture-specific thread state
+ */
int copy_thread(unsigned long clone_flags, unsigned long usp,
- unsigned long arg, struct task_struct *p)
+ unsigned long kthread_arg, struct task_struct *p)
{
struct pt_regs *childregs;
@@ -391,14 +394,17 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
p->thread.sp = (unsigned long) childregs;
if (unlikely(p->flags & PF_KTHREAD)) {
+ /* kernel thread */
memset(childregs, 0, sizeof(struct pt_regs));
- childregs->regs[2] = (unsigned long)arg;
- childregs->regs[3] = (unsigned long)usp;
+ childregs->regs[2] = kthread_arg;
+ childregs->regs[3] = usp;
childregs->sr = (1 << 30); /* not user_mode */
childregs->sr |= SR_FD; /* Invalidate FPU flag */
p->thread.pc = (unsigned long) ret_from_kernel_thread;
return 0;
}
+
+ /* user thread */
*childregs = *current_pt_regs();
/*
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad <alexinbeijing@gmail.com> --- arch/sh/kernel/process_32.c | 10 ++++++++-- arch/sh/kernel/process_64.c | 12 +++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-)