--- mips/include/pmap.h (revision 187146) +++ mips/include/pmap.h (local) @@ -47,9 +47,53 @@ #define _MACHINE_PMAP_H_ #include +#include /* - * Pte related macros + * Copyright (c) 1987 Carnegie-Mellon University + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Derived from hp300 version by Mike Hibler, this version by William + * Jolitz uses a recursive map [a pde points to the page directory] to + * map the page tables using the pagetables themselves. This is done to + * reduce the impact on kernel virtual memory for lots of sparse address + * space, and to reduce the cost of memory to each process. + * + * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 + * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 + * from: src/sys/i386/include/pmap.h,v 1.65.2.2 2000/11/30 01:54:42 peter + * JNPR: pmap.h,v 1.7.2.1 2007/09/10 07:44:12 + * $FreeBSD: src/sys/mips/include/pmap.h,v 1.3 2008/04/30 06:05:36 alc Exp $ */ #define VADDR(pdi, pti) ((vm_offset_t)(((pdi)< -#include #include #include - /* * Pmap stuff */ @@ -104,10 +146,7 @@ typedef struct pmap *pmap_t; -#ifdef _KERNEL -#include -#include -#include +#ifdef _KERNEL pt_entry_t *pmap_pte(pmap_t, vm_offset_t); pd_entry_t pmap_segmap(pmap_t pmap, vm_offset_t va); @@ -132,8 +171,6 @@ #define PMAP_LGMEM_UNLOCK(sysmap) mtx_unlock(&(sysmap)->lock) #define PMAP_LGMEM_DESTROY(sysmap) mtx_destroy(&(sysmap)->lock) -#endif /* _KERNEL */ - /* * For each vm_page_t, there is a list of all currently valid virtual * mappings of that page. An entry is a pv_entry_t, the list is pv_table. @@ -148,8 +185,6 @@ } *pv_entry_t; -#ifdef _KERNEL - #if defined(DIAGNOSTIC) #define PMAP_DIAGNOSTIC #endif @@ -182,7 +217,6 @@ void pmap_set_modified(vm_offset_t pa); int page_is_managed(vm_offset_t pa); void pmap_page_is_free(vm_page_t m); -void pmap_kushmem_reattach(struct proc *); /* PMAP_INLINE */ void pmap_kenter(vm_offset_t va, vm_paddr_t pa); /* PMAP_INLINE */ void pmap_kremove(vm_offset_t va); void *pmap_kenter_temporary(vm_paddr_t pa, int i); --- mips/mips/pmap.c (revision 187146) +++ mips/mips/pmap.c (local) @@ -103,6 +103,8 @@ #define PMAP_DIAGNOSTIC #endif +#undef PMAP_DEBUG + #ifndef PMAP_SHPGPERPROC #define PMAP_SHPGPERPROC 200 #endif @@ -489,6 +491,24 @@ #endif +/* + * this routine defines the region(s) of memory that should + * not be tested for the modified bit. + */ +static PMAP_INLINE int +pmap_track_modified(vm_offset_t va) +{ + /* + * Kernel submap initialization has been moved for MD to MI code. ie + * from cpu_startup() to vm_ksubmap_init(). clean_sva and clean_eva + * are part of the kmi structure. + */ + if ((va < kmi.clean_sva) || (va >= kmi.clean_eva)) + return (1); + else + return (0); +} + static void pmap_invalidate_all(pmap_t pmap) { @@ -672,6 +692,9 @@ register pt_entry_t *pte; pt_entry_t npte, opte; +#ifdef PMAP_DEBUG + printf("pmap_kenter: va: 0x%08x -> pa: 0x%08x\n", va, pa); +#endif npte = mips_paddr_to_tlbpfn(pa) | PTE_RW | PTE_V | PTE_G | PTE_W; if (is_cacheable_mem(pa)) @@ -1421,7 +1444,8 @@ va, oldpte); } #endif - vm_page_dirty(m); + if (pmap_track_modified(va)) + vm_page_dirty(m); } if (m->md.pv_flags & PV_TABLE_REF) vm_page_flag_set(m, PG_REFERENCED); @@ -1778,6 +1802,9 @@ validate: rw = init_pte_prot(va, m, prot); +#ifdef PMAP_DEBUG + printf("pmap_enter: va: 0x%08x -> pa: 0x%08x\n", va, pa); +#endif /* * Now validate mapping with desired protection/wiring. */ @@ -2147,9 +2174,10 @@ #endif if (phys < MIPS_KSEG0_LARGEST_PHYS) { - va = MIPS_PHYS_TO_CACHED(phys); + va = MIPS_PHYS_TO_UNCACHED(phys); bzero((caddr_t)va, PAGE_SIZE); + mips_dcache_wbinv_range(va, PAGE_SIZE); } else { int cpu; struct local_sysmaps *sysm; @@ -2202,8 +2230,9 @@ } else #endif if (phys < MIPS_KSEG0_LARGEST_PHYS) { - va = MIPS_PHYS_TO_CACHED(phys); + va = MIPS_PHYS_TO_UNCACHED(phys); bzero((char *)(caddr_t)va + off, size); + mips_dcache_wbinv_range(va + off, size); } else { int cpu; struct local_sysmaps *sysm; @@ -2240,8 +2269,9 @@ } else #endif if (phys < MIPS_KSEG0_LARGEST_PHYS) { - va = MIPS_PHYS_TO_CACHED(phys); + va = MIPS_PHYS_TO_UNCACHED(phys); bzero((caddr_t)va, PAGE_SIZE); + mips_dcache_wbinv_range(va, PAGE_SIZE); } else { int cpu; struct local_sysmaps *sysm;