diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-11-06 18:41:11 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-11-06 18:41:11 +0000 |
commit | 89ae7820c1a454d61cd281925d300bf324cfb4a3 (patch) | |
tree | 322119c116dc2ae1a396e832aac803b47d2df136 /sys/arch/i386 | |
parent | 1c0a1a534d87ced0c6089cb972b59491152bbdfa (diff) |
Let fork1, uvm_fork, and cpu_fork take a function/argument pair as argument,
instead of doing fork1, cpu_set_kpc. This lets us retire cpu_set_kpc and
avoid a multiprocessor race.
This commit breaks vax because it doesn't look like any other arch, someone
working on vax might want to look at this and try to adapt the code to be
more like the rest of the world.
Idea and uvm parts from NetBSD.
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/trap.c | 15 | ||||
-rw-r--r-- | sys/arch/i386/i386/vm_machdep.c | 34 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 5 |
3 files changed, 20 insertions, 34 deletions
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index 4e40a39aae1..892ce2bb758 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.43 2001/09/20 11:57:18 art Exp $ */ +/* $OpenBSD: trap.c,v 1.44 2001/11/06 18:41:09 art Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -753,15 +753,16 @@ syscall(frame) } void -child_return(p, frame) - struct proc *p; - struct trapframe frame; +child_return(arg) + void *arg; { + struct proc *p = (struct proc *)arg; + struct trapframe *tf = p->p_md.md_regs; - frame.tf_eax = 0; - frame.tf_eflags &= ~PSL_C; + tf->tf_eax = 0; + tf->tf_eflags &= ~PSL_C; - userret(p, frame.tf_eip, 0); + userret(p, tf->tf_eip, 0); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, SYS_fork, 0, 0); diff --git a/sys/arch/i386/i386/vm_machdep.c b/sys/arch/i386/i386/vm_machdep.c index aa62e5497ea..1f9bbce2f03 100644 --- a/sys/arch/i386/i386/vm_machdep.c +++ b/sys/arch/i386/i386/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.30 2001/09/21 02:11:57 miod Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.31 2001/11/06 18:41:09 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.61 1996/05/03 19:42:35 christos Exp $ */ /*- @@ -83,14 +83,16 @@ void setredzone __P((u_short *, caddr_t)); * the frame pointers on the stack after copying. */ void -cpu_fork(p1, p2, stack, stacksize) - register struct proc *p1, *p2; +cpu_fork(p1, p2, stack, stacksize, func, arg) + struct proc *p1, *p2; void *stack; size_t stacksize; + void (*func)(void *); + void *arg; { - register struct pcb *pcb = &p2->p_addr->u_pcb; - register struct trapframe *tf; - register struct switchframe *sf; + struct pcb *pcb = &p2->p_addr->u_pcb; + struct trapframe *tf; + struct switchframe *sf; #if NNPX > 0 /* @@ -127,7 +129,7 @@ cpu_fork(p1, p2, stack, stacksize) /* * Copy the trapframe, and arrange for the child to return directly - * through rei(). Note the inline version of cpu_set_kpc(). + * through rei(). */ p2->p_md.md_regs = tf = (struct trapframe *)pcb->pcb_tss.tss_esp0 - 1; *tf = *p1->p_md.md_regs; @@ -140,24 +142,10 @@ cpu_fork(p1, p2, stack, stacksize) sf = (struct switchframe *)tf - 1; sf->sf_ppl = 0; - sf->sf_esi = (int)child_return; - sf->sf_ebx = (int)p2; - sf->sf_eip = (int)proc_trampoline; - pcb->pcb_esp = (int)sf; -} - -void -cpu_set_kpc(p, pc, arg) - struct proc *p; - void (*pc) __P((void *)); - void *arg; -{ - struct switchframe *sf = - (struct switchframe *)p->p_addr->u_pcb.pcb_esp; - - sf->sf_esi = (int)pc; + sf->sf_esi = (int)func; sf->sf_ebx = (int)arg; sf->sf_eip = (int)proc_trampoline; + pcb->pcb_esp = (int)sf; } void diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 58b1a6d7e6d..60c38f6892d 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.38 2001/07/13 19:55:41 deraadt Exp $ */ +/* $OpenBSD: cpu.h,v 1.39 2001/11/06 18:41:09 art Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -230,9 +230,6 @@ int kvtop __P((caddr_t)); void vm86_gpfault __P((struct proc *, int)); #endif /* VM86 */ -/* trap.c */ -void child_return __P((struct proc *, struct trapframe)); - #ifdef GENERIC /* swapgeneric.c */ void setconf __P((void)); |