summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1999-02-19 19:21:43 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1999-02-19 19:21:43 +0000
commite17845d92e4149a39aab4897917d41e3d4187242 (patch)
tree5fef00de807cdb4b6e3265418ab6a78ddd6c3ec6 /sys
parent99dacef434ebe19354fe6d06d3c29fc66fa6635a (diff)
Allocate the u-area early in fork1 instead of in vm_fork.
Now we can return ENOMEM instead of doing a panic when we run out of memory.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_fork.c17
-rw-r--r--sys/vm/vm_glue.c31
2 files changed, 20 insertions, 28 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 92dade927dd..68a0e497a28 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.13 1999/01/11 20:25:09 niklas Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.14 1999/02/19 19:21:42 art Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -59,6 +59,7 @@
#include <sys/syscallargs.h>
#include <vm/vm.h>
+#include <vm/vm_kern.h>
int nprocs = 1; /* process 0 */
int randompid; /* when set to 1, pid's go random */
@@ -111,6 +112,18 @@ fork1(p1, forktype, rforkflags, retval)
int count;
static int pidchecked = 0;
int dupfd = 1, cleanfd = 0;
+ vm_offset_t uaddr;
+
+ /*
+ * Allocate a pcb and kernel stack for the process
+ */
+#if defined(arc) || defined(mips_cachealias)
+ uaddr = kmem_alloc_upage(kernel_map, USPACE);
+#else
+ uaddr = kmem_alloc_pageable(kernel_map, USPACE);
+#endif
+ if (uaddr == 0)
+ return ENOMEM;
if (forktype == ISRFORK) {
dupfd = 0;
@@ -291,6 +304,8 @@ again:
VM_INHERIT_SHARE);
}
+ p2->p_addr = (struct user *)uaddr;
+
#ifdef __FORK_BRAINDAMAGE
/*
* Set return values for child before vm_fork,
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index a166f4fc06c..f95728f05f8 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_glue.c,v 1.30 1999/02/01 16:29:48 pefo Exp $ */
+/* $OpenBSD: vm_glue.c,v 1.31 1999/02/19 19:21:40 art Exp $ */
/* $NetBSD: vm_glue.c,v 1.55.4.1 1996/06/13 17:25:45 cgd Exp $ */
/*
@@ -214,8 +214,7 @@ void
vm_fork(p1, p2)
register struct proc *p1, *p2;
{
- register struct user *up;
- vm_offset_t addr;
+ register struct user *up = p2->p_addr;
#if defined(i386) || defined(pc532)
/*
@@ -232,30 +231,8 @@ vm_fork(p1, p2)
shmfork(p1, p2);
#endif
-#if !defined(vax)
- /*
- * Allocate a wired-down (for now) pcb and kernel stack for the process
- */
-#if defined(arc) || defined(mips_cachealias)
- addr = kmem_alloc_upage(kernel_map, USPACE);
-#else
- addr = kmem_alloc_pageable(kernel_map, USPACE);
-#endif
- if (addr == 0)
- panic("vm_fork: no more kernel virtual memory");
- vm_map_pageable(kernel_map, addr, addr + USPACE, FALSE);
-#else
- /*
- * XXX somehow, on 386, ocassionally pageout removes active, wired down
- * kstack and pagetables, WITHOUT going thru vm_page_unwire! Why this
- * appears to work is not yet clear, yet it does...
- */
- addr = kmem_alloc(kernel_map, USPACE);
- if (addr == 0)
- panic("vm_fork: no more kernel virtual memory");
-#endif
- up = (struct user *)addr;
- p2->p_addr = up;
+ vm_map_pageable(kernel_map, (vm_offset_t)up,
+ (vm_offset_t)up + USPACE, FALSE);
/*
* p_stats and p_sigacts currently point at fields