Home | History | Annotate | Line # | Download | only in rumpkern
vm.c revision 1.89
      1 /*	$NetBSD: vm.c,v 1.89 2010/09/07 06:06:54 pooka Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
      5  *
      6  * Development of this software was supported by
      7  * The Finnish Cultural Foundation and the Research Foundation of
      8  * The Helsinki University of Technology.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     20  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     22  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29  * SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Virtual memory emulation routines.
     34  */
     35 
     36 /*
     37  * XXX: we abuse pg->uanon for the virtual address of the storage
     38  * for each page.  phys_addr would fit the job description better,
     39  * except that it will create unnecessary lossage on some platforms
     40  * due to not being a pointer type.
     41  */
     42 
     43 #include <sys/cdefs.h>
     44 __KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.89 2010/09/07 06:06:54 pooka Exp $");
     45 
     46 #include <sys/param.h>
     47 #include <sys/atomic.h>
     48 #include <sys/buf.h>
     49 #include <sys/kernel.h>
     50 #include <sys/kmem.h>
     51 #include <sys/mman.h>
     52 #include <sys/null.h>
     53 #include <sys/vnode.h>
     54 
     55 #include <machine/pmap.h>
     56 
     57 #include <rump/rumpuser.h>
     58 
     59 #include <uvm/uvm.h>
     60 #include <uvm/uvm_ddb.h>
     61 #include <uvm/uvm_pdpolicy.h>
     62 #include <uvm/uvm_prot.h>
     63 #include <uvm/uvm_readahead.h>
     64 
     65 #include "rump_private.h"
     66 
     67 kmutex_t uvm_pageqlock;
     68 kmutex_t uvm_swap_data_lock;
     69 
     70 struct uvmexp uvmexp;
     71 struct uvm uvm;
     72 
     73 struct vm_map rump_vmmap;
     74 static struct vm_map_kernel kmem_map_store;
     75 struct vm_map *kmem_map = &kmem_map_store.vmk_map;
     76 
     77 static struct vm_map_kernel kernel_map_store;
     78 struct vm_map *kernel_map = &kernel_map_store.vmk_map;
     79 
     80 static unsigned int pdaemon_waiters;
     81 static kmutex_t pdaemonmtx;
     82 static kcondvar_t pdaemoncv, oomwait;
     83 
     84 #define RUMPMEM_UNLIMITED ((unsigned long)-1)
     85 static unsigned long physmemlimit = RUMPMEM_UNLIMITED;
     86 static unsigned long curphysmem;
     87 
     88 static int
     89 pg_compare_key(const struct rb_node *n, const void *key)
     90 {
     91 	voff_t a = ((const struct vm_page *)n)->offset;
     92 	voff_t b = *(const voff_t *)key;
     93 
     94 	if (a < b)
     95 		return 1;
     96 	else if (a > b)
     97 		return -1;
     98 	else
     99 		return 0;
    100 }
    101 
    102 static int
    103 pg_compare_nodes(const struct rb_node *n1, const struct rb_node *n2)
    104 {
    105 
    106 	return pg_compare_key(n1, &((const struct vm_page *)n2)->offset);
    107 }
    108 
    109 const struct rb_tree_ops uvm_page_tree_ops = {
    110 	.rbto_compare_nodes = pg_compare_nodes,
    111 	.rbto_compare_key = pg_compare_key,
    112 };
    113 
    114 /*
    115  * vm pages
    116  */
    117 
    118 /* called with the object locked */
    119 struct vm_page *
    120 uvm_pagealloc_strat(struct uvm_object *uobj, voff_t off, struct vm_anon *anon,
    121 	int flags, int strat, int free_list)
    122 {
    123 	struct vm_page *pg;
    124 
    125 	pg = kmem_zalloc(sizeof(struct vm_page), KM_SLEEP);
    126 	pg->offset = off;
    127 	pg->uobject = uobj;
    128 
    129 	pg->uanon = (void *)kmem_alloc(PAGE_SIZE, KM_SLEEP);
    130 	if (flags & UVM_PGA_ZERO)
    131 		memset(pg->uanon, 0, PAGE_SIZE);
    132 	pg->flags = PG_CLEAN|PG_BUSY|PG_FAKE;
    133 
    134 	TAILQ_INSERT_TAIL(&uobj->memq, pg, listq.queue);
    135 	rb_tree_insert_node(&uobj->rb_tree, &pg->rb_node);
    136 
    137 	uobj->uo_npages++;
    138 
    139 	return pg;
    140 }
    141 
    142 /*
    143  * Release a page.
    144  *
    145  * Called with the vm object locked.
    146  */
    147 void
    148 uvm_pagefree(struct vm_page *pg)
    149 {
    150 	struct uvm_object *uobj = pg->uobject;
    151 
    152 	if (pg->flags & PG_WANTED)
    153 		wakeup(pg);
    154 
    155 	uobj->uo_npages--;
    156 	rb_tree_remove_node(&uobj->rb_tree, &pg->rb_node);
    157 	TAILQ_REMOVE(&uobj->memq, pg, listq.queue);
    158 	kmem_free((void *)pg->uanon, PAGE_SIZE);
    159 	kmem_free(pg, sizeof(*pg));
    160 }
    161 
    162 void
    163 uvm_pagezero(struct vm_page *pg)
    164 {
    165 
    166 	pg->flags &= ~PG_CLEAN;
    167 	memset((void *)pg->uanon, 0, PAGE_SIZE);
    168 }
    169 
    170 /*
    171  * Misc routines
    172  */
    173 
    174 static kmutex_t pagermtx;
    175 
    176 void
    177 uvm_init(void)
    178 {
    179 	char buf[64];
    180 	int error;
    181 
    182 	if (rumpuser_getenv("RUMP_MEMLIMIT", buf, sizeof(buf), &error) == 0) {
    183 		physmemlimit = strtoll(buf, NULL, 10);
    184 		/* it's not like we'd get far with, say, 1 byte, but ... */
    185 		if (physmemlimit == 0)
    186 			panic("uvm_init: no memory available");
    187 #define HUMANIZE_BYTES 9
    188 		CTASSERT(sizeof(buf) >= HUMANIZE_BYTES);
    189 		format_bytes(buf, HUMANIZE_BYTES, physmemlimit);
    190 #undef HUMANIZE_BYTES
    191 	} else {
    192 		strlcpy(buf, "unlimited (host limit)", sizeof(buf));
    193 	}
    194 	aprint_verbose("total memory = %s\n", buf);
    195 
    196 	uvmexp.free = 1024*1024; /* XXX: arbitrary & not updated */
    197 
    198 	mutex_init(&pagermtx, MUTEX_DEFAULT, 0);
    199 	mutex_init(&uvm_pageqlock, MUTEX_DEFAULT, 0);
    200 	mutex_init(&uvm_swap_data_lock, MUTEX_DEFAULT, 0);
    201 
    202 	mutex_init(&pdaemonmtx, MUTEX_DEFAULT, 0);
    203 	cv_init(&pdaemoncv, "pdaemon");
    204 	cv_init(&oomwait, "oomwait");
    205 
    206 	kernel_map->pmap = pmap_kernel();
    207 	callback_head_init(&kernel_map_store.vmk_reclaim_callback, IPL_VM);
    208 	kmem_map->pmap = pmap_kernel();
    209 	callback_head_init(&kmem_map_store.vmk_reclaim_callback, IPL_VM);
    210 }
    211 
    212 void
    213 uvmspace_init(struct vmspace *vm, struct pmap *pmap, vaddr_t vmin, vaddr_t vmax)
    214 {
    215 
    216 	vm->vm_map.pmap = pmap_kernel();
    217 	vm->vm_refcnt = 1;
    218 }
    219 
    220 void
    221 uvm_pagewire(struct vm_page *pg)
    222 {
    223 
    224 	/* nada */
    225 }
    226 
    227 void
    228 uvm_pageunwire(struct vm_page *pg)
    229 {
    230 
    231 	/* nada */
    232 }
    233 
    234 /* where's your schmonz now? */
    235 #define PUNLIMIT(a)	\
    236 p->p_rlimit[a].rlim_cur = p->p_rlimit[a].rlim_max = RLIM_INFINITY;
    237 void
    238 uvm_init_limits(struct proc *p)
    239 {
    240 
    241 	PUNLIMIT(RLIMIT_STACK);
    242 	PUNLIMIT(RLIMIT_DATA);
    243 	PUNLIMIT(RLIMIT_RSS);
    244 	PUNLIMIT(RLIMIT_AS);
    245 	/* nice, cascade */
    246 }
    247 #undef PUNLIMIT
    248 
    249 /*
    250  * This satisfies the "disgusting mmap hack" used by proplib.
    251  * We probably should grow some more assertables to make sure we're
    252  * not satisfying anything we shouldn't be satisfying.  At least we
    253  * should make sure it's the local machine we're mmapping ...
    254  */
    255 int
    256 uvm_mmap(struct vm_map *map, vaddr_t *addr, vsize_t size, vm_prot_t prot,
    257 	vm_prot_t maxprot, int flags, void *handle, voff_t off, vsize_t locklim)
    258 {
    259 	void *uaddr;
    260 	int error;
    261 
    262 	if (prot != (VM_PROT_READ | VM_PROT_WRITE))
    263 		panic("uvm_mmap() variant unsupported");
    264 	if (flags != (MAP_PRIVATE | MAP_ANON))
    265 		panic("uvm_mmap() variant unsupported");
    266 	/* no reason in particular, but cf. uvm_default_mapaddr() */
    267 	if (*addr != 0)
    268 		panic("uvm_mmap() variant unsupported");
    269 
    270 	uaddr = rumpuser_anonmmap(NULL, size, 0, 0, &error);
    271 	if (uaddr == NULL)
    272 		return error;
    273 
    274 	*addr = (vaddr_t)uaddr;
    275 	return 0;
    276 }
    277 
    278 struct pagerinfo {
    279 	vaddr_t pgr_kva;
    280 	int pgr_npages;
    281 	struct vm_page **pgr_pgs;
    282 	bool pgr_read;
    283 
    284 	LIST_ENTRY(pagerinfo) pgr_entries;
    285 };
    286 static LIST_HEAD(, pagerinfo) pagerlist = LIST_HEAD_INITIALIZER(pagerlist);
    287 
    288 /*
    289  * Pager "map" in routine.  Instead of mapping, we allocate memory
    290  * and copy page contents there.  Not optimal or even strictly
    291  * correct (the caller might modify the page contents after mapping
    292  * them in), but what the heck.  Assumes UVMPAGER_MAPIN_WAITOK.
    293  */
    294 vaddr_t
    295 uvm_pagermapin(struct vm_page **pgs, int npages, int flags)
    296 {
    297 	struct pagerinfo *pgri;
    298 	vaddr_t curkva;
    299 	int i;
    300 
    301 	/* allocate structures */
    302 	pgri = kmem_alloc(sizeof(*pgri), KM_SLEEP);
    303 	pgri->pgr_kva = (vaddr_t)kmem_alloc(npages * PAGE_SIZE, KM_SLEEP);
    304 	pgri->pgr_npages = npages;
    305 	pgri->pgr_pgs = kmem_alloc(sizeof(struct vm_page *) * npages, KM_SLEEP);
    306 	pgri->pgr_read = (flags & UVMPAGER_MAPIN_READ) != 0;
    307 
    308 	/* copy contents to "mapped" memory */
    309 	for (i = 0, curkva = pgri->pgr_kva;
    310 	    i < npages;
    311 	    i++, curkva += PAGE_SIZE) {
    312 		/*
    313 		 * We need to copy the previous contents of the pages to
    314 		 * the window even if we are reading from the
    315 		 * device, since the device might not fill the contents of
    316 		 * the full mapped range and we will end up corrupting
    317 		 * data when we unmap the window.
    318 		 */
    319 		memcpy((void*)curkva, pgs[i]->uanon, PAGE_SIZE);
    320 		pgri->pgr_pgs[i] = pgs[i];
    321 	}
    322 
    323 	mutex_enter(&pagermtx);
    324 	LIST_INSERT_HEAD(&pagerlist, pgri, pgr_entries);
    325 	mutex_exit(&pagermtx);
    326 
    327 	return pgri->pgr_kva;
    328 }
    329 
    330 /*
    331  * map out the pager window.  return contents from VA to page storage
    332  * and free structures.
    333  *
    334  * Note: does not currently support partial frees
    335  */
    336 void
    337 uvm_pagermapout(vaddr_t kva, int npages)
    338 {
    339 	struct pagerinfo *pgri;
    340 	vaddr_t curkva;
    341 	int i;
    342 
    343 	mutex_enter(&pagermtx);
    344 	LIST_FOREACH(pgri, &pagerlist, pgr_entries) {
    345 		if (pgri->pgr_kva == kva)
    346 			break;
    347 	}
    348 	KASSERT(pgri);
    349 	if (pgri->pgr_npages != npages)
    350 		panic("uvm_pagermapout: partial unmapping not supported");
    351 	LIST_REMOVE(pgri, pgr_entries);
    352 	mutex_exit(&pagermtx);
    353 
    354 	if (pgri->pgr_read) {
    355 		for (i = 0, curkva = pgri->pgr_kva;
    356 		    i < pgri->pgr_npages;
    357 		    i++, curkva += PAGE_SIZE) {
    358 			memcpy(pgri->pgr_pgs[i]->uanon,(void*)curkva,PAGE_SIZE);
    359 		}
    360 	}
    361 
    362 	kmem_free(pgri->pgr_pgs, npages * sizeof(struct vm_page *));
    363 	kmem_free((void*)pgri->pgr_kva, npages * PAGE_SIZE);
    364 	kmem_free(pgri, sizeof(*pgri));
    365 }
    366 
    367 /*
    368  * convert va in pager window to page structure.
    369  * XXX: how expensive is this (global lock, list traversal)?
    370  */
    371 struct vm_page *
    372 uvm_pageratop(vaddr_t va)
    373 {
    374 	struct pagerinfo *pgri;
    375 	struct vm_page *pg = NULL;
    376 	int i;
    377 
    378 	mutex_enter(&pagermtx);
    379 	LIST_FOREACH(pgri, &pagerlist, pgr_entries) {
    380 		if (pgri->pgr_kva <= va
    381 		    && va < pgri->pgr_kva + pgri->pgr_npages*PAGE_SIZE)
    382 			break;
    383 	}
    384 	if (pgri) {
    385 		i = (va - pgri->pgr_kva) >> PAGE_SHIFT;
    386 		pg = pgri->pgr_pgs[i];
    387 	}
    388 	mutex_exit(&pagermtx);
    389 
    390 	return pg;
    391 }
    392 
    393 /* Called with the vm object locked */
    394 struct vm_page *
    395 uvm_pagelookup(struct uvm_object *uobj, voff_t off)
    396 {
    397 
    398 	return (struct vm_page *)rb_tree_find_node(&uobj->rb_tree, &off);
    399 }
    400 
    401 void
    402 uvm_page_unbusy(struct vm_page **pgs, int npgs)
    403 {
    404 	struct vm_page *pg;
    405 	int i;
    406 
    407 	for (i = 0; i < npgs; i++) {
    408 		pg = pgs[i];
    409 		if (pg == NULL)
    410 			continue;
    411 
    412 		KASSERT(pg->flags & PG_BUSY);
    413 		if (pg->flags & PG_WANTED)
    414 			wakeup(pg);
    415 		if (pg->flags & PG_RELEASED)
    416 			uvm_pagefree(pg);
    417 		else
    418 			pg->flags &= ~(PG_WANTED|PG_BUSY);
    419 	}
    420 }
    421 
    422 void
    423 uvm_estimatepageable(int *active, int *inactive)
    424 {
    425 
    426 	/* XXX: guessing game */
    427 	*active = 1024;
    428 	*inactive = 1024;
    429 }
    430 
    431 struct vm_map_kernel *
    432 vm_map_to_kernel(struct vm_map *map)
    433 {
    434 
    435 	return (struct vm_map_kernel *)map;
    436 }
    437 
    438 bool
    439 vm_map_starved_p(struct vm_map *map)
    440 {
    441 
    442 	if (map->flags & VM_MAP_WANTVA)
    443 		return true;
    444 
    445 	return false;
    446 }
    447 
    448 int
    449 uvm_loan(struct vm_map *map, vaddr_t start, vsize_t len, void *v, int flags)
    450 {
    451 
    452 	panic("%s: unimplemented", __func__);
    453 }
    454 
    455 void
    456 uvm_unloan(void *v, int npages, int flags)
    457 {
    458 
    459 	panic("%s: unimplemented", __func__);
    460 }
    461 
    462 int
    463 uvm_loanuobjpages(struct uvm_object *uobj, voff_t pgoff, int orignpages,
    464 	struct vm_page **opp)
    465 {
    466 
    467 	return EBUSY;
    468 }
    469 
    470 #ifdef DEBUGPRINT
    471 void
    472 uvm_object_printit(struct uvm_object *uobj, bool full,
    473 	void (*pr)(const char *, ...))
    474 {
    475 
    476 	pr("VM OBJECT at %p, refs %d", uobj, uobj->uo_refs);
    477 }
    478 #endif
    479 
    480 vaddr_t
    481 uvm_default_mapaddr(struct proc *p, vaddr_t base, vsize_t sz)
    482 {
    483 
    484 	return 0;
    485 }
    486 
    487 int
    488 uvm_map_protect(struct vm_map *map, vaddr_t start, vaddr_t end,
    489 	vm_prot_t prot, bool set_max)
    490 {
    491 
    492 	return EOPNOTSUPP;
    493 }
    494 
    495 /*
    496  * UVM km
    497  */
    498 
    499 vaddr_t
    500 uvm_km_alloc(struct vm_map *map, vsize_t size, vsize_t align, uvm_flag_t flags)
    501 {
    502 	void *rv, *desired = NULL;
    503 	int alignbit, error;
    504 
    505 #ifdef __x86_64__
    506 	/*
    507 	 * On amd64, allocate all module memory from the lowest 2GB.
    508 	 * This is because NetBSD kernel modules are compiled
    509 	 * with -mcmodel=kernel and reserve only 4 bytes for
    510 	 * offsets.  If we load code compiled with -mcmodel=kernel
    511 	 * anywhere except the lowest or highest 2GB, it will not
    512 	 * work.  Since userspace does not have access to the highest
    513 	 * 2GB, use the lowest 2GB.
    514 	 *
    515 	 * Note: this assumes the rump kernel resides in
    516 	 * the lowest 2GB as well.
    517 	 *
    518 	 * Note2: yes, it's a quick hack, but since this the only
    519 	 * place where we care about the map we're allocating from,
    520 	 * just use a simple "if" instead of coming up with a fancy
    521 	 * generic solution.
    522 	 */
    523 	extern struct vm_map *module_map;
    524 	if (map == module_map) {
    525 		desired = (void *)(0x80000000 - size);
    526 	}
    527 #endif
    528 
    529 	alignbit = 0;
    530 	if (align) {
    531 		alignbit = ffs(align)-1;
    532 	}
    533 
    534 	rv = rumpuser_anonmmap(desired, size, alignbit, flags & UVM_KMF_EXEC,
    535 	    &error);
    536 	if (rv == NULL) {
    537 		if (flags & (UVM_KMF_CANFAIL | UVM_KMF_NOWAIT))
    538 			return 0;
    539 		else
    540 			panic("uvm_km_alloc failed");
    541 	}
    542 
    543 	if (flags & UVM_KMF_ZERO)
    544 		memset(rv, 0, size);
    545 
    546 	return (vaddr_t)rv;
    547 }
    548 
    549 void
    550 uvm_km_free(struct vm_map *map, vaddr_t vaddr, vsize_t size, uvm_flag_t flags)
    551 {
    552 
    553 	rumpuser_unmap((void *)vaddr, size);
    554 }
    555 
    556 struct vm_map *
    557 uvm_km_suballoc(struct vm_map *map, vaddr_t *minaddr, vaddr_t *maxaddr,
    558 	vsize_t size, int pageable, bool fixed, struct vm_map_kernel *submap)
    559 {
    560 
    561 	return (struct vm_map *)417416;
    562 }
    563 
    564 vaddr_t
    565 uvm_km_alloc_poolpage(struct vm_map *map, bool waitok)
    566 {
    567 
    568 	return (vaddr_t)rump_hypermalloc(PAGE_SIZE, PAGE_SIZE,
    569 	    waitok, "kmalloc");
    570 }
    571 
    572 void
    573 uvm_km_free_poolpage(struct vm_map *map, vaddr_t addr)
    574 {
    575 
    576 	rump_hyperfree((void *)addr, PAGE_SIZE);
    577 }
    578 
    579 vaddr_t
    580 uvm_km_alloc_poolpage_cache(struct vm_map *map, bool waitok)
    581 {
    582 
    583 	return uvm_km_alloc_poolpage(map, waitok);
    584 }
    585 
    586 void
    587 uvm_km_free_poolpage_cache(struct vm_map *map, vaddr_t vaddr)
    588 {
    589 
    590 	uvm_km_free_poolpage(map, vaddr);
    591 }
    592 
    593 void
    594 uvm_km_va_drain(struct vm_map *map, uvm_flag_t flags)
    595 {
    596 
    597 	/* we eventually maybe want some model for available memory */
    598 }
    599 
    600 /*
    601  * Mapping and vm space locking routines.
    602  * XXX: these don't work for non-local vmspaces
    603  */
    604 int
    605 uvm_vslock(struct vmspace *vs, void *addr, size_t len, vm_prot_t access)
    606 {
    607 
    608 	KASSERT(vs == &vmspace0);
    609 	return 0;
    610 }
    611 
    612 void
    613 uvm_vsunlock(struct vmspace *vs, void *addr, size_t len)
    614 {
    615 
    616 	KASSERT(vs == &vmspace0);
    617 }
    618 
    619 void
    620 vmapbuf(struct buf *bp, vsize_t len)
    621 {
    622 
    623 	bp->b_saveaddr = bp->b_data;
    624 }
    625 
    626 void
    627 vunmapbuf(struct buf *bp, vsize_t len)
    628 {
    629 
    630 	bp->b_data = bp->b_saveaddr;
    631 	bp->b_saveaddr = 0;
    632 }
    633 
    634 void
    635 uvmspace_addref(struct vmspace *vm)
    636 {
    637 
    638 	/*
    639 	 * there is only vmspace0.  we're not planning on
    640 	 * feeding it to the fishes.
    641 	 */
    642 }
    643 
    644 void
    645 uvmspace_free(struct vmspace *vm)
    646 {
    647 
    648 	/* nothing for now */
    649 }
    650 
    651 int
    652 uvm_io(struct vm_map *map, struct uio *uio)
    653 {
    654 
    655 	/*
    656 	 * just do direct uio for now.  but this needs some vmspace
    657 	 * olympics for rump_sysproxy.
    658 	 */
    659 	return uiomove((void *)(vaddr_t)uio->uio_offset, uio->uio_resid, uio);
    660 }
    661 
    662 /*
    663  * page life cycle stuff.  it really doesn't exist, so just stubs.
    664  */
    665 
    666 void
    667 uvm_pageactivate(struct vm_page *pg)
    668 {
    669 
    670 	/* nada */
    671 }
    672 
    673 void
    674 uvm_pagedeactivate(struct vm_page *pg)
    675 {
    676 
    677 	/* nada */
    678 }
    679 
    680 void
    681 uvm_pagedequeue(struct vm_page *pg)
    682 {
    683 
    684 	/* nada*/
    685 }
    686 
    687 void
    688 uvm_pageenqueue(struct vm_page *pg)
    689 {
    690 
    691 	/* nada */
    692 }
    693 
    694 void
    695 uvmpdpol_anfree(struct vm_anon *an)
    696 {
    697 
    698 	/* nada */
    699 }
    700 
    701 /*
    702  * Routines related to the Page Baroness.
    703  */
    704 
    705 void
    706 uvm_wait(const char *msg)
    707 {
    708 
    709 	if (__predict_false(curlwp == uvm.pagedaemon_lwp))
    710 		panic("pagedaemon out of memory");
    711 	if (__predict_false(rump_threads == 0))
    712 		panic("pagedaemon missing (RUMP_THREADS = 0)");
    713 
    714 	mutex_enter(&pdaemonmtx);
    715 	pdaemon_waiters++;
    716 	cv_signal(&pdaemoncv);
    717 	cv_wait(&oomwait, &pdaemonmtx);
    718 	mutex_exit(&pdaemonmtx);
    719 }
    720 
    721 void
    722 uvm_pageout_start(int npages)
    723 {
    724 
    725 	/* we don't have the heuristics */
    726 }
    727 
    728 void
    729 uvm_pageout_done(int npages)
    730 {
    731 
    732 	/* could wakeup waiters, but just let the pagedaemon do it */
    733 }
    734 
    735 /*
    736  * Under-construction page mistress.  This is lacking vfs support, namely:
    737  *
    738  *  1) draining vfs buffers
    739  *  2) paging out pages in vm vnode objects
    740  *     (we will not page out anon memory on the basis that
    741  *     that's the task of the host)
    742  */
    743 
    744 void
    745 uvm_pageout(void *arg)
    746 {
    747 	struct pool *pp, *pp_first;
    748 	uint64_t where;
    749 	int timo = 0;
    750 	bool succ;
    751 
    752 	mutex_enter(&pdaemonmtx);
    753 	for (;;) {
    754 		cv_timedwait(&pdaemoncv, &pdaemonmtx, timo);
    755 		uvmexp.pdwoke++;
    756 		kernel_map->flags |= VM_MAP_WANTVA;
    757 		mutex_exit(&pdaemonmtx);
    758 
    759 		succ = false;
    760 		pool_drain_start(&pp_first, &where);
    761 		pp = pp_first;
    762 		for (;;) {
    763 			succ = pool_drain_end(pp, where);
    764 			if (succ)
    765 				break;
    766 			pool_drain_start(&pp, &where);
    767 			if (pp == pp_first) {
    768 				succ = pool_drain_end(pp, where);
    769 				break;
    770 			}
    771 		}
    772 		mutex_enter(&pdaemonmtx);
    773 
    774 		if (!succ) {
    775 			rumpuser_dprintf("pagedaemoness: failed to reclaim "
    776 			    "memory ... sleeping (deadlock?)\n");
    777 			timo = hz;
    778 			continue;
    779 		}
    780 		kernel_map->flags &= ~VM_MAP_WANTVA;
    781 		timo = 0;
    782 
    783 		if (pdaemon_waiters) {
    784 			pdaemon_waiters = 0;
    785 			cv_broadcast(&oomwait);
    786 		}
    787 	}
    788 
    789 	panic("you can swap out any time you like, but you can never leave");
    790 }
    791 
    792 /*
    793  * In a regular kernel the pagedaemon is activated when memory becomes
    794  * low.  In a virtual rump kernel we do not know exactly how much memory
    795  * we have available -- it depends on the conditions on the host.
    796  * Therefore, we cannot preemptively kick the pagedaemon.  Rather, we
    797  * wait until things we desperate and we're forced to uvm_wait().
    798  *
    799  * The alternative would be to allocate a huge chunk of memory at
    800  * startup, but that solution has a number of problems including
    801  * being a resource hog, failing anyway due to host memory overcommit
    802  * and core dump size.
    803  */
    804 
    805 void
    806 uvm_kick_pdaemon()
    807 {
    808 
    809 	/* nada */
    810 }
    811 
    812 void *
    813 rump_hypermalloc(size_t howmuch, int alignment, bool waitok, const char *wmsg)
    814 {
    815 	unsigned long newmem;
    816 	void *rv;
    817 
    818 	/* first we must be within the limit */
    819  limitagain:
    820 	if (physmemlimit != RUMPMEM_UNLIMITED) {
    821 		newmem = atomic_add_long_nv(&curphysmem, howmuch);
    822 		if (newmem > physmemlimit) {
    823 			newmem = atomic_add_long_nv(&curphysmem, -howmuch);
    824 			if (!waitok)
    825 				return NULL;
    826 			uvm_wait(wmsg);
    827 			goto limitagain;
    828 		}
    829 	}
    830 
    831 	/* second, we must get something from the backend */
    832  again:
    833 	rv = rumpuser_malloc(howmuch, alignment);
    834 	if (__predict_false(rv == NULL && waitok)) {
    835 		uvm_wait(wmsg);
    836 		goto again;
    837 	}
    838 
    839 	return rv;
    840 }
    841 
    842 void
    843 rump_hyperfree(void *what, size_t size)
    844 {
    845 
    846 	if (physmemlimit != RUMPMEM_UNLIMITED) {
    847 		atomic_add_long(&curphysmem, -size);
    848 	}
    849 	rumpuser_free(what);
    850 }
    851