Commit e0877f07 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: fork cleanup

Fix the do_fork calling convention: normal arch pass the regs and the new sp
value to do_fork instead of NULL.

Currently the arch-independent code ignores these values, while the UML code
(actually it's copy_thread) gets the right values by itself.

With this patch, things are fixed up.
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 41f2148a
...@@ -96,8 +96,8 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) ...@@ -96,8 +96,8 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
current->thread.request.u.thread.proc = fn; current->thread.request.u.thread.proc = fn;
current->thread.request.u.thread.arg = arg; current->thread.request.u.thread.arg = arg;
pid = do_fork(CLONE_VM | CLONE_UNTRACED | flags, 0, NULL, 0, NULL, pid = do_fork(CLONE_VM | CLONE_UNTRACED | flags, 0,
NULL); &current->thread.regs, 0, NULL, NULL);
if(pid < 0) if(pid < 0)
panic("do_fork failed in kernel_thread, errno = %d", pid); panic("do_fork failed in kernel_thread, errno = %d", pid);
return(pid); return(pid);
......
...@@ -111,8 +111,7 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp, ...@@ -111,8 +111,7 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
void (*handler)(int); void (*handler)(int);
if(current->thread.forking){ if(current->thread.forking){
memcpy(&p->thread.regs.regs.skas, memcpy(&p->thread.regs.regs.skas, &regs->regs.skas,
&current->thread.regs.regs.skas,
sizeof(p->thread.regs.regs.skas)); sizeof(p->thread.regs.regs.skas));
REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.skas.regs, 0); REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.skas.regs, 0);
if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp; if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp;
...@@ -201,14 +200,3 @@ int thread_pid_skas(struct task_struct *task) ...@@ -201,14 +200,3 @@ int thread_pid_skas(struct task_struct *task)
#warning Need to look up userspace_pid by cpu #warning Need to look up userspace_pid by cpu
return(userspace_pid[0]); return(userspace_pid[0]);
} }
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
...@@ -31,7 +31,8 @@ long sys_fork(void) ...@@ -31,7 +31,8 @@ long sys_fork(void)
long ret; long ret;
current->thread.forking = 1; current->thread.forking = 1;
ret = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL); ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
&current->thread.regs, 0, NULL, NULL);
current->thread.forking = 0; current->thread.forking = 0;
return(ret); return(ret);
} }
...@@ -41,8 +42,9 @@ long sys_vfork(void) ...@@ -41,8 +42,9 @@ long sys_vfork(void)
long ret; long ret;
current->thread.forking = 1; current->thread.forking = 1;
ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL, ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
NULL); UPT_SP(&current->thread.regs.regs),
&current->thread.regs, 0, NULL, NULL);
current->thread.forking = 0; current->thread.forking = 0;
return(ret); return(ret);
} }
...@@ -162,14 +164,3 @@ int next_syscall_index(int limit) ...@@ -162,14 +164,3 @@ int next_syscall_index(int limit)
spin_unlock(&syscall_lock); spin_unlock(&syscall_lock);
return(ret); return(ret);
} }
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
...@@ -266,10 +266,10 @@ int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp, ...@@ -266,10 +266,10 @@ int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
} }
if(current->thread.forking){ if(current->thread.forking){
sc_to_sc(UPT_SC(&p->thread.regs.regs), sc_to_sc(UPT_SC(&p->thread.regs.regs), UPT_SC(&regs->regs));
UPT_SC(&current->thread.regs.regs));
SC_SET_SYSCALL_RETURN(UPT_SC(&p->thread.regs.regs), 0); SC_SET_SYSCALL_RETURN(UPT_SC(&p->thread.regs.regs), 0);
if(sp != 0) SC_SP(UPT_SC(&p->thread.regs.regs)) = sp; if(sp != 0)
SC_SP(UPT_SC(&p->thread.regs.regs)) = sp;
} }
p->thread.mode.tt.extern_pid = new_pid; p->thread.mode.tt.extern_pid = new_pid;
...@@ -459,14 +459,3 @@ int is_valid_pid(int pid) ...@@ -459,14 +459,3 @@ int is_valid_pid(int pid)
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
return(0); return(0);
} }
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
...@@ -69,15 +69,11 @@ long sys_clone(unsigned long clone_flags, unsigned long newsp, ...@@ -69,15 +69,11 @@ long sys_clone(unsigned long clone_flags, unsigned long newsp,
{ {
long ret; long ret;
/* XXX: normal arch do here this pass, and also pass the regs to if (!newsp)
* do_fork, instead of NULL. Currently the arch-independent code newsp = UPT_SP(&current->thread.regs.regs);
* ignores these values, while the UML code (actually it's
* copy_thread) does the right thing. But this should change,
probably. */
/*if (!newsp)
newsp = UPT_SP(current->thread.regs);*/
current->thread.forking = 1; current->thread.forking = 1;
ret = do_fork(clone_flags, newsp, NULL, 0, parent_tid, child_tid); ret = do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
child_tid);
current->thread.forking = 0; current->thread.forking = 0;
return(ret); return(ret);
} }
...@@ -197,14 +193,3 @@ long sys_sigaction(int sig, const struct old_sigaction __user *act, ...@@ -197,14 +193,3 @@ long sys_sigaction(int sig, const struct old_sigaction __user *act,
return ret; return ret;
} }
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
...@@ -174,26 +174,11 @@ long sys_clone(unsigned long clone_flags, unsigned long newsp, ...@@ -174,26 +174,11 @@ long sys_clone(unsigned long clone_flags, unsigned long newsp,
{ {
long ret; long ret;
/* XXX: normal arch do here this pass, and also pass the regs to if (!newsp)
* do_fork, instead of NULL. Currently the arch-independent code newsp = UPT_SP(&current->thread.regs.regs);
* ignores these values, while the UML code (actually it's
* copy_thread) does the right thing. But this should change,
probably. */
/*if (!newsp)
newsp = UPT_SP(current->thread.regs);*/
current->thread.forking = 1; current->thread.forking = 1;
ret = do_fork(clone_flags, newsp, NULL, 0, parent_tid, child_tid); ret = do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
child_tid);
current->thread.forking = 0; current->thread.forking = 0;
return(ret); return(ret);
} }
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment