summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-05-03 22:44:37 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-05-03 22:44:37 +0000
commitd80bf4667612fc0e31782d418d0c426f1db79461 (patch)
tree7b43a6f6b8dbb3c5753055385d5b9de7db59a7ac
parent6a5a09fe5abb7c3f12aae4466dcc7a714afed7b1 (diff)
Move the u-area allocation and pmap-magic logic to its own function
uvm_uarea_alloc() function name from NetBSD; arm testing by miod@
-rw-r--r--sys/kern/kern_fork.c7
-rw-r--r--sys/uvm/uvm_extern.h3
-rw-r--r--sys/uvm/uvm_glue.c31
3 files changed, 27 insertions, 14 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index bad4221d5d5..da052e891ff 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.163 2014/04/18 11:51:17 guenther Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.164 2014/05/03 22:44:36 guenther Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -287,10 +287,7 @@ fork1(struct proc *curp, int flags, void *stack, pid_t *tidptr,
}
}
- uaddr = uvm_km_kmemalloc_pla(kernel_map, uvm.kernel_object, USPACE,
- USPACE_ALIGN, UVM_KMF_ZERO,
- no_constraint.ucr_low, no_constraint.ucr_high,
- 0, 0, USPACE/PAGE_SIZE);
+ uaddr = uvm_uarea_alloc();
if (uaddr == 0) {
if ((flags & FORK_THREAD) == 0) {
(void)chgproccnt(uid, -1);
diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h
index 06919d70979..d6eae9c297f 100644
--- a/sys/uvm/uvm_extern.h
+++ b/sys/uvm/uvm_extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_extern.h,v 1.112 2014/04/03 21:40:10 tedu Exp $ */
+/* $OpenBSD: uvm_extern.h,v 1.113 2014/05/03 22:44:36 guenther Exp $ */
/* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */
/*
@@ -513,6 +513,7 @@ int uvm_fault(vm_map_t, vaddr_t,
#if defined(KGDB)
void uvm_chgkprot(caddr_t, size_t, int);
#endif
+vaddr_t uvm_uarea_alloc(void);
void uvm_fork(struct proc *, struct proc *, boolean_t,
void *, size_t, void (*)(void *), void *);
void uvm_exit(struct proc *);
diff --git a/sys/uvm/uvm_glue.c b/sys/uvm/uvm_glue.c
index ffb283f22c1..324794c09e3 100644
--- a/sys/uvm/uvm_glue.c
+++ b/sys/uvm/uvm_glue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_glue.c,v 1.62 2014/04/13 23:14:15 tedu Exp $ */
+/* $OpenBSD: uvm_glue.c,v 1.63 2014/05/03 22:44:36 guenther Exp $ */
/* $NetBSD: uvm_glue.c,v 1.44 2001/02/06 19:54:44 eeh Exp $ */
/*
@@ -294,11 +294,31 @@ uvm_vsunlock_device(struct proc *p, void *addr, size_t len, void *map)
}
/*
+ * uvm_uarea_alloc: allocate the u-area for a new thread
+ */
+vaddr_t
+uvm_uarea_alloc(void)
+{
+ vaddr_t uaddr;
+
+ uaddr = uvm_km_kmemalloc_pla(kernel_map, uvm.kernel_object, USPACE,
+ USPACE_ALIGN, UVM_KMF_ZERO,
+ no_constraint.ucr_low, no_constraint.ucr_high,
+ 0, 0, USPACE/PAGE_SIZE);
+
+#ifdef PMAP_UAREA
+ /* Tell the pmap this is a u-area mapping */
+ if (uaddr != 0)
+ PMAP_UAREA(uaddr);
+#endif
+
+ return (uaddr);
+}
+
+/*
* uvm_fork: fork a virtual address space
*
* - the address space is copied as per parent map's inherit values
- * - a new "user" structure is allocated for the child process
- * [filled in by MD layer...]
* - if specified, the child gets a new user stack described by
* stack and stacksize
* - NOTE: the kernel stack may be at a different location in the child
@@ -318,11 +338,6 @@ uvm_fork(struct proc *p1, struct proc *p2, boolean_t shared, void *stack,
} else
p2->p_vmspace = uvmspace_fork(p1->p_vmspace); /* fork vmspace */
-#ifdef PMAP_UAREA
- /* Tell the pmap this is a u-area mapping */
- PMAP_UAREA((vaddr_t)p2->p_addr);
-#endif
-
/*
* cpu_fork() copy and update the pcb, and make the child ready
* to run. If this is a normal user fork, the child will exit