-/* $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 $ */
/*
}
}
- 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);
-/* $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 $ */
/*
#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 *);
-/* $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 $ */
/*
uvm_km_free(kernel_map, kva, sz);
}
+/*
+ * 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
} 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