Author: kib
Date: Tue Sep  8 23:38:49 2020
New Revision: 365485
URL: https://svnweb.freebsd.org/changeset/base/365485

Log:
  Convert allocations of the phys pager to vm_pager_allocate().
  
  Future changes would require additional initialization of OBJT_PHYS
  objects, and vm_object_allocate() is not suitable for it.
  
  Reviewed by:  markj
  Tested by:    pho
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week
  Differential revision:        https://reviews.freebsd.org/D24652

Modified:
  head/sys/dev/ksyms/ksyms.c
  head/sys/dev/xen/gntdev/gntdev.c
  head/sys/kern/link_elf.c
  head/sys/kern/link_elf_obj.c

Modified: head/sys/dev/ksyms/ksyms.c
==============================================================================
--- head/sys/dev/ksyms/ksyms.c  Tue Sep  8 23:28:09 2020        (r365484)
+++ head/sys/dev/ksyms/ksyms.c  Tue Sep  8 23:38:49 2020        (r365485)
@@ -41,6 +41,7 @@
 #include <sys/proc.h>
 #include <sys/queue.h>
 #include <sys/resourcevar.h>
+#include <sys/rwlock.h>
 #include <sys/stat.h>
 #include <sys/sx.h>
 #include <sys/uio.h>
@@ -51,6 +52,8 @@
 #include <vm/vm.h>
 #include <vm/vm_extern.h>
 #include <vm/vm_object.h>
+#include <vm/vm_page.h>
+#include <vm/vm_pager.h>
 
 #include "linker_if.h"
 
@@ -442,8 +445,8 @@ ksyms_open(struct cdev *dev, int flags, int fmt __unus
                ksyms_size_calc(&ts);
                elfsz = sizeof(struct ksyms_hdr) + ts.ts_symsz + ts.ts_strsz;
 
-               object = vm_object_allocate(OBJT_PHYS,
-                   OFF_TO_IDX(round_page(elfsz)));
+               object = vm_pager_allocate(OBJT_PHYS, NULL, round_page(elfsz),
+                   VM_PROT_ALL, 0, td->td_ucred);
                sc->sc_obj = object;
                sc->sc_objsz = elfsz;
 

Modified: head/sys/dev/xen/gntdev/gntdev.c
==============================================================================
--- head/sys/dev/xen/gntdev/gntdev.c    Tue Sep  8 23:28:09 2020        
(r365484)
+++ head/sys/dev/xen/gntdev/gntdev.c    Tue Sep  8 23:38:49 2020        
(r365485)
@@ -1068,7 +1068,8 @@ mmap_gref(struct per_user_data *priv_user, struct gntd
        vm_object_t mem_obj;
        struct gntdev_gref *gref;
 
-       mem_obj = vm_object_allocate(OBJT_PHYS, size);
+       mem_obj = vm_pager_allocate(OBJT_PHYS, NULL, size, VM_PROT_ALL, 0,
+           curthread->td_ucred);
        if (mem_obj == NULL)
                return (ENOMEM);
 

Modified: head/sys/kern/link_elf.c
==============================================================================
--- head/sys/kern/link_elf.c    Tue Sep  8 23:28:09 2020        (r365484)
+++ head/sys/kern/link_elf.c    Tue Sep  8 23:38:49 2020        (r365485)
@@ -1106,7 +1106,8 @@ link_elf_load_file(linker_class_t cls, const char* fil
 
        ef = (elf_file_t) lf;
 #ifdef SPARSE_MAPPING
-       ef->object = vm_object_allocate(OBJT_PHYS, atop(mapsize));
+       ef->object = vm_pager_allocate(OBJT_PHYS, NULL, mapsize, VM_PROT_ALL,
+           0, thread0.td_ucred);
        if (ef->object == NULL) {
                error = ENOMEM;
                goto out;

Modified: head/sys/kern/link_elf_obj.c
==============================================================================
--- head/sys/kern/link_elf_obj.c        Tue Sep  8 23:28:09 2020        
(r365484)
+++ head/sys/kern/link_elf_obj.c        Tue Sep  8 23:38:49 2020        
(r365485)
@@ -34,16 +34,17 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/fcntl.h>
 #include <sys/kernel.h>
 #include <sys/lock.h>
 #include <sys/malloc.h>
+#include <sys/linker.h>
 #include <sys/mutex.h>
 #include <sys/mount.h>
-#include <sys/proc.h>
 #include <sys/namei.h>
-#include <sys/fcntl.h>
+#include <sys/proc.h>
+#include <sys/rwlock.h>
 #include <sys/vnode.h>
-#include <sys/linker.h>
 
 #include <machine/elf.h>
 
@@ -53,11 +54,13 @@ __FBSDID("$FreeBSD$");
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
-#include <vm/vm_object.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
 #include <vm/pmap.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
 #include <vm/vm_map.h>
+#include <vm/vm_object.h>
+#include <vm/vm_page.h>
+#include <vm/vm_pager.h>
 
 #include <sys/link_elf.h>
 
@@ -905,7 +908,8 @@ link_elf_load_file(linker_class_t cls, const char *fil
         * This stuff needs to be in a single chunk so that profiling etc
         * can get the bounds and gdb can associate offsets with modules
         */
-       ef->object = vm_object_allocate(OBJT_PHYS, atop(round_page(mapsize)));
+       ef->object = vm_pager_allocate(OBJT_PHYS, NULL, round_page(mapsize),
+           VM_PROT_ALL, 0, thread0.td_ucred);
        if (ef->object == NULL) {
                error = ENOMEM;
                goto out;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to