Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4d94ff8 authored by Al Viro's avatar Al Viro
Browse files

um: kill thread->forking



we only use that to tell copy_thread() done by syscall from that
done by kernel_thread().  However, it's easier to do simply by
checking PF_KTHREAD in thread flags.

Merge sys_clone() guts for 32bit and 64bit, while we are at it...

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 8e2c85aa
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -20,14 +20,6 @@ struct mm_struct;

struct thread_struct {
	struct task_struct *saved_task;
	/*
	 * This flag is set to 1 before calling do_fork (and analyzed in
	 * copy_thread) to mark that we are begin called from userspace (fork /
	 * vfork / clone), and reset to 0 after. It is left to 0 when called
	 * from kernelspace (i.e. kernel_thread() or fork_idle(),
	 * as of 2.6.11).
	 */
	int forking;
	struct pt_regs regs;
	int singlestep_syscall;
	void *fault_addr;
@@ -58,7 +50,6 @@ struct thread_struct {

#define INIT_THREAD \
{ \
	.forking		= 0, \
	.regs		   	= EMPTY_REGS,	\
	.fault_addr		= NULL, \
	.prev_sched		= NULL, \
+4 −4
Original line number Diff line number Diff line
@@ -181,11 +181,12 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
		struct pt_regs *regs)
{
	void (*handler)(void);
	int kthread = current->flags & PF_KTHREAD;
	int ret = 0;

	p->thread = (struct thread_struct) INIT_THREAD;

	if (current->thread.forking) {
	if (!kthread) {
	  	memcpy(&p->thread.regs.regs, &regs->regs,
		       sizeof(p->thread.regs.regs));
		PT_REGS_SET_SYSCALL_RETURN(&p->thread.regs, 0);
@@ -195,8 +196,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
		handler = fork_handler;

		arch_copy_thread(&current->thread.arch, &p->thread.arch);
	}
	else {
	} else {
		get_safe_registers(p->thread.regs.regs.gp, p->thread.regs.regs.fp);
		p->thread.request.u.thread = current->thread.request.u.thread;
		handler = new_thread_handler;
@@ -204,7 +204,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,

	new_thread(task_stack_page(p), &p->thread.switch_buf, handler);

	if (current->thread.forking) {
	if (!kthread) {
		clear_flushed_tls(p);

		/*
+12 −12
Original line number Diff line number Diff line
@@ -17,25 +17,25 @@

long sys_fork(void)
{
	long ret;

	current->thread.forking = 1;
	ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
	return do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
		      &current->thread.regs, 0, NULL, NULL);
	current->thread.forking = 0;
	return ret;
}

long sys_vfork(void)
{
	long ret;

	current->thread.forking = 1;
	ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
	return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
		      UPT_SP(&current->thread.regs.regs),
		      &current->thread.regs, 0, NULL, NULL);
	current->thread.forking = 0;
	return ret;
}

long sys_clone(unsigned long clone_flags, unsigned long newsp,
	       void __user *parent_tid, void __user *child_tid)
{
	if (!newsp)
		newsp = UPT_SP(&current->thread.regs.regs);

	return do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
		      child_tid);
}

long old_mmap(unsigned long addr, unsigned long len,
+2 −0
Original line number Diff line number Diff line
extern long sys_clone(unsigned long clone_flags, unsigned long newsp,
	       void __user *parent_tid, void __user *child_tid);
#ifdef __i386__
#include "syscalls_32.h"
#else
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
#define ptregs_execve sys_execve
#define ptregs_iopl sys_iopl
#define ptregs_vm86old sys_vm86old
#define ptregs_clone sys_clone
#define ptregs_clone i386_clone
#define ptregs_vm86 sys_vm86
#define ptregs_sigaltstack sys_sigaltstack
#define ptregs_vfork sys_vfork
Loading