From f9b44a6d571da0f740c05fdeb9508467a43bc600 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 17 May 2012 16:20:19 +0000 Subject: [PATCH] Add support for PMAP_GROWKERNEL --- sys/common/pmap/tlb/pmap.c | 48 ++++++++++++++++++++++++++------------ sys/common/pmap/tlb/pmap.h | 3 ++- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/sys/common/pmap/tlb/pmap.c b/sys/common/pmap/tlb/pmap.c index 5462c1f867a0..b378d907fcf3 100644 --- a/sys/common/pmap/tlb/pmap.c +++ b/sys/common/pmap/tlb/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.12 2012/01/18 07:17:09 skrll Exp $ */ +/* $NetBSD: pmap.c,v 1.13 2012/05/17 16:20:19 matt Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.12 2012/01/18 07:17:09 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.13 2012/05/17 16:20:19 matt Exp $"); /* * Manages physical address maps. @@ -220,15 +220,6 @@ struct pmap * const kernel_pmap_ptr = &kernel_pmap_store.kernel_pmap; struct pmap_limits pmap_limits; -#ifdef PMAP_POOLPAGE_DEBUG -struct poolpage_info { - vaddr_t base; - vaddr_t size; - vaddr_t hint; - pt_entry_t *sysmap; -} poolpage; -#endif - #ifdef UVMHIST static struct kern_history_ent pmapexechistbuf[10000]; static struct kern_history_ent pmaphistbuf[10000]; @@ -348,8 +339,34 @@ void pmap_virtual_space(vaddr_t *vstartp, vaddr_t *vendp) { - *vstartp = VM_MIN_KERNEL_ADDRESS; /* kernel is in K0SEG */ - *vendp = trunc_page(pmap_limits.virtual_end); /* XXX need pmap_growkernel() */ + *vstartp = VM_MIN_KERNEL_ADDRESS; + *vendp = VM_MAX_KERNEL_ADDRESS; +} + +vaddr_t +pmap_growkernel(vaddr_t maxkvaddr) +{ + vaddr_t virtual_end = pmap_limits.virtual_end; + maxkvaddr = pmap_round_seg(maxkvaddr) - 1; + + /* + * Reserve PTEs for the new KVA space. + */ + for (; virtual_end < maxkvaddr; virtual_end += NBSEG) { + pmap_pte_reserve(pmap_kernel(), virtual_end, 0); + } + + /* + * Don't exceed VM_MAX_KERNEL_ADDRESS! + */ + if (virtual_end == 0 || virtual_end > VM_MAX_KERNEL_ADDRESS) + virtual_end = VM_MAX_KERNEL_ADDRESS; + + /* + * Update new end. + */ + pmap_limits.virtual_end = virtual_end; + return virtual_end; } /* @@ -414,7 +431,7 @@ pmap_steal_memory(vsize_t size, vaddr_t *vstartp, vaddr_t *vendp) sizeof(*seg) * (vm_nphysseg - bank)); } - va = pmap_md_direct_map_paddr(pa); + va = pmap_md_map_poolpage(pa, size); memset((void *)va, 0, size); return va; } @@ -1828,7 +1845,7 @@ pmap_map_poolpage(paddr_t pa) struct vm_page_md * const mdpg = VM_PAGE_TO_MD(pg); pmap_page_set_attributes(mdpg, VM_PAGEMD_POOLPAGE); - const vaddr_t va = pmap_md_direct_map_paddr(pa); + const vaddr_t va = pmap_md_map_poolpage(pa, NBPG); pmap_md_vca_add(pg, va, NULL); return va; } @@ -1844,6 +1861,7 @@ pmap_unmap_poolpage(vaddr_t va) KASSERT(pg); struct vm_page_md * const mdpg = VM_PAGE_TO_MD(pg); pmap_page_clear_attributes(mdpg, VM_PAGEMD_POOLPAGE); + pmap_md_unmap_poolpage(va, NBPG); pmap_md_vca_remove(pg, va); return pa; diff --git a/sys/common/pmap/tlb/pmap.h b/sys/common/pmap/tlb/pmap.h index 0fffce8a4478..177304cdfb15 100644 --- a/sys/common/pmap/tlb/pmap.h +++ b/sys/common/pmap/tlb/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.11 2011/10/13 19:50:39 matt Exp $ */ +/* $NetBSD: pmap.h,v 1.12 2012/05/17 16:20:19 matt Exp $ */ /* * Copyright (c) 1992, 1993 @@ -253,6 +253,7 @@ void pmap_tlb_asid_check(void); uint16_t pmap_pvlist_lock(struct vm_page_md *, bool); #define PMAP_STEAL_MEMORY /* enable pmap_steal_memory() */ +#define PMAP_GROWKERNEL /* enable pmap_growkernel() */ /* * Alternate mapping hooks for pool pages. Avoids thrashing the TLB.