Module Name: src
Committed By: reinoud
Date: Tue Aug 30 10:58:42 UTC 2011
Modified Files:
src/sys/arch/usermode/usermode: pmap.c
Log Message:
Implement pmap_clear_modify() and pmap_is_modified()
To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/usermode/usermode/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/usermode/usermode/pmap.c
diff -u src/sys/arch/usermode/usermode/pmap.c:1.42 src/sys/arch/usermode/usermode/pmap.c:1.43
--- src/sys/arch/usermode/usermode/pmap.c:1.42 Tue Aug 30 10:44:06 2011
+++ src/sys/arch/usermode/usermode/pmap.c Tue Aug 30 10:58:41 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.42 2011/08/30 10:44:06 reinoud Exp $ */
+/* $NetBSD: pmap.c,v 1.43 2011/08/30 10:58:41 reinoud Exp $ */
/*-
* Copyright (c) 2011 Reinoud Zandijk <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.42 2011/08/30 10:44:06 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.43 2011/08/30 10:58:41 reinoud Exp $");
#include "opt_memsize.h"
#include "opt_kmempages.h"
@@ -832,10 +832,29 @@
}
bool
-pmap_clear_modify(struct vm_page *pg)
+pmap_clear_modify(struct vm_page *page)
{
-aprint_debug("pmap_clear_modify not implemented\n");
- return true;
+ struct pv_entry *pv;
+ uintptr_t ppn;
+ bool rv;
+
+ ppn = atop(VM_PAGE_TO_PHYS(page));
+ rv = pmap_is_modified(page);
+
+ aprint_debug("pmap_clear_modify page %"PRIiPTR"\n", ppn);
+
+ /* if marked modified, clear it in all the pmap's referencing it */
+ if (rv) {
+ /* if its marked modified in a kernel mapping, don't clear it */
+ for (pv = &pv_table[ppn]; pv != NULL; pv = pv->pv_next)
+ if (pv->pv_pmap == pmap_kernel() &&
+ (pv->pv_prot & VM_PROT_WRITE))
+ return rv;
+ /* clear it */
+ pv_table[ppn].pv_pflags &= ~PV_MODIFIED;
+ pmap_update_page(ppn);
+ }
+ return rv;
}
bool
@@ -846,10 +865,17 @@
}
bool
-pmap_is_modified(struct vm_page *pg)
+pmap_is_modified(struct vm_page *page)
{
-aprint_debug("pmap_is_modified not implemented\n");
- return false;
+ intptr_t ppn;
+ bool rv;
+
+ ppn = atop(VM_PAGE_TO_PHYS(page));
+ rv = (pv_table[ppn].pv_pflags & PV_MODIFIED) != 0;
+
+ aprint_debug("pmap_is_modified page %"PRIiPTR" : %s\n", ppn, rv?"yes":"no");
+
+ return rv;
}
bool