Module Name: src
Committed By: matt
Date: Thu Apr 8 16:05:31 UTC 2010
Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: pmap.c
Log Message:
Fix problem where pmap_clear_modify could go into an infinite loop.
Spotted by cyber.
To generate a diff of this commit:
cvs rdiff -u -r1.179.16.22 -r1.179.16.23 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.22 src/sys/arch/mips/mips/pmap.c:1.179.16.23
--- src/sys/arch/mips/mips/pmap.c:1.179.16.22 Thu Mar 11 08:19:01 2010
+++ src/sys/arch/mips/mips/pmap.c Thu Apr 8 16:05:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.179.16.22 2010/03/11 08:19:01 matt Exp $ */
+/* $NetBSD: pmap.c,v 1.179.16.23 2010/04/08 16:05:31 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.22 2010/03/11 08:19:01 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.179.16.23 2010/04/08 16:05:31 matt Exp $");
/*
* Manages physical address maps.
@@ -1886,7 +1886,8 @@
bool
pmap_clear_modify(struct vm_page *pg)
{
- struct pv_entry *pv = &pg->mdpage.pvh_first;
+ pv_entry_t pv = &pg->mdpage.pvh_first;
+ pv_entry_t pv_next;
uint16_t gen;
PMAP_COUNT(clear_modify);
@@ -1916,11 +1917,12 @@
*/
kpreempt_disable();
gen = VM_PAGE_PVLIST_LOCK(pg, false);
- while (pv != NULL) {
+ for (; pv != NULL; pv = pv_next) {
pmap_t pmap = pv->pv_pmap;
vaddr_t va = pv->pv_va;
pt_entry_t *pte;
uint32_t pt_entry;
+ pv_next = pv->pv_next;
if (pmap == pmap_kernel()) {
pte = kvtopte(va);
} else {
@@ -1946,13 +1948,11 @@
VM_PAGE_PVLIST_UNLOCK(pg);
pmap_tlb_invalidate_addr(pmap, va);
pmap_update(pmap);
- if (gen != VM_PAGE_PVLIST_LOCK(pg, false)) {
+ if (__predict_false(gen != VM_PAGE_PVLIST_LOCK(pg, false))) {
/*
* The list changed! So restart from the beginning.
*/
- pv = &pg->mdpage.pvh_first;
- } else {
- pv = pv->pv_next;
+ pv_next = &pg->mdpage.pvh_first;
}
}
VM_PAGE_PVLIST_UNLOCK(pg);