From d6ca8c92c335bd8bb7ac2fe8fdfc1ed6dd3e1f38 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Thu, 5 Oct 2006 18:47:22 +0200 Subject: [PATCH] --- yaml --- r: 39020 b: refs/heads/master c: 51ec28e1b2cb267a09a0b8eac1ccf8d61b7268bf h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/arch/i386/kernel/process.c | 6 +++++- trunk/arch/x86_64/kernel/entry.S | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index af337607b4a5..2f1ccc0bedda 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f015c6c4d733f68cbc1c5d231bb158abaa5c9606 +refs/heads/master: 51ec28e1b2cb267a09a0b8eac1ccf8d61b7268bf diff --git a/trunk/arch/i386/kernel/process.c b/trunk/arch/i386/kernel/process.c index dad02a960e03..b0a07801d9df 100644 --- a/trunk/arch/i386/kernel/process.c +++ b/trunk/arch/i386/kernel/process.c @@ -328,6 +328,7 @@ extern void kernel_thread_helper(void); int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) { struct pt_regs regs; + int err; memset(®s, 0, sizeof(regs)); @@ -342,7 +343,10 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2; /* Ok, create the new process.. */ - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); + err = do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); + if (err == 0) /* terminate kernel stack */ + task_pt_regs(current)->eip = 0; + return err; } EXPORT_SYMBOL(kernel_thread); diff --git a/trunk/arch/x86_64/kernel/entry.S b/trunk/arch/x86_64/kernel/entry.S index b8285cf1a9c3..ab9b2c4726f2 100644 --- a/trunk/arch/x86_64/kernel/entry.S +++ b/trunk/arch/x86_64/kernel/entry.S @@ -978,6 +978,11 @@ ENTRY(kernel_thread) call do_fork movq %rax,RAX(%rsp) xorl %edi,%edi + test %rax,%rax + jnz 1f + /* terminate stack in child */ + movq %rdi,RIP(%rsp) +1: /* * It isn't worth to check for reschedule here,