diff options
author | neel <neel@FreeBSD.org> | 2013-09-20 17:06:49 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2013-09-20 17:06:49 +0000 |
commit | 44c4dbefdb59e719e608d0ee0da3e7edbef93193 (patch) | |
tree | 77174d7c385a60aa52dd285919d35ba0c2cf8fa8 /sys/vm/vm_map.c | |
parent | e0705f6378f45a0a074c7ff0fc6f39e1c2c255a1 (diff) | |
download | FreeBSD-src-44c4dbefdb59e719e608d0ee0da3e7edbef93193.zip FreeBSD-src-44c4dbefdb59e719e608d0ee0da3e7edbef93193.tar.gz |
Merge the following changes from projects/bhyve_npt_pmap:
- add fields to 'struct pmap' that are required to manage nested page tables.
- add a parameter to 'vmspace_alloc()' that can be used to override the
default pmap initialization routine 'pmap_pinit()'.
These changes are pushed ahead of the remaining changes in 'bhyve_npt_pmap'
in anticipation of the upcoming KBI freeze for 10.0.
Reviewed by: kib@, alc@
Approved by: re (glebius)
Diffstat (limited to 'sys/vm/vm_map.c')
-rw-r--r-- | sys/vm/vm_map.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 5990630..45171da 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -280,15 +280,22 @@ vm_map_zdtor(void *mem, int size, void *arg) /* * Allocate a vmspace structure, including a vm_map and pmap, * and initialize those structures. The refcnt is set to 1. + * + * If 'pinit' is NULL then the embedded pmap is initialized via pmap_pinit(). */ struct vmspace * -vmspace_alloc(min, max) - vm_offset_t min, max; +vmspace_alloc(vm_offset_t min, vm_offset_t max, pmap_pinit_t pinit) { struct vmspace *vm; vm = uma_zalloc(vmspace_zone, M_WAITOK); - if (vm->vm_map.pmap == NULL && !pmap_pinit(vmspace_pmap(vm))) { + + KASSERT(vm->vm_map.pmap == NULL, ("vm_map.pmap must be NULL")); + + if (pinit == NULL) + pinit = &pmap_pinit; + + if (!pinit(vmspace_pmap(vm))) { uma_zfree(vmspace_zone, vm); return (NULL); } @@ -3157,7 +3164,7 @@ vmspace_fork(struct vmspace *vm1, vm_ooffset_t *fork_charge) old_map = &vm1->vm_map; /* Copy immutable fields of vm1 to vm2. */ - vm2 = vmspace_alloc(old_map->min_offset, old_map->max_offset); + vm2 = vmspace_alloc(old_map->min_offset, old_map->max_offset, NULL); if (vm2 == NULL) return (NULL); vm2->vm_taddr = vm1->vm_taddr; @@ -3739,7 +3746,7 @@ vmspace_exec(struct proc *p, vm_offset_t minuser, vm_offset_t maxuser) struct vmspace *oldvmspace = p->p_vmspace; struct vmspace *newvmspace; - newvmspace = vmspace_alloc(minuser, maxuser); + newvmspace = vmspace_alloc(minuser, maxuser, NULL); if (newvmspace == NULL) return (ENOMEM); newvmspace->vm_swrss = oldvmspace->vm_swrss; |