Move flag(s) representing the type of vm_map_entry into its own vm_maptype_t
authorMatthew Dillon <dillon@dragonflybsd.org>
Mon, 11 Sep 2006 20:25:31 +0000 (20:25 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Mon, 11 Sep 2006 20:25:31 +0000 (20:25 +0000)
type.  This is a precursor to adding a new VM mapping type for virtualized
page tables.

24 files changed:
sys/emulation/linux/i386/imgact_linux.c
sys/emulation/linux/linux_misc.c
sys/kern/imgact_aout.c
sys/kern/imgact_elf.c
sys/kern/imgact_gzip.c
sys/kern/init_main.c
sys/kern/kern_slaballoc.c
sys/kern/link_elf.c
sys/kern/sys_pipe.c
sys/kern/sys_process.c
sys/kern/sysv_shm.c
sys/kern/vfs_bio.c
sys/vfs/procfs/procfs_map.c
sys/vm/vm.h
sys/vm/vm_contig.c
sys/vm/vm_kern.c
sys/vm/vm_map.c
sys/vm/vm_map.h
sys/vm/vm_meter.c
sys/vm/vm_mmap.c
sys/vm/vm_object.c
sys/vm/vm_pageout.c
sys/vm/vm_unix.c
usr.bin/fstat/fstat.c

index d797a93..96cc10f 100644 (file)
@@ -29,7 +29,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/linux/imgact_linux.c,v 1.35.2.2 2001/11/03 01:41:08 ps Exp $
- * $DragonFly: src/sys/emulation/linux/i386/imgact_linux.c,v 1.7 2005/12/10 16:06:20 swildner Exp $
+ * $DragonFly: src/sys/emulation/linux/i386/imgact_linux.c,v 1.8 2006/09/11 20:25:00 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -129,6 +129,7 @@ exec_linux_imgact(struct image_params *imgp)
        vmaddr = virtual_offset;
        error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr,
                            a_out->a_text + a_out->a_data + bss_size, FALSE,
+                           VM_MAPTYPE_NORMAL,
                            VM_PROT_ALL, VM_PROT_ALL, 0);
        if (error)
            return error;
@@ -198,7 +199,10 @@ exec_linux_imgact(struct image_params *imgp)
        if (bss_size != 0) {
            vmaddr = virtual_offset + a_out->a_text + a_out->a_data;
            error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr, 
-                               bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
+                               bss_size, FALSE,
+                               VM_MAPTYPE_NORMAL,
+                               VM_PROT_ALL, VM_PROT_ALL,
+                               0);
            if (error)
                return (error);
 #ifdef DEBUG
index 39a34b1..6282b6e 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/compat/linux/linux_misc.c,v 1.85.2.9 2002/09/24 08:11:41 mdodd Exp $
- * $DragonFly: src/sys/emulation/linux/linux_misc.c,v 1.29 2006/08/12 00:26:19 dillon Exp $
+ * $DragonFly: src/sys/emulation/linux/linux_misc.c,v 1.30 2006/09/11 20:24:59 dillon Exp $
  */
 
 #include "opt_compat.h"
@@ -384,8 +384,11 @@ sys_linux_uselib(struct linux_uselib_args *args)
 
                /* get anon user mapping, read+write+execute */
                error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0,
-                   &vmaddr, a_out->a_text + a_out->a_data, FALSE, VM_PROT_ALL,
-                   VM_PROT_ALL, 0);
+                                   &vmaddr, a_out->a_text + a_out->a_data,
+                                   FALSE,
+                                   VM_MAPTYPE_NORMAL,
+                                   VM_PROT_ALL, VM_PROT_ALL,
+                                   0);
                if (error)
                        goto cleanup;
 
@@ -438,7 +441,11 @@ sys_linux_uselib(struct linux_uselib_args *args)
 
                /* allocate some 'anon' space */
                error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0,
-                   &vmaddr, bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
+                                   &vmaddr, bss_size,
+                                   FALSE,
+                                   VM_MAPTYPE_NORMAL,
+                                   VM_PROT_ALL, VM_PROT_ALL,
+                                   0);
                if (error)
                        goto cleanup;
        }
