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
This commit is contained in:
kib 2020-09-08 23:38:49 +00:00
parent 97138e71d7
commit 205e6f3a9f
4 changed files with 20 additions and 11 deletions

View File

@ -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 __unused, struct thread *td)
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;

View File

@ -1068,7 +1068,8 @@ mmap_gref(struct per_user_data *priv_user, struct gntdev_gref *gref_start,
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);

View File

@ -1106,7 +1106,8 @@ link_elf_load_file(linker_class_t cls, const char* filename,
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;

View File

@ -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 *filename,
* 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;