Module Name: src Committed By: matt Date: Wed Feb 24 00:09:04 UTC 2010
Modified Files: src/sys/arch/mips/mips [matt-nb5-mips64]: pmap.c Log Message: Fix bug because of typo: "if (foo); something" is not the same as "if (foo) something". Add some more KASSERTs (used to find the bug). To generate a diff of this commit: cvs rdiff -u -r1.179.16.16 -r1.179.16.17 src/sys/arch/mips/mips/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/mips/mips/pmap.c diff -u src/sys/arch/mips/mips/pmap.c:1.179.16.16 src/sys/arch/mips/mips/pmap.c:1.179.16.17 --- src/sys/arch/mips/mips/pmap.c:1.179.16.16 Tue Feb 23 20:33:48 2010 +++ src/sys/arch/mips/mips/pmap.c Wed Feb 24 00:09:04 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.179.16.16 2010/02/23 20:33:48 matt Exp $ */ +/* $NetBSD: pmap.c,v 1.179.16.17 2010/02/24 00:09:04 matt Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.179.16.16 2010/02/23 20:33:48 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.179.16.17 2010/02/24 00:09:04 matt Exp $"); /* * Manages physical address maps. @@ -412,7 +412,7 @@ if (PG_MD_CACHED_P(pg) && mips_cache_badalias(pv->pv_va, va)) mips_dcache_wbinv_range_index(pv->pv_va, PAGE_SIZE); - if (pv->pv_pmap == NULL); + if (pv->pv_pmap == NULL) pv->pv_va = va; VM_PAGE_PVLIST_UNLOCK(pg); } @@ -1236,6 +1236,11 @@ uint32_t pt_entry; KASSERT(pmap != NULL); + KASSERT(!MIPS_KSEG0_P(va)); + KASSERT(!MIPS_KSEG1_P(va)); +#ifdef _LP64 + KASSERT(!MIPS_XKPHYS_P(va)); +#endif if (pmap == pmap_kernel()) { /* * Change entries in kernel pmap. @@ -1940,6 +1945,24 @@ /******************** pv_entry management ********************/ +static void +pmap_check_pvlist(struct vm_page *pg) +{ +#ifdef PARANIOADIAG + pt_entry_t pv = &pg->mdpage.pvh_first; + if (pv->pv_pmap != NULL) { + for (; pv != NULL; pv = pv->pv_next) { + KASSERT(!MIPS_KSEG0_P(pv->pv_va)); + KASSERT(!MIPS_KSEG1_P(pv->pv_va)); +#ifdef _LP64 + KASSERT(!MIPS_XKPHYS_P(pv->pv_va)); +#endif + } + pv = &pg->mdpage.pvh_first; + } +#endif /* PARANOIADIAG */ +} + /* * Enter the pmap and virtual address into the * physical to virtual map table. @@ -1949,6 +1972,12 @@ { pv_entry_t pv, npv, apv; + KASSERT(!MIPS_KSEG0_P(va)); + KASSERT(!MIPS_KSEG1_P(va)); +#ifdef _LP64 + KASSERT(!MIPS_XKPHYS_P(va)); +#endif + apv = NULL; pv = &pg->mdpage.pvh_first; #ifdef DEBUG @@ -1958,6 +1987,7 @@ #endif kpreempt_disable(); (void)VM_PAGE_PVLIST_LOCK(pg, true); + pmap_check_pvlist(pg); #if defined(MIPS3_NO_PV_UNCACHED) || defined(MULTIPROCESSOR) again: #endif @@ -2108,6 +2138,7 @@ pv->pv_next = npv; PMAP_COUNT(mappings); } + pmap_check_pvlist(pg); VM_PAGE_PVLIST_UNLOCK(pg); kpreempt_enable(); if (__predict_false(apv != NULL)) @@ -2136,6 +2167,8 @@ pv = &pg->mdpage.pvh_first; (void)VM_PAGE_PVLIST_LOCK(pg, true); + pmap_check_pvlist(pg); + /* * If it is the first entry on the list, it is actually * in the header and we must copy the following entry up @@ -2148,6 +2181,7 @@ npv = pv->pv_next; if (npv) { *pv = *npv; + KASSERT(pv->pv_pmap != NULL); } else { pmap_clear_page_attributes(pg, PG_MD_UNCACHED); pv->pv_pmap = NULL; @@ -2180,7 +2214,10 @@ pmap_page_cache(pg, true); } #endif + + pmap_check_pvlist(pg); VM_PAGE_PVLIST_UNLOCK(pg); + /* * Free the pv_entry if needed. */