index c76a7ee..a1ce25e 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/kern/imgact_aout.c,v 1.59.2.5 2001/11/03 01:41:08 ps Exp $
- * $DragonFly: src/sys/kern/imgact_aout.c,v 1.11 2006/05/06 02:43:12 dillon Exp $
+ * $DragonFly: src/sys/kern/imgact_aout.c,v 1.12 2006/09/11 20:25:01 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -186,6 +186,7 @@ exec_aout_imgact(struct image_params *imgp)
        error = vm_map_insert(map, &count, object,
                file_offset,
                virtual_offset, text_end,
+               VM_MAPTYPE_NORMAL,
                VM_PROT_READ | VM_PROT_EXECUTE, VM_PROT_ALL,
                MAP_COPY_ON_WRITE | MAP_PREFAULT);
        if (error) {
@@ -199,6 +200,7 @@ exec_aout_imgact(struct image_params *imgp)
                error = vm_map_insert(map, &count, object,
                        file_offset + a_out->a_text,
                        text_end, data_end,
+                       VM_MAPTYPE_NORMAL,
                        VM_PROT_ALL, VM_PROT_ALL,
                        MAP_COPY_ON_WRITE | MAP_PREFAULT);
                if (error) {
@@ -211,7 +213,9 @@ exec_aout_imgact(struct image_params *imgp)
        if (bss_size) {
                error = vm_map_insert(map, &count, NULL, 0,
                        data_end, data_end + bss_size,
-                       VM_PROT_ALL, VM_PROT_ALL, 0);
+                       VM_MAPTYPE_NORMAL,
+                       VM_PROT_ALL, VM_PROT_ALL,
+                       0);
                if (error) {
                        vm_map_unlock(map);
                        vm_map_entry_release(count);
index 961b24b..05d70b4 100644 (file)
@@ -27,7 +27,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/kern/imgact_elf.c,v 1.73.2.13 2002/12/28 19:49:41 dillon Exp $
- * $DragonFly: src/sys/kern/imgact_elf.c,v 1.41 2006/09/05 00:55:45 dillon Exp $
+ * $DragonFly: src/sys/kern/imgact_elf.c,v 1.42 2006/09/11 20:25:01 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -307,8 +307,8 @@ elf_load_section(struct proc *p, struct vmspace *vmspace, struct vnode *vp,
                                      file_addr,        /* file offset */
                                      map_addr,         /* virtual start */
                                      map_addr + map_len,/* virtual end */
-                                     prot,
-                                     VM_PROT_ALL,
+                                     VM_MAPTYPE_NORMAL,
+                                     prot, VM_PROT_ALL,
                                      cow);
                vm_map_unlock(&vmspace->vm_map);
                vm_map_entry_release(count);
@@ -341,7 +341,9 @@ elf_load_section(struct proc *p, struct vmspace *vmspace, struct vnode *vp,
                rv = vm_map_insert(&vmspace->vm_map, &count,
                                        NULL, 0,
                                        map_addr, map_addr + map_len,
-                                       VM_PROT_ALL, VM_PROT_ALL, 0);
+                                       VM_MAPTYPE_NORMAL,
+                                       VM_PROT_ALL, VM_PROT_ALL,
+                                       0);
                vm_map_unlock(&vmspace->vm_map);
                vm_map_entry_release(count);
                if (rv != KERN_SUCCESS) {
@@ -357,8 +359,8 @@ elf_load_section(struct proc *p, struct vmspace *vmspace, struct vnode *vp,
                                 &data_buf,
                                 PAGE_SIZE,
                                 TRUE,
-                                VM_PROT_READ,
-                                VM_PROT_ALL,
+                                VM_MAPTYPE_NORMAL,
+                                VM_PROT_READ, VM_PROT_ALL,
                                 MAP_COPY_ON_WRITE | MAP_PREFAULT_PARTIAL);
                if (rv != KERN_SUCCESS) {
                        vm_object_deallocate(object);
@@ -1173,12 +1175,15 @@ each_segment(struct proc *p, segment_callback func, void *closure, int writable)
                /*
                 * Dont include memory segment in the coredump if
                 * MAP_NOCORE is set in mmap(2) or MADV_NOCORE in
-                * madvise(2).  Do not dump submaps (i.e. parts of the
-                * kernel map).
+                * madvise(2).
+                *
+                * Currently we only dump normal VM object maps.  We do
+                * not dump submaps or virtual page tables.
                 */
-               if (writable && entry->eflags & (MAP_ENTRY_NOCOREDUMP|MAP_ENTRY_IS_SUB_MAP))
+               if (writable && (entry->eflags & MAP_ENTRY_NOCOREDUMP))
+                       continue;
+               if (entry->maptype != VM_MAPTYPE_NORMAL)
                        continue;
-
                if ((obj = entry->object.vm_object) == NULL)
                        continue;
 
index f48bd46..7e9efbc 100644 (file)
@@ -7,7 +7,7 @@
  * ----------------------------------------------------------------------------
  *
  * $FreeBSD: src/sys/kern/imgact_gzip.c,v 1.40.2.1 2001/11/03 01:41:08 ps Exp $
- * $DragonFly: src/sys/kern/imgact_gzip.c,v 1.5 2004/01/20 18:41:51 dillon Exp $
+ * $DragonFly: src/sys/kern/imgact_gzip.c,v 1.6 2006/09/11 20:25:01 dillon Exp $
  *
  * This module handles execution of a.out files which have been run through
  * "gzip".  This saves diskspace, but wastes cpu-cycles and VM.
@@ -249,11 +249,12 @@ do_aout_hdr(struct imgact_gzip * gz)
                vmaddr = gz->virtual_offset + gz->a_out.a_text + 
                        gz->a_out.a_data;
                error = vm_map_find(&vmspace->vm_map,
-                               NULL,
-                               0,
-                               &vmaddr, 
-                               gz->bss_size,
-                               FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
+                                   NULL, 0,
+                                   &vmaddr, gz->bss_size,
+                                   FALSE,
+                                   VM_MAPTYPE_NORMAL,
+                                   VM_PROT_ALL, VM_PROT_ALL,
+                                   0);
                if (error) {
                        gz->where = __LINE__;
                        return (error);
index 011eb9a..ba72e35 100644 (file)
@@ -40,7 +40,7 @@
  *
  *     @(#)init_main.c 8.9 (Berkeley) 1/21/94
  * $FreeBSD: src/sys/kern/init_main.c,v 1.134.2.8 2003/06/06 20:21:32 tegge Exp $
- * $DragonFly: src/sys/kern/init_main.c,v 1.62 2006/09/05 00:55:45 dillon Exp $
+ * $DragonFly: src/sys/kern/init_main.c,v 1.63 2006/09/11 20:25:01 dillon Exp $
  */
 
 #include "opt_init_path.h"
@@ -469,8 +469,12 @@ start_init(void *dummy)
         * Need just enough stack to hold the faked-up "execve()" arguments.
         */
        addr = trunc_page(USRSTACK - PAGE_SIZE);
-       if (vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &addr, PAGE_SIZE,
-                       FALSE, VM_PROT_ALL, VM_PROT_ALL, 0) != 0)
+       error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &addr, PAGE_SIZE,
+                           FALSE, 
+                           VM_MAPTYPE_NORMAL,
+                           VM_PROT_ALL, VM_PROT_ALL,
+                           0);
+       if (error)
                panic("init: couldn't allocate argument space");
        p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
        p->p_vmspace->vm_ssize = 1;
index 043fc0f..d48726f 100644 (file)
@@ -33,7 +33,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/kern/kern_slaballoc.c,v 1.42 2006/09/05 15:38:26 dillon Exp $
+ * $DragonFly: src/sys/kern/kern_slaballoc.c,v 1.43 2006/09/11 20:25:01 dillon Exp $
  *
  * This module implements a slab allocator drop-in replacement for the
  * kernel malloc().
@@ -1068,7 +1068,9 @@ kmem_slab_alloc(vm_size_t size, vm_offset_t align, int flags)
     vm_object_reference(kernel_object);
     vm_map_insert(map, &count, 
                    kernel_object, offset, addr, addr + size,
-                   VM_PROT_ALL, VM_PROT_ALL, 0);
+                   VM_MAPTYPE_NORMAL,
+                   VM_PROT_ALL, VM_PROT_ALL,
+                   0);
 
     td = curthread;
 
index b3ab82e..b98a9a1 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/kern/link_elf.c,v 1.24 1999/12/24 15:33:36 bde Exp $
- * $DragonFly: src/sys/kern/link_elf.c,v 1.21 2006/09/05 00:55:45 dillon Exp $
+ * $DragonFly: src/sys/kern/link_elf.c,v 1.22 2006/09/11 20:25:01 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -556,9 +556,11 @@ link_elf_load_file(const char* filename, linker_file_t* result)
     vm_object_reference(ef->object);
     ef->address = (caddr_t) vm_map_min(kernel_map);
     error = vm_map_find(kernel_map, ef->object, 0,
-                       (vm_offset_t *) &ef->address,
-                       mapsize, 1,
-                       VM_PROT_ALL, VM_PROT_ALL, 0);
+                       (vm_offset_t *)&ef->address, mapsize,
+                       1,
+                       VM_MAPTYPE_NORMAL,
+                       VM_PROT_ALL, VM_PROT_ALL,
+                       0);
     if (error) {
        vm_object_deallocate(ef->object);
        kfree(ef, M_LINKER);
index 28ed88d..dba2cbb 100644 (file)
@@ -17,7 +17,7 @@
  *    are met.
  *
  * $FreeBSD: src/sys/kern/sys_pipe.c,v 1.60.2.13 2002/08/05 15:05:15 des Exp $
- * $DragonFly: src/sys/kern/sys_pipe.c,v 1.41 2006/09/05 00:55:45 dillon Exp $
+ * $DragonFly: src/sys/kern/sys_pipe.c,v 1.42 2006/09/11 20:25:01 dillon Exp $
  */
 
 /*
@@ -318,8 +318,11 @@ pipespace(struct pipe *cpipe, int size)
                buffer = (caddr_t) vm_map_min(kernel_map);
 
                error = vm_map_find(kernel_map, object, 0,
-                       (vm_offset_t *) &buffer, size, 1,
-                       VM_PROT_ALL, VM_PROT_ALL, 0);
+                                   (vm_offset_t *)&buffer, size,
+                                   1,
+                                   VM_MAPTYPE_NORMAL,
+                                   VM_PROT_ALL, VM_PROT_ALL,
+                                   0);
 
                if (error != KERN_SUCCESS) {
                        vm_object_deallocate(object);
index cdd20be..359205b 100644 (file)
@@ -29,7 +29,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/kern/sys_process.c,v 1.51.2.6 2003/01/08 03:06:45 kan Exp $
- * $DragonFly: src/sys/kern/sys_process.c,v 1.21 2006/09/03 18:29:16 dillon Exp $
+ * $DragonFly: src/sys/kern/sys_process.c,v 1.22 2006/09/11 20:25:01 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -83,7 +83,11 @@ pread (struct proc *procp, unsigned int addr, unsigned int *retval) {
 
        /* Find space in kernel_map for the page we're interested in */
        rv = vm_map_find (kernel_map, object, IDX_TO_OFF(pindex),
-               &kva, PAGE_SIZE, 0, VM_PROT_ALL, VM_PROT_ALL, 0);
+                         &kva, PAGE_SIZE, 
+                         0, 
+                         VM_MAPTYPE_NORMAL,
+                         VM_PROT_ALL, VM_PROT_ALL,
+                         0);
 
        if (!rv) {
                vm_object_reference (object);
@@ -169,8 +173,11 @@ pwrite (struct proc *procp, unsigned int addr, unsigned int datum) {
 
        /* Find space in kernel_map for the page we're interested in */
        rv = vm_map_find (kernel_map, object, IDX_TO_OFF(pindex),
-               &kva, PAGE_SIZE, 0,
-               VM_PROT_ALL, VM_PROT_ALL, 0);
+                         &kva, PAGE_SIZE,
+                         0,
+                         VM_MAPTYPE_NORMAL,
+                         VM_PROT_ALL, VM_PROT_ALL,
+                         0);
        if (!rv) {
                vm_object_reference (object);
 
index cd0d317..232118c 100644 (file)
@@ -1,5 +1,5 @@
 /* $FreeBSD: src/sys/kern/sysv_shm.c,v 1.45.2.6 2002/10/22 20:45:03 fjoe Exp $ */
-/* $DragonFly: src/sys/kern/sysv_shm.c,v 1.18 2006/09/05 00:55:45 dillon Exp $ */
+/* $DragonFly: src/sys/kern/sysv_shm.c,v 1.19 2006/09/11 20:25:01 dillon Exp $ */
 /*     $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $      */
 
 /*
@@ -297,8 +297,13 @@ sys_shmat(struct shmat_args *uap)
 
        shm_handle = shmseg->shm_internal;
        vm_object_reference(shm_handle->shm_object);
-       rv = vm_map_find(&p->p_vmspace->vm_map, shm_handle->shm_object,
-               0, &attach_va, size, (flags & MAP_FIXED)?0:1, prot, prot, 0);
+       rv = vm_map_find(&p->p_vmspace->vm_map, 
+                        shm_handle->shm_object, 0,
+                        &attach_va, size,
+                        ((flags & MAP_FIXED) ? 0 : 1), 
+                        VM_MAPTYPE_NORMAL,
+                        prot, prot,
+                        0);
        if (rv != KERN_SUCCESS) {
                 vm_object_deallocate(shm_handle->shm_object);
                return ENOMEM;
index 5341eed..3915263 100644 (file)
@@ -12,7 +12,7 @@
  *             John S. Dyson.
  *
  * $FreeBSD: src/sys/kern/vfs_bio.c,v 1.242.2.20 2003/05/28 18:38:10 alc Exp $
- * $DragonFly: src/sys/kern/vfs_bio.c,v 1.79 2006/09/05 00:55:45 dillon Exp $
+ * $DragonFly: src/sys/kern/vfs_bio.c,v 1.80 2006/09/11 20:25:01 dillon Exp $
  */
 
 /*
@@ -1812,7 +1812,9 @@ restart:
                                vm_map_insert(buffer_map, &count,
                                        NULL, 0,
                                        addr, addr + maxsize,
-                                       VM_PROT_ALL, VM_PROT_ALL, MAP_NOFAULT);
+                                       VM_MAPTYPE_NORMAL,
+                                       VM_PROT_ALL, VM_PROT_ALL,
+                                       MAP_NOFAULT);
 
                                bp->b_kvabase = (caddr_t) addr;
                                bp->b_kvasize = maxsize;
index 91bfe3c..9caa199 100644 (file)
@@ -37,7 +37,7 @@
  *     @(#)procfs_status.c     8.3 (Berkeley) 2/17/94
  *
  * $FreeBSD: src/sys/miscfs/procfs/procfs_map.c,v 1.24.2.1 2001/08/04 13:12:24 rwatson Exp $
- * $DragonFly: src/sys/vfs/procfs/procfs_map.c,v 1.4 2004/05/02 03:05:11 cpressey Exp $
+ * $DragonFly: src/sys/vfs/procfs/procfs_map.c,v 1.5 2006/09/11 20:25:01 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -95,8 +95,10 @@ procfs_domap(struct proc *curp, struct proc *p, struct pfsnode *pfs,
                int resident, privateresident;
                char *type;
 
-               if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
+               if (entry->maptype != VM_MAPTYPE_NORMAL &&
+                   entry->maptype != VM_MAPTYPE_VPAGETABLE) {
                        continue;
+               }
 
                obj = entry->object.vm_object;
                if (obj && (obj->shadow_count == 1))
index aad9fe2..67c2442 100644 (file)
@@ -60,7 +60,7 @@
  * rights to redistribute these changes.
  *
  * $FreeBSD: src/sys/vm/vm.h,v 1.16.2.1 2002/12/28 19:49:41 dillon Exp $
- * $DragonFly: src/sys/vm/vm.h,v 1.6 2006/05/21 03:43:47 dillon Exp $
+ * $DragonFly: src/sys/vm/vm.h,v 1.7 2006/09/11 20:25:31 dillon Exp $
  */
 
 #ifndef VM_VM_H_
@@ -89,6 +89,13 @@ typedef u_char vm_prot_t;    /* protection codes */
 #define        VM_PROT_ALL             (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
 #define        VM_PROT_DEFAULT         VM_PROT_ALL
 
+typedef u_char vm_maptype_t;   /* type of vm_map_entry */
+
+#define VM_MAPTYPE_UNSPECIFIED 0
+#define VM_MAPTYPE_NORMAL      1
+#define VM_MAPTYPE_VPAGETABLE  2
+#define VM_MAPTYPE_SUBMAP      3
+
 union vm_map_object;
 typedef union vm_map_object vm_map_object_t;
 
index d4b0e4f..0c75a2c 100644 (file)
@@ -64,7 +64,7 @@
  * SUCH DAMAGE.
  *
  *     from: @(#)vm_page.c     7.4 (Berkeley) 5/7/91
- * $DragonFly: src/sys/vm/vm_contig.c,v 1.17 2006/08/12 00:26:22 dillon Exp $
+ * $DragonFly: src/sys/vm/vm_contig.c,v 1.18 2006/09/11 20:25:31 dillon Exp $
  */
 
 /*
@@ -417,8 +417,11 @@ vm_contig_pg_kmap(int start, u_long size, vm_map_t map, int flags)
        }
        vm_object_reference(kernel_object);
        vm_map_insert(map, &count, 
-           kernel_object, addr - VM_MIN_KERNEL_ADDRESS,
-           addr, addr + size, VM_PROT_ALL, VM_PROT_ALL, 0);
+                     kernel_object, addr - VM_MIN_KERNEL_ADDRESS,
+                     addr, addr + size,
+                     VM_MAPTYPE_NORMAL,
+                     VM_PROT_ALL, VM_PROT_ALL,
+                     0);
        vm_map_unlock(map);
        vm_map_entry_release(count);
 
index 1f09b03..536ba5b 100644 (file)
@@ -62,7 +62,7 @@
  * rights to redistribute these changes.
  *
  * $FreeBSD: src/sys/vm/vm_kern.c,v 1.61.2.2 2002/03/12 18:25:26 tegge Exp $
- * $DragonFly: src/sys/vm/vm_kern.c,v 1.22 2006/01/13 20:45:30 swildner Exp $
+ * $DragonFly: src/sys/vm/vm_kern.c,v 1.23 2006/09/11 20:25:31 dillon Exp $
  */
 
 /*
@@ -105,7 +105,11 @@ kmem_alloc_pageable(vm_map_t map, vm_size_t size)
        size = round_page(size);
        addr = vm_map_min(map);
        result = vm_map_find(map, NULL, (vm_offset_t) 0,
-           &addr, size, TRUE, VM_PROT_ALL, VM_PROT_ALL, 0);
+                            &addr, size,
+                            TRUE, 
+                            VM_MAPTYPE_NORMAL,
+                            VM_PROT_ALL, VM_PROT_ALL,
+                            0);
        if (result != KERN_SUCCESS) {
                return (0);
        }
@@ -126,7 +130,11 @@ kmem_alloc_nofault(vm_map_t map, vm_size_t size)
        size = round_page(size);
        addr = vm_map_min(map);
        result = vm_map_find(map, NULL, (vm_offset_t) 0,
-           &addr, size, TRUE, VM_PROT_ALL, VM_PROT_ALL, MAP_NOFAULT);
+                            &addr, size,
+                            TRUE,
+                            VM_MAPTYPE_NORMAL,
+                            VM_PROT_ALL, VM_PROT_ALL,
+                            MAP_NOFAULT);
        if (result != KERN_SUCCESS) {
                return (0);
        }
@@ -172,8 +180,10 @@ kmem_alloc3(vm_map_t map, vm_size_t size, int kmflags)
        offset = addr - VM_MIN_KERNEL_ADDRESS;
        vm_object_reference(kernel_object);
        vm_map_insert(map, &count,
-               kernel_object, offset, addr, addr + size,
-               VM_PROT_ALL, VM_PROT_ALL, 0);
+                     kernel_object, offset, addr, addr + size,
+                     VM_MAPTYPE_NORMAL,
+                     VM_PROT_ALL, VM_PROT_ALL,
+                     0);
        vm_map_unlock(map);
        if (kmflags & KM_KRESERVE)
                vm_map_entry_krelease(count);
@@ -258,7 +268,11 @@ kmem_suballoc(vm_map_t parent, vm_offset_t *min, vm_offset_t *max,
 
        *min = (vm_offset_t) vm_map_min(parent);
        ret = vm_map_find(parent, NULL, (vm_offset_t) 0,
-           min, size, TRUE, VM_PROT_ALL, VM_PROT_ALL, 0);
+                         min, size,
+                         TRUE,
+                         VM_MAPTYPE_UNSPECIFIED,
+                         VM_PROT_ALL, VM_PROT_ALL,
+                         0);
        if (ret != KERN_SUCCESS) {
                printf("kmem_suballoc: bad status return of %d.\n", ret);
                panic("kmem_suballoc");
@@ -324,8 +338,10 @@ kmem_malloc(vm_map_t map, vm_size_t size, int flags)
        offset = addr - VM_MIN_KERNEL_ADDRESS;
        vm_object_reference(kmem_object);
        vm_map_insert(map, &count,
-               kmem_object, offset, addr, addr + size,
-               VM_PROT_ALL, VM_PROT_ALL, 0);
+                     kmem_object, offset, addr, addr + size,
+                     VM_MAPTYPE_NORMAL,
+                     VM_PROT_ALL, VM_PROT_ALL,
+                     0);
 
        td = curthread;
        wanted_reserve = 0;
@@ -467,8 +483,11 @@ kmem_alloc_wait(vm_map_t map, vm_size_t size)
                tsleep(map, 0, "kmaw", 0);
        }
        vm_map_insert(map, &count,
-                   NULL, (vm_offset_t) 0,
-                   addr, addr + size, VM_PROT_ALL, VM_PROT_ALL, 0);
+                     NULL, (vm_offset_t) 0,
+                     addr, addr + size,
+                     VM_MAPTYPE_NORMAL,
+                     VM_PROT_ALL, VM_PROT_ALL,
+                     0);
        vm_map_unlock(map);
        vm_map_entry_release(count);
        return (addr);
@@ -516,7 +535,10 @@ kmem_init(vm_offset_t start, vm_offset_t end)
        kernel_map->system_map = 1;
        count = vm_map_entry_reserve(MAP_RESERVE_COUNT);
        vm_map_insert(m, &count, NULL, (vm_offset_t) 0,
-           VM_MIN_KERNEL_ADDRESS, start, VM_PROT_ALL, VM_PROT_ALL, 0);
+                     VM_MIN_KERNEL_ADDRESS, start,
+                     VM_MAPTYPE_NORMAL,
+                     VM_PROT_ALL, VM_PROT_ALL,
+                     0);
        /* ... and ending with the completion of the above `insert' */
        vm_map_unlock(m);
        vm_map_entry_release(count);
index 79ca1ec..d4c13f1 100644 (file)
@@ -62,7 +62,7 @@
  * rights to redistribute these changes.
  *
  * $FreeBSD: src/sys/vm/vm_map.c,v 1.187.2.19 2003/05/27 00:47:02 alc Exp $
- * $DragonFly: src/sys/vm/vm_map.c,v 1.46 2006/08/12 00:26:22 dillon Exp $
+ * $DragonFly: src/sys/vm/vm_map.c,v 1.47 2006/09/11 20:25:31 dillon Exp $
  */
 
 /*
@@ -290,21 +290,26 @@ vmspace_swap_count(struct vmspace *vmspace)
 {
        vm_map_t map = &vmspace->vm_map;
        vm_map_entry_t cur;
+       vm_object_t object;
        int count = 0;
+       int n;
 
        for (cur = map->header.next; cur != &map->header; cur = cur->next) {
-               vm_object_t object;
-
-               if ((cur->eflags & MAP_ENTRY_IS_SUB_MAP) == 0 &&
-                   (object = cur->object.vm_object) != NULL &&
-                   object->type == OBJT_SWAP
-               ) {
-                       int n = (cur->end - cur->start) / PAGE_SIZE;
-
+               switch(cur->maptype) {
+               case VM_MAPTYPE_NORMAL:
+               case VM_MAPTYPE_VPAGETABLE:
+                       if ((object = cur->object.vm_object) == NULL)
+                               break;
+                       if (object->type != OBJT_SWAP)
+                               break;
+                       n = (cur->end - cur->start) / PAGE_SIZE;
                        if (object->un_pager.swp.swp_bcount) {
                                count += object->un_pager.swp.swp_bcount *
                                    SWAP_META_PAGES * n / object->size + 1;
                        }
+                       break;
+               default:
+                       break;
                }
        }
        return(count);
@@ -647,7 +652,9 @@ vm_map_lookup_entry(vm_map_t map, vm_offset_t address,
 int
 vm_map_insert(vm_map_t map, int *countp,
              vm_object_t object, vm_ooffset_t offset,
-             vm_offset_t start, vm_offset_t end, vm_prot_t prot, vm_prot_t max,
+             vm_offset_t start, vm_offset_t end,
+             vm_maptype_t maptype,
+             vm_prot_t prot, vm_prot_t max,
              int cow)
 {
        vm_map_entry_t new_entry;
@@ -711,6 +718,7 @@ vm_map_insert(vm_map_t map, int *countp,
                 (prev_entry->eflags == protoeflags) &&
                 (prev_entry->end == start) &&
                 (prev_entry->wired_count == 0) &&
+                prev_entry->maptype == maptype &&
                 ((prev_entry->object.vm_object == NULL) ||
                  vm_object_coalesce(prev_entry->object.vm_object,
                                     OFF_TO_IDX(prev_entry->offset),
@@ -756,6 +764,7 @@ vm_map_insert(vm_map_t map, int *countp,
        new_entry->start = start;
        new_entry->end = end;
 
+       new_entry->maptype = maptype;
        new_entry->eflags = protoeflags;
        new_entry->object.vm_object = object;
        new_entry->offset = offset;
@@ -909,9 +918,11 @@ retry:
  */
 int
 vm_map_find(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
-           vm_offset_t *addr,  /* IN/OUT */
-           vm_size_t length, boolean_t find_space, vm_prot_t prot,
-           vm_prot_t max, int cow)
+           vm_offset_t *addr,  vm_size_t length,
+           boolean_t find_space,
+           vm_maptype_t maptype,
+           vm_prot_t prot, vm_prot_t max,
+           int cow)
 {
        vm_offset_t start;
        int result;
@@ -930,7 +941,10 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
                start = *addr;
        }
        result = vm_map_insert(map, &count, object, offset,
-               start, start + length, prot, max, cow);
+                              start, start + length,
+                              maptype,
+                              prot, max,
+                              cow);
        vm_map_unlock(map);
        vm_map_entry_release(count);
 
@@ -956,15 +970,19 @@ vm_map_simplify_entry(vm_map_t map, vm_map_entry_t entry, int *countp)
        vm_map_entry_t next, prev;
        vm_size_t prevsize, esize;
 
-       if (entry->eflags & (MAP_ENTRY_IN_TRANSITION | MAP_ENTRY_IS_SUB_MAP)) {
+       if (entry->eflags & MAP_ENTRY_IN_TRANSITION) {
                ++mycpu->gd_cnt.v_intrans_coll;
                return;
        }
 
+       if (entry->maptype == VM_MAPTYPE_SUBMAP)
+               return;
+
        prev = entry->prev;
        if (prev != &map->header) {
                prevsize = prev->end - prev->start;
                if ( (prev->end == entry->start) &&
+                    (prev->maptype == entry->maptype) &&
                     (prev->object.vm_object == entry->object.vm_object) &&
                     (!prev->object.vm_object ||
                        (prev->offset + prevsize == entry->offset)) &&
@@ -990,6 +1008,7 @@ vm_map_simplify_entry(vm_map_t map, vm_map_entry_t entry, int *countp)
        if (next != &map->header) {
                esize = entry->end - entry->start;
                if ((entry->end == next->start) &&
+                   (next->maptype == entry->maptype) &&
                    (next->object.vm_object == entry->object.vm_object) &&
                     (!entry->object.vm_object ||
                        (entry->offset + esize == next->offset)) &&
@@ -1065,8 +1084,13 @@ _vm_map_clip_start(vm_map_t map, vm_map_entry_t entry, vm_offset_t start, int *c
 
        vm_map_entry_link(map, entry->prev, new_entry);
 
-       if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
+       switch(entry->maptype) {
+       case VM_MAPTYPE_NORMAL:
+       case VM_MAPTYPE_VPAGETABLE:
                vm_object_reference(new_entry->object.vm_object);
+               break;
+       default:
+               break;
        }
 }
 
@@ -1121,8 +1145,13 @@ _vm_map_clip_end(vm_map_t map, vm_map_entry_t entry, vm_offset_t end, int *count
 
        vm_map_entry_link(map, entry, new_entry);
 
-       if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
+       switch(entry->maptype) {
+       case VM_MAPTYPE_NORMAL:
+       case VM_MAPTYPE_VPAGETABLE:
                vm_object_reference(new_entry->object.vm_object);
+               break;
+       default:
+               break;
        }
 }
 
@@ -1388,7 +1417,7 @@ vm_map_submap(vm_map_t map, vm_offset_t start, vm_offset_t end, vm_map_t submap)
            ((entry->eflags & MAP_ENTRY_COW) == 0) &&
            (entry->object.vm_object == NULL)) {
                entry->object.sub_map = submap;
-               entry->eflags |= MAP_ENTRY_IS_SUB_MAP;
+               entry->maptype = VM_MAPTYPE_SUBMAP;
                result = KERN_SUCCESS;
        }
        vm_map_unlock(map);
@@ -1398,12 +1427,17 @@ vm_map_submap(vm_map_t map, vm_offset_t start, vm_offset_t end, vm_map_t submap)
 }
 
 /*
- *     vm_map_protect:
+ * vm_map_protect:
  *
- *     Sets the protection of the specified address
- *     region in the target map.  If "set_max" is
- *     specified, the maximum protection is to be set;
- *     otherwise, only the current protection is affected.
+ * Sets the protection of the specified address region in the target map. 
+ * If "set_max" is specified, the maximum protection is to be set;
+ * otherwise, only the current protection is affected.
+ *
+ * The protection is not applicable to submaps, but is applicable to normal
+ * maps and maps governed by virtual page tables.  For example, when operating
+ * on a virtual page table our protection basically controls how COW occurs
+ * on the backing object, whereas the virtual page table abstraction itself
+ * is an abstraction for userland.
  */
 int
 vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
@@ -1427,10 +1461,9 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
        /*
         * Make a first pass to check for protection violations.
         */
-
        current = entry;
        while ((current != &map->header) && (current->start < end)) {
-               if (current->eflags & MAP_ENTRY_IS_SUB_MAP) {
+               if (current->maptype == VM_MAPTYPE_SUBMAP) {
                        vm_map_unlock(map);
                        vm_map_entry_release(count);
                        return (KERN_INVALID_ARGUMENT);
@@ -1455,12 +1488,13 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
                vm_map_clip_end(map, current, end, &count);
 
                old_prot = current->protection;
-               if (set_max)
+               if (set_max) {
                        current->protection =
                            (current->max_protection = new_prot) &
                            old_prot;
-               else
+               } else {
                        current->protection = new_prot;
+               }
 
                /*
                 * Update physical map if necessary. Worry about copy-on-write
@@ -1557,7 +1591,7 @@ vm_map_madvise(vm_map_t map, vm_offset_t start, vm_offset_t end, int behav)
                     (current != &map->header) && (current->start < end);
                     current = current->next
                ) {
-                       if (current->eflags & MAP_ENTRY_IS_SUB_MAP)
+                       if (current->maptype == VM_MAPTYPE_SUBMAP)
                                continue;
 
                        vm_map_clip_end(map, current, end, &count);
@@ -1600,6 +1634,9 @@ vm_map_madvise(vm_map_t map, vm_offset_t start, vm_offset_t end, int behav)
                 *
                 * Since we don't clip the vm_map_entry, we have to clip
                 * the vm_object pindex and count.
+                *
+                * NOTE!  We currently do not support these functions on
+                * virtual page tables.
                 */
                for (current = entry;
                     (current != &map->header) && (current->start < end);
@@ -1607,7 +1644,7 @@ vm_map_madvise(vm_map_t map, vm_offset_t start, vm_offset_t end, int behav)
                ) {
                        vm_offset_t useStart;
 
-                       if (current->eflags & MAP_ENTRY_IS_SUB_MAP)
+                       if (current->maptype != VM_MAPTYPE_NORMAL)
                                continue;
 
                        pindex = OFF_TO_IDX(current->offset);
@@ -1746,7 +1783,7 @@ vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t real_end,
                         * management structures and the faulting in of the
                         * page.
                         */
-                       if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
+                       if (entry->maptype != VM_MAPTYPE_SUBMAP) {
                                int copyflag = entry->eflags & MAP_ENTRY_NEEDS_COPY;
                                if (copyflag && ((entry->protection & VM_PROT_WRITE) != 0)) {
 
@@ -1952,7 +1989,7 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t real_end, int kmflags)
                         * do not have to do this for entries that point to sub
                         * maps because we won't hold the lock on the sub map.
                         */
-                       if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
+                       if (entry->maptype != VM_MAPTYPE_SUBMAP) {
                                int copyflag = entry->eflags & MAP_ENTRY_NEEDS_COPY;
                                if (copyflag &&
                                    ((entry->protection & VM_PROT_WRITE) != 0)) {
@@ -2137,7 +2174,7 @@ vm_map_clean(vm_map_t map, vm_offset_t start, vm_offset_t end, boolean_t syncio,
         * Make a first pass to check for holes.
         */
        for (current = entry; current->start < end; current = current->next) {
-               if (current->eflags & MAP_ENTRY_IS_SUB_MAP) {
+               if (current->maptype == VM_MAPTYPE_SUBMAP) {
                        vm_map_unlock_read(map);
                        return (KERN_INVALID_ARGUMENT);
                }
@@ -2158,7 +2195,7 @@ vm_map_clean(vm_map_t map, vm_offset_t start, vm_offset_t end, boolean_t syncio,
        for (current = entry; current->start < end; current = current->next) {
                offset = current->offset + (start - current->start);
                size = (end <= current->end ? end : current->end) - start;
-               if (current->eflags & MAP_ENTRY_IS_SUB_MAP) {
+               if (current->maptype == VM_MAPTYPE_SUBMAP) {
                        vm_map_t smap;
                        vm_map_entry_t tentry;
                        vm_size_t tsize;
@@ -2211,10 +2248,23 @@ vm_map_clean(vm_map_t map, vm_offset_t start, vm_offset_t end, boolean_t syncio,
                        vn_lock(object->handle, LK_EXCLUSIVE | LK_RETRY);
                        flags = (syncio || invalidate) ? OBJPC_SYNC : 0;
                        flags |= invalidate ? OBJPC_INVAL : 0;
-                       vm_object_page_clean(object,
-                           OFF_TO_IDX(offset),
-                           OFF_TO_IDX(offset + size + PAGE_MASK),
-                           flags);
+
+                       /*
+                        * When operating on a virtual page table just
+                        * flush the whole object.  XXX we probably ought
+                        * to 
+                        */
+                       switch(current->maptype) {
+                       case VM_MAPTYPE_NORMAL:
+                               vm_object_page_clean(object,
+                                   OFF_TO_IDX(offset),
+                                   OFF_TO_IDX(offset + size + PAGE_MASK),
+                                   flags);
+                               break;
+                       case VM_MAPTYPE_VPAGETABLE:
+                               vm_object_page_clean(object, 0, 0, flags);
+                               break;
+                       }
                        vn_unlock(((struct vnode *)object->handle));
                        vm_object_deallocate(object);
                }
@@ -2224,10 +2274,17 @@ vm_map_clean(vm_map_t map, vm_offset_t start, vm_offset_t end, boolean_t syncio,
                        int clean_only = 
                                (object->type == OBJT_DEVICE) ? FALSE : TRUE;
                        vm_object_reference(object);
-                       vm_object_page_remove(object,
-                           OFF_TO_IDX(offset),
-                           OFF_TO_IDX(offset + size + PAGE_MASK),
-                           clean_only);
+                       switch(current->maptype) {
+                       case VM_MAPTYPE_NORMAL:
+                               vm_object_page_remove(object,
+                                   OFF_TO_IDX(offset),
+                                   OFF_TO_IDX(offset + size + PAGE_MASK),
+                                   clean_only);
+                               break;
+                       case VM_MAPTYPE_VPAGETABLE:
+                               vm_object_page_remove(object, 0, 0, clean_only);
+                               break;
+                       }
                        vm_object_deallocate(object);
                }
                start += size;
@@ -2264,8 +2321,13 @@ vm_map_entry_delete(vm_map_t map, vm_map_entry_t entry, int *countp)
        vm_map_entry_unlink(map, entry);
        map->size -= entry->end - entry->start;
 
-       if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
+       switch(entry->maptype) {
+       case VM_MAPTYPE_NORMAL:
+       case VM_MAPTYPE_VPAGETABLE:
                vm_object_deallocate(entry->object.vm_object);
+               break;
+       default:
+               break;
        }
 
        vm_map_entry_dispose(map, entry, countp);
@@ -2577,11 +2639,12 @@ vm_map_copy_entry(vm_map_t src_map, vm_map_t dst_map,
 {
        vm_object_t src_object;
 
-       if ((dst_entry->eflags|src_entry->eflags) & MAP_ENTRY_IS_SUB_MAP)
+       if (dst_entry->maptype == VM_MAPTYPE_SUBMAP)
+               return;
+       if (src_entry->maptype == VM_MAPTYPE_SUBMAP)
                return;
 
        if (src_entry->wired_count == 0) {
-
                /*
                 * If the source entry is marked needs_copy, it is already
                 * write-protected.
@@ -2597,7 +2660,6 @@ vm_map_copy_entry(vm_map_t src_map, vm_map_t dst_map,
                 * Make a copy of the object.
                 */
                if ((src_object = src_entry->object.vm_object) != NULL) {
-
                        if ((src_object->handle == NULL) &&
                                (src_object->type == OBJT_DEFAULT ||
                                 src_object->type == OBJT_SWAP)) {
@@ -2674,7 +2736,7 @@ vmspace_fork(struct vmspace *vm1)
 
        old_entry = old_map->header.next;
        while (old_entry != &old_map->header) {
-               if (old_entry->eflags & MAP_ENTRY_IS_SUB_MAP)
+               if (old_entry->maptype == VM_MAPTYPE_SUBMAP)
                        panic("vm_map_fork: encountered a submap");
 
                switch (old_entry->inheritance) {
@@ -2683,7 +2745,8 @@ vmspace_fork(struct vmspace *vm1)
 
                case VM_INHERIT_SHARE:
                        /*
-                        * Clone the entry, creating the shared object if necessary.
+                        * Clone the entry, creating the shared object if
+                        * necessary.
                         */
                        object = old_entry->object.vm_object;
                        if (object == NULL) {
@@ -2825,7 +2888,10 @@ vm_map_stack (vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize,
         */
        rv = vm_map_insert(map, &count,
                           NULL, 0, addrbos + max_ssize - init_ssize,
-                          addrbos + max_ssize, prot, max, cow);
+                          addrbos + max_ssize,
+                          VM_MAPTYPE_NORMAL,
+                          prot, max,
+                          cow);
 
        /* Now set the avail_ssize amount */
        if (rv == KERN_SUCCESS) {
@@ -2970,8 +3036,8 @@ Retry:
 
        rv = vm_map_insert(map, &count,
                           NULL, 0, addr, stack_entry->start,
-                          VM_PROT_ALL,
-                          VM_PROT_ALL,
+                          VM_MAPTYPE_NORMAL,
+                          VM_PROT_ALL, VM_PROT_ALL,
                           0);
 
        /* Adjust the available stack space by the amount we grew. */
@@ -3137,8 +3203,7 @@ RetryLookup:
        /*
         * Handle submaps.
         */
-
-       if (entry->eflags & MAP_ENTRY_IS_SUB_MAP) {
+       if (entry->maptype == VM_MAPTYPE_SUBMAP) {
                vm_map_t old_map = map;
 
                *var_map = map = entry->object.sub_map;
@@ -3330,7 +3395,7 @@ DB_SHOW_COMMAND(map, vm_map_print)
                        if (entry->wired_count != 0)
                                db_printf(", wired");
                }
-               if (entry->eflags & MAP_ENTRY_IS_SUB_MAP) {
+               if (entry->maptype == VM_MAPTYPE_SUBMAP) {
                        /* XXX no %qd in kernel.  Truncate entry->offset. */
                        db_printf(", share=%p, offset=0x%lx\n",
                            (void *)entry->object.sub_map,
index 8aa9053..ef5f49d 100644 (file)
@@ -62,7 +62,7 @@
  * rights to redistribute these changes.
  *
  * $FreeBSD: src/sys/vm/vm_map.h,v 1.54.2.5 2003/01/13 22:51:17 dillon Exp $
- * $DragonFly: src/sys/vm/vm_map.h,v 1.22 2006/05/20 02:42:15 dillon Exp $
+ * $DragonFly: src/sys/vm/vm_map.h,v 1.23 2006/09/11 20:25:31 dillon Exp $
  */
 
 /*
@@ -127,7 +127,7 @@ struct vm_map_entry {
        union vm_map_object object;     /* object I point to */
        vm_ooffset_t offset;            /* offset into object */
        vm_eflags_t eflags;             /* map entry flags */
-       /* Only in task maps: */
+       vm_maptype_t maptype;           /* type of VM mapping */
        vm_prot_t protection;           /* protection code */
        vm_prot_t max_protection;       /* maximum protection */
        vm_inherit_t inheritance;       /* inheritance */
@@ -136,7 +136,7 @@ struct vm_map_entry {
 };
 
 #define MAP_ENTRY_NOSYNC               0x0001
-#define MAP_ENTRY_IS_SUB_MAP           0x0002
+#define MAP_ENTRY_UNUSED0002           0x0002
 #define MAP_ENTRY_COW                  0x0004
 #define MAP_ENTRY_NEEDS_COPY           0x0008
 #define MAP_ENTRY_NOFAULT              0x0010
@@ -418,11 +418,20 @@ void vm_map_entry_release(int);
 void vm_map_entry_krelease(int);
 vm_map_t vm_map_create (struct pmap *, vm_offset_t, vm_offset_t);
 int vm_map_delete (vm_map_t, vm_offset_t, vm_offset_t, int *);
-int vm_map_find (vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t, boolean_t, vm_prot_t, vm_prot_t, int);
+int vm_map_find (vm_map_t, vm_object_t, vm_ooffset_t,
+                vm_offset_t *, vm_size_t, 
+                boolean_t, 
+                vm_maptype_t,
+                vm_prot_t, vm_prot_t, 
+                int);
 int vm_map_findspace (vm_map_t, vm_offset_t, vm_size_t, vm_offset_t, vm_offset_t *);
 int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t);
 void vm_map_init (struct vm_map *, vm_offset_t, vm_offset_t);
-int vm_map_insert (vm_map_t, int *, vm_object_t, vm_ooffset_t, vm_offset_t, vm_offset_t, vm_prot_t, vm_prot_t, int);
+int vm_map_insert (vm_map_t, int *, vm_object_t, vm_ooffset_t,
+                  vm_offset_t, vm_offset_t,
+                  vm_maptype_t,
+                  vm_prot_t, vm_prot_t,
+                  int);
 int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *,
     vm_pindex_t *, vm_prot_t *, boolean_t *);
 void vm_map_lookup_done (vm_map_t, vm_map_entry_t, int);
index d0f12ff..fb81c20 100644 (file)
@@ -32,7 +32,7 @@
  *
  *     @(#)vm_meter.c  8.4 (Berkeley) 1/4/94
  * $FreeBSD: src/sys/vm/vm_meter.c,v 1.34.2.7 2002/10/10 19:28:22 dillon Exp $
- * $DragonFly: src/sys/vm/vm_meter.c,v 1.9 2006/05/25 07:36:37 dillon Exp $
+ * $DragonFly: src/sys/vm/vm_meter.c,v 1.10 2006/09/11 20:25:31 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -176,8 +176,11 @@ do_vmtotal_callback(struct proc *p, void *data)
        paging = 0;
        for (map = &p->p_vmspace->vm_map, entry = map->header.next;
            entry != &map->header; entry = entry->next) {
-               if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) ||
-                   entry->object.vm_object == NULL)
+               if (entry->maptype != VM_MAPTYPE_NORMAL &&
+                   entry->maptype != VM_MAPTYPE_VPAGETABLE) {
+                       continue;
+               }
+               if (entry->object.vm_object == NULL)
                        continue;
                vm_object_set_flag(entry->object.vm_object, OBJ_ACTIVE);
                paging |= entry->object.vm_object->paging_in_progress;
index 97b274d..dae16bc 100644 (file)
@@ -39,7 +39,7 @@
  *
  *     @(#)vm_mmap.c   8.4 (Berkeley) 1/12/94
  * $FreeBSD: src/sys/vm/vm_mmap.c,v 1.108.2.6 2002/07/02 20:06:19 dillon Exp $
- * $DragonFly: src/sys/vm/vm_mmap.c,v 1.30 2006/06/05 07:26:11 dillon Exp $
+ * $DragonFly: src/sys/vm/vm_mmap.c,v 1.31 2006/09/11 20:25:31 dillon Exp $
  */
 
 /*
@@ -669,8 +669,11 @@ RestartScan:
                /*
                 * ignore submaps (for now) or null objects
                 */
-               if ((current->eflags & MAP_ENTRY_IS_SUB_MAP) ||
-                       current->object.vm_object == NULL)
+               if (current->maptype != VM_MAPTYPE_NORMAL &&
+                   current->maptype != VM_MAPTYPE_VPAGETABLE) {
+                       continue;
+               }
+               if (current->object.vm_object == NULL)
                        continue;
                
                /*
@@ -691,9 +694,14 @@ RestartScan:
                         * Check pmap first, it is likely faster, also
                         * it can provide info as to whether we are the
                         * one referencing or modifying the page.
+                        *
+                        * If we have to check the VM object, only mess
+                        * around with normal maps.  Do not mess around
+                        * with virtual page tables (XXX).
                         */
                        mincoreinfo = pmap_mincore(pmap, addr);
-                       if (!mincoreinfo) {
+                       if (mincoreinfo == 0 &&
+                           current->maptype == VM_MAPTYPE_NORMAL) {
                                vm_pindex_t pindex;
                                vm_ooffset_t offset;
                                vm_page_t m;
@@ -1019,12 +1027,14 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot,
                *addr = pmap_addr_hint(object, *addr, size);
        }
 
-       if (flags & MAP_STACK)
+       if (flags & MAP_STACK) {
                rv = vm_map_stack (map, *addr, size, prot,
                                   maxprot, docow);
-       else
+       } else {
+               /* XXX VM_MAPTYPE_VPAGETABLE if MAP_VPAGETABLE */
                rv = vm_map_find(map, object, foff, addr, size, fitit,
-                                prot, maxprot, docow);
+                                VM_MAPTYPE_NORMAL, prot, maxprot, docow);
+       }
 
        if (rv != KERN_SUCCESS) {
                /*
index e14b7ba..53f559a 100644 (file)
@@ -62,7 +62,7 @@
  * rights to redistribute these changes.
  *
  * $FreeBSD: src/sys/vm/vm_object.c,v 1.171.2.8 2003/05/26 19:17:56 alc Exp $
- * $DragonFly: src/sys/vm/vm_object.c,v 1.25 2006/05/25 07:36:37 dillon Exp $
+ * $DragonFly: src/sys/vm/vm_object.c,v 1.26 2006/09/11 20:25:31 dillon Exp $
  */
 
 /*
@@ -1758,7 +1758,6 @@ _vm_object_in_map(vm_map_t map, vm_object_t object, vm_map_entry_t entry)
 
        if (map == 0)
                return 0;
-
        if (entry == 0) {
                tmpe = map->header.next;
                entcount = map->nentries;
@@ -1768,7 +1767,10 @@ _vm_object_in_map(vm_map_t map, vm_object_t object, vm_map_entry_t entry)
                        }
                        tmpe = tmpe->next;
                }
-       } else if (entry->eflags & MAP_ENTRY_IS_SUB_MAP) {
+               return (0);
+       }
+       switch(entry->maptype) {
+       case VM_MAPTYPE_SUBMAP:
                tmpm = entry->object.sub_map;
                tmpe = tmpm->header.next;
                entcount = tmpm->nentries;
@@ -1778,11 +1780,18 @@ _vm_object_in_map(vm_map_t map, vm_object_t object, vm_map_entry_t entry)
                        }
                        tmpe = tmpe->next;
                }
-       } else if ((obj = entry->object.vm_object) != NULL) {
-               for(; obj; obj=obj->backing_object)
-                       if( obj == object) {
+               break;
+       case VM_MAPTYPE_NORMAL:
+       case VM_MAPTYPE_VPAGETABLE:
+               obj = entry->object.vm_object;
+               while (obj) {
+                       if (obj == object)
                                return 1;
-                       }
+                       obj = obj->backing_object;
+               }
+               break;
+       default:
+               break;
        }
        return 0;
 }
index cf953d8..a4f7164 100644 (file)
@@ -66,7 +66,7 @@
  * rights to redistribute these changes.
  *
  * $FreeBSD: src/sys/vm/vm_pageout.c,v 1.151.2.15 2002/12/29 18:21:04 dillon Exp $
- * $DragonFly: src/sys/vm/vm_pageout.c,v 1.24 2006/08/12 00:26:22 dillon Exp $
+ * $DragonFly: src/sys/vm/vm_pageout.c,v 1.25 2006/09/11 20:25:31 dillon Exp $
  */
 
 /*
@@ -582,13 +582,18 @@ vm_pageout_map_deactivate_pages(vm_map_t map, vm_pindex_t desired)
         */
        tmpe = map->header.next;
        while (tmpe != &map->header) {
-               if ((tmpe->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
+               switch(tmpe->maptype) {
+               case VM_MAPTYPE_NORMAL:
+               case VM_MAPTYPE_VPAGETABLE:
                        obj = tmpe->object.vm_object;
                        if ((obj != NULL) && (obj->shadow_count <= 1) &&
                                ((bigobj == NULL) ||
                                 (bigobj->resident_page_count < obj->resident_page_count))) {
                                bigobj = obj;
                        }
+                       break;
+               default:
+                       break;
                }
                if (tmpe->wired_count > 0)
                        nothingwired = FALSE;
@@ -606,10 +611,15 @@ vm_pageout_map_deactivate_pages(vm_map_t map, vm_pindex_t desired)
        while (tmpe != &map->header) {
                if (pmap_resident_count(vm_map_pmap(map)) <= desired)
                        break;
-               if ((tmpe->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
+               switch(tmpe->maptype) {
+               case VM_MAPTYPE_NORMAL:
+               case VM_MAPTYPE_VPAGETABLE:
                        obj = tmpe->object.vm_object;
                        if (obj)
                                vm_pageout_object_deactivate_pages(map, obj, desired, 0);
+                       break;
+               default:
+                       break;
                }
                tmpe = tmpe->next;
        };
index 5df81cb..1c2bc5c 100644 (file)
@@ -39,7 +39,7 @@
  *
  *     @(#)vm_unix.c   8.1 (Berkeley) 6/11/93
  * $FreeBSD: src/sys/vm/vm_unix.c,v 1.24.2.2 2002/07/02 20:06:19 dillon Exp $
- * $DragonFly: src/sys/vm/vm_unix.c,v 1.5 2006/06/05 07:26:11 dillon Exp $
+ * $DragonFly: src/sys/vm/vm_unix.c,v 1.6 2006/09/11 20:25:31 dillon Exp $
  */
 
 /*
@@ -96,8 +96,12 @@ sys_obreak(struct obreak_args *uap)
                diff = new - old;
                if (vm->vm_map.size + diff > p->p_rlimit[RLIMIT_VMEM].rlim_cur)
                        return(ENOMEM);
-               rv = vm_map_find(&vm->vm_map, NULL, 0, &old, diff, FALSE,
-                       VM_PROT_ALL, VM_PROT_ALL, 0);
+               rv = vm_map_find(&vm->vm_map, NULL, 0,
+                                &old, diff,
+                                FALSE,
+                                VM_MAPTYPE_NORMAL,
+                                VM_PROT_ALL, VM_PROT_ALL,
+                                0);
                if (rv != KERN_SUCCESS) {
                        return (ENOMEM);
                }
index 6d84faf..26b6355 100644 (file)
@@ -33,7 +33,7 @@
  * @(#) Copyright (c) 1988, 1993 The Regents of the University of California.  All rights reserved.
  * @(#)fstat.c 8.3 (Berkeley) 5/2/95
  * $FreeBSD: src/usr.bin/fstat/fstat.c,v 1.21.2.7 2001/11/21 10:49:37 dwmalone Exp $
- * $DragonFly: src/usr.bin/fstat/fstat.c,v 1.18 2006/09/09 19:07:26 dillon Exp $
+ * $DragonFly: src/usr.bin/fstat/fstat.c,v 1.19 2006/09/11 20:24:57 dillon Exp $
  */
 
 #define        _KERNEL_STRUCTURES
@@ -417,7 +417,7 @@ dommap(struct kinfo_proc *kp)
                        return;
                }
 
-               if (entry.eflags & MAP_ENTRY_IS_SUB_MAP)
+               if (entry.maptype == VM_MAPTYPE_SUBMAP)
                        continue;
 
                if ((objp = entry.object.vm_object) == NULL)