diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-06-14 03:04:09 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-06-14 03:04:09 +0000 |
commit | dedeb2b420670c93d16940d6c746f6af87246d7f (patch) | |
tree | e7ede060b9f80cd1289b09a130f22a9e66a3bb62 | |
parent | 000d711134f5ad425653ff4dccc81a69197e51e4 (diff) |
backout:
> extend uvm_page_physload to have the ability to add "device" pages to the
> system.
since it was overlayed over a system that we warned would go "in to be
tested, but may be pulled out". oga, you just made me spend 20 minutes
of time I should not have had to spend doing this.
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 7 | ||||
-rw-r--r-- | sys/uvm/uvm_extern.h | 13 | ||||
-rw-r--r-- | sys/uvm/uvm_page.c | 51 | ||||
-rw-r--r-- | sys/uvm/uvm_page.h | 3 | ||||
-rw-r--r-- | sys/uvm/uvm_pmemrange.c | 4 |
5 files changed, 27 insertions, 51 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 1a836f2838c..4631a8f8c3e 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.94 2009/06/07 02:01:54 oga Exp $ */ +/* $OpenBSD: machdep.c,v 1.95 2009/06/14 03:04:07 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -1713,11 +1713,10 @@ cpu_dump_mempagecnt(void) int amd64_pa_used(paddr_t addr) { - struct vm_page *pg; - bios_memmap_t *bmp; + bios_memmap_t *bmp; /* Kernel manages these */ - if ((pg = PHYS_TO_VM_PAGE(addr)) && (pg->pg_flags & PG_DEV) == 0) + if (PHYS_TO_VM_PAGE(addr)) return 1; /* Kernel is loaded here */ diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h index 1cf804ba3d1..48255c1d8ad 100644 --- a/sys/uvm/uvm_extern.h +++ b/sys/uvm/uvm_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_extern.h,v 1.78 2009/06/07 02:01:54 oga Exp $ */ +/* $OpenBSD: uvm_extern.h,v 1.79 2009/06/14 03:04:08 deraadt Exp $ */ /* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */ /* @@ -235,11 +235,6 @@ typedef int vm_prot_t; #define UVM_LK_EXIT 0x00000002 /* leave map locked on exit */ /* - * flags to uvm_physload. - */ -#define PHYSLOAD_DEVICE 0x01 /* don't add to the page queue */ - -/* * structures */ @@ -575,10 +570,8 @@ vaddr_t uvm_pagealloc_contig(vaddr_t, vaddr_t, void uvm_pagerealloc(struct vm_page *, struct uvm_object *, voff_t); /* Actually, uvm_page_physload takes PF#s which need their own type */ -void uvm_page_physload_flags(paddr_t, paddr_t, paddr_t, - paddr_t, int, int); -#define uvm_page_physload(s, e, as, ae, fl) \ - uvm_page_physload_flags(s, e, as, ae, fl, 0) +void uvm_page_physload(paddr_t, paddr_t, + paddr_t, paddr_t, int); void uvm_setpagesize(void); void uvm_shutdown(void); diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index 41cd30644dc..3758deb58e7 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.87 2009/06/07 02:01:54 oga Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.88 2009/06/14 03:04:08 deraadt Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -73,6 +73,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/malloc.h> #include <sys/sched.h> #include <sys/kernel.h> #include <sys/vnode.h> @@ -572,8 +573,8 @@ uvm_page_physget(paddr_t *paddrp) */ void -uvm_page_physload_flags(paddr_t start, paddr_t end, paddr_t avail_start, - paddr_t avail_end, int free_list, int flags) +uvm_page_physload(paddr_t start, paddr_t end, paddr_t avail_start, + paddr_t avail_end, int free_list) { int preload, lcv; psize_t npages; @@ -615,15 +616,13 @@ uvm_page_physload_flags(paddr_t start, paddr_t end, paddr_t avail_start, * if VM is already running, attempt to malloc() vm_page structures */ if (!preload) { - /* - * XXXCDC: need some sort of lockout for this case - * right now it is only used by devices so it should be alright. - */ +#if defined(VM_PHYSSEG_NOADD) + panic("uvm_page_physload: tried to add RAM after vm_mem_init"); +#else + /* XXXCDC: need some sort of lockout for this case */ paddr_t paddr; - npages = end - start; /* # of pages */ - - pgs = (struct vm_page *)uvm_km_zalloc(kernel_map, + pgs = (vm_page *)uvm_km_zalloc(kernel_map, sizeof(struct vm_page) * npages); if (pgs == NULL) { printf("uvm_page_physload: can not malloc vm_page " @@ -631,31 +630,18 @@ uvm_page_physload_flags(paddr_t start, paddr_t end, paddr_t avail_start, printf("\tignoring 0x%lx -> 0x%lx\n", start, end); return; } - - /* init phys_addr and free pages, XXX uvmexp.npages */ - for (lcv = 0, paddr = ptoa(start); lcv < npages; - lcv++, paddr += PAGE_SIZE) { + /* init phys_addr and free_list, and free pages */ + for (lcv = 0, paddr = ptoa(start) ; + lcv < npages ; lcv++, paddr += PAGE_SIZE) { pgs[lcv].phys_addr = paddr; -#ifdef __HAVE_VM_PAGE_MD - VM_MDPAGE_INIT(&pgs[lcv]); -#endif + pgs[lcv].free_list = free_list; if (atop(paddr) >= avail_start && - atop(paddr) <= avail_end) { - if (flags & PHYSLOAD_DEVICE) { - atomic_setbits_int(&pgs[lcv].pg_flags, - PG_DEV); - pgs[lcv].wire_count = 1; - } else { -#if defined(VM_PHYSSEG_NOADD) - panic("uvm_page_physload: tried to add RAM after vm_mem_init"); -#else - uvm_pagefree(&pgs[lcv]); -#endif - } - } + atop(paddr) <= avail_end) + uvm_pagefree(&pgs[lcv]); } /* XXXCDC: incomplete: need to update uvmexp.free, what else? */ /* XXXCDC: need hook to tell pmap to rebuild pv_list, etc... */ +#endif } else { /* gcc complains if these don't get init'd */ @@ -836,13 +822,15 @@ uvm_pagealloc_strat(struct uvm_object *obj, voff_t off, struct vm_anon *anon, pg->offset = off; pg->uobject = obj; pg->uanon = anon; - KASSERT((pg->pg_flags & PG_DEV) == 0); pg->pg_flags = PG_BUSY|PG_FAKE; if (!(flags & UVM_PGA_ZERO)) atomic_setbits_int(&pg->pg_flags, PG_CLEAN); if (anon) { anon->an_page = pg; atomic_setbits_int(&pg->pg_flags, PQ_ANON); +#ifdef UBC + uvm_pgcnt_anon++; +#endif } else { if (obj) uvm_pageinsert(pg); @@ -920,7 +908,6 @@ uvm_pagefree(struct vm_page *pg) UVMHIST_LOG(pghist, "freeing pg %p/%lx", pg, (u_long)VM_PAGE_TO_PHYS(pg), 0, 0); - KASSERT((pg->pg_flags & PG_DEV) == 0); /* * if the page was an object page (and thus "TABLED"), remove it diff --git a/sys/uvm/uvm_page.h b/sys/uvm/uvm_page.h index 33f39b8d484..e6d71c95ae9 100644 --- a/sys/uvm/uvm_page.h +++ b/sys/uvm/uvm_page.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.h,v 1.35 2009/06/07 02:01:54 oga Exp $ */ +/* $OpenBSD: uvm_page.h,v 1.36 2009/06/14 03:04:08 deraadt Exp $ */ /* $NetBSD: uvm_page.h,v 1.19 2000/12/28 08:24:55 chs Exp $ */ /* @@ -173,7 +173,6 @@ struct vm_page { #define PG_FAKE 0x00000040 /* page is not yet initialized */ #define PG_RDONLY 0x00000080 /* page must be mapped read-only */ #define PG_ZERO 0x00000100 /* page is pre-zero'd */ -#define PG_DEV 0x00000200 /* page is in device space, lay off */ #define PG_PAGER1 0x00001000 /* pager-specific flag */ #define PG_MASK 0x0000ffff diff --git a/sys/uvm/uvm_pmemrange.c b/sys/uvm/uvm_pmemrange.c index 3ea1d7b41c7..d25b780168b 100644 --- a/sys/uvm/uvm_pmemrange.c +++ b/sys/uvm/uvm_pmemrange.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pmemrange.c,v 1.7 2009/06/14 02:20:23 deraadt Exp $ */ +/* $OpenBSD: uvm_pmemrange.c,v 1.8 2009/06/14 03:04:08 deraadt Exp $ */ /* * Copyright (c) 2009 Ariane van der Steldt <ariane@stack.nl> @@ -776,7 +776,6 @@ uvm_pmr_freepages(struct vm_page *pg, psize_t count) uvm_lock_fpageq(); for (i = 0; i < count; i++) { - KASSERT((pg->pg_flags & PG_DEV) == 0); atomic_clearbits_int(&pg[i].pg_flags, pg[i].pg_flags); atomic_setbits_int(&pg[i].pg_flags, PQ_FREE); } @@ -807,7 +806,6 @@ uvm_pmr_freepageq(struct pglist *pgl) struct vm_page *pg; TAILQ_FOREACH(pg, pgl, pageq) { - KASSERT((pg->pg_flags & PG_DEV) == 0); atomic_clearbits_int(&pg->pg_flags, pg->pg_flags); atomic_setbits_int(&pg->pg_flags, PQ_FREE); } |