From aa195e816f53324b28544729a747ff6aaeea3b0f Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Thu, 20 Jan 2000 22:18:54 +0000 Subject: [PATCH] Fix PR9240: comment above cpu_fork() out of synch with reality on most ports. (comment change only, but was wrong for more than just i386). --- sys/arch/alpha/alpha/vm_machdep.c | 24 ++++++++++++++++-------- sys/arch/amiga/amiga/vm_machdep.c | 22 ++++++++++++++++------ sys/arch/arm32/arm32/vm_machdep.c | 22 +++++++++++++++------- sys/arch/atari/atari/vm_machdep.c | 22 ++++++++++++++++------ sys/arch/hp300/hp300/vm_machdep.c | 22 +++++++++++++++------- sys/arch/i386/i386/vm_machdep.c | 22 +++++++++++++++------- sys/arch/luna68k/luna68k/vm_machdep.c | 26 ++++++++++++++++++-------- sys/arch/mac68k/mac68k/vm_machdep.c | 22 ++++++++++++++++------ sys/arch/mips/mips/vm_machdep.c | 24 +++++++++++++++++------- sys/arch/mvme68k/mvme68k/vm_machdep.c | 22 ++++++++++++++++------ sys/arch/news68k/news68k/vm_machdep.c | 22 +++++++++++++++------- sys/arch/next68k/next68k/vm_machdep.c | 22 +++++++++++++++------- sys/arch/pc532/pc532/vm_machdep.c | 19 +++++++++++++++---- sys/arch/powerpc/powerpc/vm_machdep.c | 16 +++++++++++++++- sys/arch/sh3/sh3/vm_machdep.c | 22 +++++++++++++++------- sys/arch/sparc/sparc/vm_machdep.c | 19 ++++++++++++++----- sys/arch/sparc64/sparc64/vm_machdep.c | 19 ++++++++++++++----- sys/arch/sun3/sun3/vm_machdep.c | 22 ++++++++++++++++------ sys/arch/vax/vax/vm_machdep.c | 18 +++++++++++++++++- sys/arch/x68k/x68k/vm_machdep.c | 22 ++++++++++++++++------ 20 files changed, 312 insertions(+), 117 deletions(-) diff --git a/sys/arch/alpha/alpha/vm_machdep.c b/sys/arch/alpha/alpha/vm_machdep.c index 90281789bed3..ebc03e56cf0e 100644 --- a/sys/arch/alpha/alpha/vm_machdep.c +++ b/sys/arch/alpha/alpha/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.52 1999/12/04 21:19:59 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.53 2000/01/20 22:18:54 sommerfeld Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -29,7 +29,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.52 1999/12/04 21:19:59 ragge Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.53 2000/01/20 22:18:54 sommerfeld Exp $"); #include #include @@ -131,12 +131,20 @@ cpu_exit(p) /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the kernel stack and pcb, making the child - * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. - * We currently double-map the user area so that the stack is at the same - * address in each process; in the future we will probably relocate - * the frame pointers on the stack after copying. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * switch_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/amiga/amiga/vm_machdep.c b/sys/arch/amiga/amiga/vm_machdep.c index 36ebceafb487..43c5445ddae5 100644 --- a/sys/arch/amiga/amiga/vm_machdep.c +++ b/sys/arch/amiga/amiga/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.52 1999/12/04 21:20:03 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.53 2000/01/20 22:18:55 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -64,11 +64,21 @@ #include /* - * Finish a fork operation, with process p2 nearly set up. Copy and - * update the kernel stack and pcb, making the child ready to run, - * and marking it so that it can return differently than the parent. - * When scheduled, child p2 will start from proc_trampoline(). cpu_fork() - * returns once for forking parent p1. + * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/arm32/arm32/vm_machdep.c b/sys/arch/arm32/arm32/vm_machdep.c index c2a03809303a..371ec0f24985 100644 --- a/sys/arch/arm32/arm32/vm_machdep.c +++ b/sys/arch/arm32/arm32/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.47 1999/12/04 21:20:09 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.48 2000/01/20 22:18:55 sommerfeld Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -96,12 +96,20 @@ pt_entry_t *pmap_pte __P((pmap_t, vm_offset_t)); /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the kernel stack and pcb, making the child - * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. - * We currently double-map the user area so that the stack is at the same - * address in each process; in the future we will probably relocate - * the frame pointers on the stack after copying. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void diff --git a/sys/arch/atari/atari/vm_machdep.c b/sys/arch/atari/atari/vm_machdep.c index 56d05d246879..a598e37aca67 100644 --- a/sys/arch/atari/atari/vm_machdep.c +++ b/sys/arch/atari/atari/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.30 1999/12/04 21:20:15 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.31 2000/01/20 22:18:55 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -64,11 +64,21 @@ #include /* - * Finish a fork operation, with process p2 nearly set up. Copy and - * update the kernel stack and pcb, making the child ready to run, - * and marking it so that it can return differently than the parent. - * When scheduled, child p2 will start from proc_trampoline(). cpu_fork() - * returns once for forking parent p1. + * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/hp300/hp300/vm_machdep.c b/sys/arch/hp300/hp300/vm_machdep.c index 717c42bd4d66..6b87f0454a2e 100644 --- a/sys/arch/hp300/hp300/vm_machdep.c +++ b/sys/arch/hp300/hp300/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.53 1999/12/04 21:20:24 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.54 2000/01/20 22:18:56 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -64,12 +64,20 @@ /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the kernel stack and pcb, making the child - * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. - * We currently double-map the user area so that the stack is at the same - * address in each process; in the future we will probably relocate - * the frame pointers on the stack after copying. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/i386/i386/vm_machdep.c b/sys/arch/i386/i386/vm_machdep.c index 2e0d8f151333..9784d7f9b2e6 100644 --- a/sys/arch/i386/i386/vm_machdep.c +++ b/sys/arch/i386/i386/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.85 1999/12/04 21:20:33 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.86 2000/01/20 22:18:56 sommerfeld Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -77,12 +77,20 @@ void setredzone __P((u_short *, caddr_t)); /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the kernel stack and pcb, making the child - * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. - * We currently double-map the user area so that the stack is at the same - * address in each process; in the future we will probably relocate - * the frame pointers on the stack after copying. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/luna68k/luna68k/vm_machdep.c b/sys/arch/luna68k/luna68k/vm_machdep.c index f041e01d3bab..7301596e288a 100644 --- a/sys/arch/luna68k/luna68k/vm_machdep.c +++ b/sys/arch/luna68k/luna68k/vm_machdep.c @@ -1,5 +1,5 @@ -/* $NetBSD: vm_machdep.c,v 1.1 2000/01/05 08:49:04 nisimura Exp $ */ -/* $NetBSD: vm_machdep.c,v 1.1 2000/01/05 08:49:04 nisimura Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.2 2000/01/20 22:18:56 sommerfeld Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.2 2000/01/20 22:18:56 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -44,7 +44,7 @@ */ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.1 2000/01/05 08:49:04 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.2 2000/01/20 22:18:56 sommerfeld Exp $"); #include "opt_compat_hpux.h" @@ -69,11 +69,21 @@ __KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.1 2000/01/05 08:49:04 nisimura Exp #include /* - * Finish a fork operation, with process p2 nearly set up. Copy and - * update the kernel stack and pcb, making the child ready to run, - * and marking it so that it can return differently than the parent. - * When scheduled, child p2 will start from proc_trampoline(). cpu_fork() - * returns once for forking parent p1. + * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/mac68k/mac68k/vm_machdep.c b/sys/arch/mac68k/mac68k/vm_machdep.c index 9dd2353c35c4..e336ab838566 100644 --- a/sys/arch/mac68k/mac68k/vm_machdep.c +++ b/sys/arch/mac68k/mac68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.44 1999/12/04 21:20:45 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.45 2000/01/20 22:18:57 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -63,11 +63,21 @@ #include /* - * Finish a fork operation, with process p2 nearly set up. Copy and - * update the kernel stack and pcb, making the child ready to run, - * and marking it so that it can return differently than the parent. - * When scheduled, child p2 will start from proc_trampoline(). cpu_fork() - * returns once for forking parent p1. + * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/mips/mips/vm_machdep.c b/sys/arch/mips/mips/vm_machdep.c index b06882c65aad..205e05cbc21e 100644 --- a/sys/arch/mips/mips/vm_machdep.c +++ b/sys/arch/mips/mips/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.46 2000/01/09 08:01:55 shin Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.47 2000/01/20 22:18:57 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -43,7 +43,7 @@ */ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.46 2000/01/09 08:01:55 shin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.47 2000/01/20 22:18:57 sommerfeld Exp $"); #include #include @@ -72,11 +72,21 @@ extern struct proc *fpcurproc; extern paddr_t kvtophys __P((vaddr_t)); /* XXX */ /* - * Finish a fork operation, with process p2 nearly set up. Copy and - * update the kernel stack and pcb, making the child ready to run, - * and marking it so that it can return differently than the parent. - * When scheduled, child p2 will start from proc_trampoline(). cpu_fork() - * returns once for forking parent p1. + * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/mvme68k/mvme68k/vm_machdep.c b/sys/arch/mvme68k/mvme68k/vm_machdep.c index c5d4558cabfe..3bf0684fe74d 100644 --- a/sys/arch/mvme68k/mvme68k/vm_machdep.c +++ b/sys/arch/mvme68k/mvme68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.27 1999/12/04 21:20:56 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.28 2000/01/20 22:18:57 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -65,11 +65,21 @@ #include /* - * Finish a fork operation, with process p2 nearly set up. Copy and - * update the kernel stack and pcb, making the child ready to run, - * and marking it so that it can return differently than the parent. - * When scheduled, child p2 will start from proc_trampoline(). cpu_fork() - * returns once for forking parent p1. + * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/news68k/news68k/vm_machdep.c b/sys/arch/news68k/news68k/vm_machdep.c index 3bc262e741ba..9734bfd99170 100644 --- a/sys/arch/news68k/news68k/vm_machdep.c +++ b/sys/arch/news68k/news68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.1 1999/12/09 14:53:18 tsutsui Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.2 2000/01/20 22:18:57 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -64,12 +64,20 @@ /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the kernel stack and pcb, making the child - * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. - * We currently double-map the user area so that the stack is at the same - * address in each process; in the future we will probably relocate - * the frame pointers on the stack after copying. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/next68k/next68k/vm_machdep.c b/sys/arch/next68k/next68k/vm_machdep.c index 0c96ee0fa9fc..7d743e69238d 100644 --- a/sys/arch/next68k/next68k/vm_machdep.c +++ b/sys/arch/next68k/next68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.15 1999/12/04 21:21:04 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.16 2000/01/20 22:18:58 sommerfeld Exp $ */ /* * This file was taken from mvme68k/mvme68k/vm_machdep.c @@ -75,12 +75,20 @@ /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the kernel stack and pcb, making the child - * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. - * We currently double-map the user area so that the stack is at the same - * address in each process; in the future we will probably relocate - * the frame pointers on the stack after copying. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/pc532/pc532/vm_machdep.c b/sys/arch/pc532/pc532/vm_machdep.c index 6103869ea389..adf28e5c1120 100644 --- a/sys/arch/pc532/pc532/vm_machdep.c +++ b/sys/arch/pc532/pc532/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.39 1999/12/04 21:21:14 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.40 2000/01/20 22:18:58 sommerfeld Exp $ */ /*- * Copyright (c) 1996 Matthias Pfaller. @@ -68,9 +68,20 @@ void setredzone __P((u_short *, caddr_t)); /* * Finish a fork operation, with process p2 nearly set up. - * Copy the pcb and setup the kernel stack for the child. - * Setup the child's stackframe to return to child_return - * via proc_trampoline from cpu_switch. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/powerpc/powerpc/vm_machdep.c b/sys/arch/powerpc/powerpc/vm_machdep.c index 40ed76b5e5cf..c64d7499f801 100644 --- a/sys/arch/powerpc/powerpc/vm_machdep.c +++ b/sys/arch/powerpc/powerpc/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.14 1999/11/13 00:30:43 thorpej Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.15 2000/01/20 22:18:58 sommerfeld Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -48,6 +48,20 @@ /* * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * fork_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/sh3/sh3/vm_machdep.c b/sys/arch/sh3/sh3/vm_machdep.c index b9a11c3f3791..ab7bbf53a073 100644 --- a/sys/arch/sh3/sh3/vm_machdep.c +++ b/sys/arch/sh3/sh3/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.6 2000/01/07 12:01:00 msaitoh Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.7 2000/01/20 22:18:59 sommerfeld Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -66,12 +66,20 @@ void setredzone __P((u_short *, caddr_t)); /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the kernel stack and pcb, making the child - * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. - * We currently double-map the user area so that the stack is at the same - * address in each process; in the future we will probably relocate - * the frame pointers on the stack after copying. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/sparc/sparc/vm_machdep.c b/sys/arch/sparc/sparc/vm_machdep.c index e525752c508e..2e613aafcbfd 100644 --- a/sys/arch/sparc/sparc/vm_machdep.c +++ b/sys/arch/sparc/sparc/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.50 1999/12/04 21:21:32 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.51 2000/01/20 22:18:59 sommerfeld Exp $ */ /* * Copyright (c) 1996 @@ -184,11 +184,20 @@ vunmapbuf(bp, len) /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the pcb, making the child ready to run, and marking - * it so that it can return differently than the parent. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. * - * This function relies on the fact that the pcb is - * the first element in struct user. + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/sparc64/sparc64/vm_machdep.c b/sys/arch/sparc64/sparc64/vm_machdep.c index bc87c9eb4cbb..c20124572754 100644 --- a/sys/arch/sparc64/sparc64/vm_machdep.c +++ b/sys/arch/sparc64/sparc64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.24 1999/12/30 16:42:10 eeh Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.25 2000/01/20 22:18:59 sommerfeld Exp $ */ /* * Copyright (c) 1996 @@ -210,11 +210,20 @@ char cpu_forkname[] = "cpu_fork()"; /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the pcb, making the child ready to run, and marking - * it so that it can return differently than the parent. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. * - * This function relies on the fact that the pcb is - * the first element in struct user. + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/sun3/sun3/vm_machdep.c b/sys/arch/sun3/sun3/vm_machdep.c index 2a5d34e278d5..ef5f4a5ffb16 100644 --- a/sys/arch/sun3/sun3/vm_machdep.c +++ b/sys/arch/sun3/sun3/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.56 1999/12/04 21:21:45 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.57 2000/01/20 22:18:59 sommerfeld Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -69,11 +69,21 @@ extern void proc_do_uret __P((void)); extern void proc_trampoline __P((void)); /* - * Finish a fork operation, with process p2 nearly set up. Copy and - * update the kernel stack and pcb, making the child ready to run, - * and marking it so that it can return differently than the parent. - * When scheduled, child p2 will start from proc_do_uret(). cpu_fork() - * returns once for forking parent p1. + * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_do_uret() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize) diff --git a/sys/arch/vax/vax/vm_machdep.c b/sys/arch/vax/vax/vm_machdep.c index b2da15ec5bfc..866974051c16 100644 --- a/sys/arch/vax/vax/vm_machdep.c +++ b/sys/arch/vax/vax/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.55 1999/10/22 21:14:34 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.56 2000/01/20 22:19:00 sommerfeld Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -84,6 +84,22 @@ pagemove(from, to, size) } /* + * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. + * * cpu_fork() copies parent process trapframe directly into child PCB * so that when we swtch() to the child process it will go directly * back to user mode without any need to jump back through kernel. diff --git a/sys/arch/x68k/x68k/vm_machdep.c b/sys/arch/x68k/x68k/vm_machdep.c index 2a0d7397f0f1..2738a60da239 100644 --- a/sys/arch/x68k/x68k/vm_machdep.c +++ b/sys/arch/x68k/x68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.28 1999/12/04 21:21:50 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.29 2000/01/20 22:19:00 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -63,11 +63,21 @@ #include /* - * Finish a fork operation, with process p2 nearly set up. Copy and - * update the kernel stack and pcb, making the child ready to run, - * and marking it so that it can return differently than the parent. - * When scheduled, child p2 will start from proc_trampoline(). cpu_fork() - * returns once for forking parent p1. + * Finish a fork operation, with process p2 nearly set up. + * Copy and update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * proc_trampoline() and call child_return() with p2 as an + * argument. This causes the newly-created child process to go + * directly to user level with an apparent return value of 0 from + * fork(), while the parent process returns normally. + * + * p1 is the process being forked; if p1 == &proc0, we are creating + * a kernel thread, and the return path will later be changed in cpu_set_kpc. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack pointer + * accordingly. */ void cpu_fork(p1, p2, stack, stacksize)