Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode/usermode Implement pmap_clear_modify() and...



details:   https://anonhg.NetBSD.org/src/rev/eed42faaf632
branches:  trunk
changeset: 769024:eed42faaf632
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Tue Aug 30 10:58:41 2011 +0000

description:
Implement pmap_clear_modify() and pmap_is_modified()

diffstat:

 sys/arch/usermode/usermode/pmap.c |  42 +++++++++++++++++++++++++++++++-------
 1 files changed, 34 insertions(+), 8 deletions(-)

diffs (72 lines):

diff -r f6d1ba597c5d -r eed42faaf632 sys/arch/usermode/usermode/pmap.c
--- a/sys/arch/usermode/usermode/pmap.c Tue Aug 30 10:44:06 2011 +0000
+++ b/sys/arch/usermode/usermode/pmap.c Tue Aug 30 10:58:41 2011 +0000
@@ -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 <reinoud%NetBSD.org@localhost>
@@ -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



Home | Main Index | Thread Index | Old Index