Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Allow the caller to specify a stack for the child proces...
details: https://anonhg.NetBSD.org/src/rev/a4d08ebaee04
branches: trunk
changeset: 472948:a4d08ebaee04
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu May 13 21:58:32 1999 +0000
description:
Allow the caller to specify a stack for the child process. If NULL,
the child inherits the stack pointer from the parent (traditional
behavior). Like the signal stack, the stack area is secified as
a low address and a size; machine-dependent code accounts for stack
direction.
This is required for clone(2).
diffstat:
sys/arch/alpha/alpha/vm_machdep.c | 14 +++++++++++---
sys/arch/amiga/amiga/vm_machdep.c | 13 +++++++++++--
sys/arch/arm32/arm32/vm_machdep.c | 14 +++++++++++---
sys/arch/atari/atari/vm_machdep.c | 13 +++++++++++--
sys/arch/hp300/hp300/vm_machdep.c | 13 +++++++++++--
sys/arch/i386/i386/vm_machdep.c | 13 +++++++++++--
sys/arch/mac68k/mac68k/vm_machdep.c | 13 +++++++++++--
sys/arch/mips/mips/vm_machdep.c | 14 +++++++++++---
sys/arch/mvme68k/mvme68k/vm_machdep.c | 13 +++++++++++--
sys/arch/next68k/next68k/vm_machdep.c | 13 +++++++++++--
sys/arch/pc532/pc532/vm_machdep.c | 13 +++++++++++--
sys/arch/powerpc/powerpc/vm_machdep.c | 13 +++++++++++--
sys/arch/sparc/sparc/vm_machdep.c | 12 ++++++++++--
sys/arch/sparc64/sparc64/vm_machdep.c | 12 ++++++++++--
sys/arch/sun3/sun3/vm_machdep.c | 12 ++++++++++--
sys/arch/vax/vax/vm_machdep.c | 13 +++++++++++--
sys/arch/x68k/x68k/vm_machdep.c | 13 +++++++++++--
sys/kern/init_main.c | 4 ++--
sys/kern/kern_fork.c | 16 ++++++++++------
sys/kern/kern_kthread.c | 4 ++--
sys/sys/proc.h | 5 +++--
sys/uvm/uvm_extern.h | 5 +++--
sys/uvm/uvm_glue.c | 10 +++++++---
sys/vm/vm_extern.h | 4 ++--
24 files changed, 213 insertions(+), 56 deletions(-)
diffs (truncated from 800 to 300 lines):
diff -r 12c86d099d40 -r a4d08ebaee04 sys/arch/alpha/alpha/vm_machdep.c
--- a/sys/arch/alpha/alpha/vm_machdep.c Thu May 13 21:46:17 1999 +0000
+++ b/sys/arch/alpha/alpha/vm_machdep.c Thu May 13 21:58:32 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.45 1999/03/26 23:41:26 mycroft Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.46 1999/05/13 21:58:32 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.45 1999/03/26 23:41:26 mycroft Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.46 1999/05/13 21:58:32 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -139,8 +139,10 @@
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2)
+cpu_fork(p1, p2, stack, stacksize)
register struct proc *p1, *p2;
+ void *stack;
+ size_t stacksize;
{
struct user *up = p2->p_addr;
int i;
@@ -221,6 +223,12 @@
p2tf->tf_regs[FRAME_A4] = 1; /* is child */
/*
+ * If specificed, give the child a different stack.
+ */
+ if (stack != NULL)
+ p2tf->tf_regs[FRAME_SP] = (u_long)stack + stacksize;
+
+ /*
* Arrange for continuation at child_return(), which
* will return to exception_return(). Note that the child
* process doesn't stay in the kernel for long!
diff -r 12c86d099d40 -r a4d08ebaee04 sys/arch/amiga/amiga/vm_machdep.c
--- a/sys/arch/amiga/amiga/vm_machdep.c Thu May 13 21:46:17 1999 +0000
+++ b/sys/arch/amiga/amiga/vm_machdep.c Thu May 13 21:58:32 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.42 1999/03/26 23:41:27 mycroft Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.43 1999/05/13 21:58:33 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -72,8 +72,10 @@
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2)
+cpu_fork(p1, p2, stack, stacksize)
register struct proc *p1, *p2;
+ void *stack;
+ size_t stacksize;
{
register struct pcb *pcb = &p2->p_addr->u_pcb;
register struct trapframe *tf;
@@ -100,6 +102,13 @@
tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) - 1;
p2->p_md.md_regs = (int *)tf;
*tf = *(struct trapframe *)p1->p_md.md_regs;
+
+ /*
+ * If specified, give the child a different stack.
+ */
+ if (stack != NULL)
+ tf->tf_regs[15] = (u_int)stack + stacksize;
+
sf = (struct switchframe *)tf - 1;
sf->sf_pc = (u_int)proc_trampoline;
pcb->pcb_regs[6] = (int)child_return; /* A2 */
diff -r 12c86d099d40 -r a4d08ebaee04 sys/arch/arm32/arm32/vm_machdep.c
--- a/sys/arch/arm32/arm32/vm_machdep.c Thu May 13 21:46:17 1999 +0000
+++ b/sys/arch/arm32/arm32/vm_machdep.c Thu May 13 21:58:32 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.41 1999/03/30 21:01:42 mycroft Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.42 1999/05/13 21:58:33 thorpej Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@@ -106,9 +106,11 @@
*/
void
-cpu_fork(p1, p2)
+cpu_fork(p1, p2, stack, stacksize)
struct proc *p1;
struct proc *p2;
+ void *stack;
+ size_t stacksize;
{
struct pcb *pcb = (struct pcb *)&p2->p_addr->u_pcb;
struct trapframe *tf;
@@ -165,8 +167,14 @@
#endif /* ARMFPE */
p2->p_md.md_regs = tf = (struct trapframe *)pcb->pcb_sp - 1;
+ *tf = *p1->p_md.md_regs;
- *tf = *p1->p_md.md_regs;
+ /*
+ * If specified, give the child a different stack.
+ */
+ if (stack != NULL)
+ tf->tf_usr_sp = (u_int)stack + stacksize;
+
sf = (struct switchframe *)tf - 1;
sf->sf_spl = _SPL_0;
sf->sf_r4 = (u_int)child_return;
diff -r 12c86d099d40 -r a4d08ebaee04 sys/arch/atari/atari/vm_machdep.c
--- a/sys/arch/atari/atari/vm_machdep.c Thu May 13 21:46:17 1999 +0000
+++ b/sys/arch/atari/atari/vm_machdep.c Thu May 13 21:58:32 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.23 1999/03/26 23:41:28 mycroft Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.24 1999/05/13 21:58:33 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -73,8 +73,10 @@
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2)
+cpu_fork(p1, p2, stack, stacksize)
register struct proc *p1, *p2;
+ void *stack;
+ size_t stacksize;
{
register struct pcb *pcb = &p2->p_addr->u_pcb;
register struct trapframe *tf;
@@ -101,6 +103,13 @@
tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) - 1;
p2->p_md.md_regs = (int *)tf;
*tf = *(struct trapframe *)p1->p_md.md_regs;
+
+ /*
+ * If specified, give the child a different stack.
+ */
+ if (stack != NULL)
+ tf->tf_regs[15] = (u_int)stack + stacksize;
+
sf = (struct switchframe *)tf - 1;
sf->sf_pc = (u_int)proc_trampoline;
pcb->pcb_regs[6] = (int)child_return; /* A2 */
diff -r 12c86d099d40 -r a4d08ebaee04 sys/arch/hp300/hp300/vm_machdep.c
--- a/sys/arch/hp300/hp300/vm_machdep.c Thu May 13 21:46:17 1999 +0000
+++ b/sys/arch/hp300/hp300/vm_machdep.c Thu May 13 21:58:32 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.47 1999/03/26 23:41:29 mycroft Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.48 1999/05/13 21:58:33 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -72,8 +72,10 @@
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2)
+cpu_fork(p1, p2, stack, stacksize)
struct proc *p1, *p2;
+ void *stack;
+ size_t stacksize;
{
struct pcb *pcb = &p2->p_addr->u_pcb;
struct trapframe *tf;
@@ -100,6 +102,13 @@
tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) - 1;
p2->p_md.md_regs = (int *)tf;
*tf = *(struct trapframe *)p1->p_md.md_regs;
+
+ /*
+ * If specified, give the child a different stack.
+ */
+ if (stack != NULL)
+ tf->tf_regs[15] = (u_int)stack + stacksize;
+
sf = (struct switchframe *)tf - 1;
sf->sf_pc = (u_int)proc_trampoline;
pcb->pcb_regs[6] = (int)child_return; /* A2 */
diff -r 12c86d099d40 -r a4d08ebaee04 sys/arch/i386/i386/vm_machdep.c
--- a/sys/arch/i386/i386/vm_machdep.c Thu May 13 21:46:17 1999 +0000
+++ b/sys/arch/i386/i386/vm_machdep.c Thu May 13 21:58:32 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.77 1999/05/12 19:28:29 thorpej Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.78 1999/05/13 21:58:34 thorpej Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@@ -86,8 +86,10 @@
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2)
+cpu_fork(p1, p2, stack, stacksize)
register struct proc *p1, *p2;
+ void *stack;
+ size_t stacksize;
{
register struct pcb *pcb = &p2->p_addr->u_pcb;
register struct trapframe *tf;
@@ -145,6 +147,13 @@
*/
p2->p_md.md_regs = tf = (struct trapframe *)pcb->pcb_tss.tss_esp0 - 1;
*tf = *p1->p_md.md_regs;
+
+ /*
+ * If specified, give the child a different stack.
+ */
+ if (stack != NULL)
+ tf->tf_esp = (u_int)stack + stacksize;
+
sf = (struct switchframe *)tf - 1;
sf->sf_ppl = 0;
sf->sf_esi = (int)child_return;
diff -r 12c86d099d40 -r a4d08ebaee04 sys/arch/mac68k/mac68k/vm_machdep.c
--- a/sys/arch/mac68k/mac68k/vm_machdep.c Thu May 13 21:46:17 1999 +0000
+++ b/sys/arch/mac68k/mac68k/vm_machdep.c Thu May 13 21:58:32 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.36 1999/04/06 04:04:45 scottr Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.37 1999/05/13 21:58:34 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -72,8 +72,10 @@
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2)
+cpu_fork(p1, p2, stack, stacksize)
struct proc *p1, *p2;
+ void *stack;
+ size_t stacksize;
{
struct pcb *pcb = &p2->p_addr->u_pcb;
struct trapframe *tf;
@@ -100,6 +102,13 @@
tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) - 1;
p2->p_md.md_regs = (int *)tf;
*tf = *(struct trapframe *)p1->p_md.md_regs;
+
+ /*
+ * If specified, give the child a different stack.
+ */
+ if (stack != NULL)
+ tf->tf_regs[15] = (u_int)stack + stacksize;
+
sf = (struct switchframe *)tf - 1;
sf->sf_pc = (u_int)proc_trampoline;
pcb->pcb_regs[6] = (int)child_return; /* A2 */
diff -r 12c86d099d40 -r a4d08ebaee04 sys/arch/mips/mips/vm_machdep.c
--- a/sys/arch/mips/mips/vm_machdep.c Thu May 13 21:46:17 1999 +0000
+++ b/sys/arch/mips/mips/vm_machdep.c Thu May 13 21:58:32 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.35 1999/04/24 08:10:42 simonb Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.36 1999/05/13 21:58:34 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.35 1999/04/24 08:10:42 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.36 1999/05/13 21:58:34 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -74,8 +74,10 @@
* cpu_fork() now returns just once.
*/
void
-cpu_fork(p1, p2)
+cpu_fork(p1, p2, stack, stacksize)
struct proc *p1, *p2;
+ void *stack;
+ size_t stacksize;
{
struct pcb *pcb;
struct frame *f;
@@ -113,6 +115,12 @@
memcpy(f, p1->p_md.md_regs, sizeof(struct frame));
memset(((caddr_t) f) - 24, 0, 24);
+ /*
+ * If specified, give the child a different stack.
+ */
+ if (stack != NULL)
+ f->f_regs[SP] = (u_int)stack + stacksize;
+
p2->p_md.md_regs = (void *)f;
p2->p_md.md_flags = p1->p_md.md_flags & MDP_FPUSED;
x = (CPUISMIPS3) ? (MIPS3_PG_G|MIPS3_PG_RO|MIPS3_PG_WIRED) : MIPS1_PG_G;
diff -r 12c86d099d40 -r a4d08ebaee04 sys/arch/mvme68k/mvme68k/vm_machdep.c
Home |
Main Index |
Thread Index |
Old Index