Tue Aug 30 10:58:42 2011 UTC ()
Implement pmap_clear_modify() and pmap_is_modified()


(reinoud)
diff -r1.42 -r1.43 src/sys/arch/usermode/usermode/pmap.c

cvs diff -r1.42 -r1.43 src/sys/arch/usermode/usermode/pmap.c (expand / switch to unified diff)

--- src/sys/arch/usermode/usermode/pmap.c 2011/08/30 10:44:06 1.42
+++ src/sys/arch/usermode/usermode/pmap.c 2011/08/30 10:58:41 1.43
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap.c,v 1.42 2011/08/30 10:44:06 reinoud Exp $ */ 1/* $NetBSD: pmap.c,v 1.43 2011/08/30 10:58:41 reinoud Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Reinoud Zandijk <reinoud@NetBSD.org> 4 * Copyright (c) 2011 Reinoud Zandijk <reinoud@NetBSD.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.42 2011/08/30 10:44:06 reinoud Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.43 2011/08/30 10:58:41 reinoud Exp $");
31 31
32#include "opt_memsize.h" 32#include "opt_memsize.h"
33#include "opt_kmempages.h" 33#include "opt_kmempages.h"
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/mutex.h> 37#include <sys/mutex.h>
38#include <sys/buf.h> 38#include <sys/buf.h>
39#include <sys/malloc.h> 39#include <sys/malloc.h>
40#include <sys/pool.h> 40#include <sys/pool.h>
41#include <machine/thunk.h> 41#include <machine/thunk.h>
42 42
43#include <uvm/uvm.h> 43#include <uvm/uvm.h>
@@ -822,44 +822,70 @@ pmap_zero_page(paddr_t pa) @@ -822,44 +822,70 @@ pmap_zero_page(paddr_t pa)
822void 822void
823pmap_copy_page(paddr_t src, paddr_t dst) 823pmap_copy_page(paddr_t src, paddr_t dst)
824{ 824{
825aprint_debug("pmap_copy_page not implemented\n"); 825aprint_debug("pmap_copy_page not implemented\n");
826} 826}
827 827
828void 828void
829pmap_page_protect(struct vm_page *pg, vm_prot_t prot) 829pmap_page_protect(struct vm_page *pg, vm_prot_t prot)
830{ 830{
831aprint_debug("pmap_page_protect not implemented\n"); 831aprint_debug("pmap_page_protect not implemented\n");
832} 832}
833 833
834bool 834bool
835pmap_clear_modify(struct vm_page *pg) 835pmap_clear_modify(struct vm_page *page)
836{ 836{
837aprint_debug("pmap_clear_modify not implemented\n"); 837 struct pv_entry *pv;
838 return true; 838 uintptr_t ppn;
 839 bool rv;
 840
 841 ppn = atop(VM_PAGE_TO_PHYS(page));
 842 rv = pmap_is_modified(page);
 843
 844 aprint_debug("pmap_clear_modify page %"PRIiPTR"\n", ppn);
 845
 846 /* if marked modified, clear it in all the pmap's referencing it */
 847 if (rv) {
 848 /* if its marked modified in a kernel mapping, don't clear it */
 849 for (pv = &pv_table[ppn]; pv != NULL; pv = pv->pv_next)
 850 if (pv->pv_pmap == pmap_kernel() &&
 851 (pv->pv_prot & VM_PROT_WRITE))
 852 return rv;
 853 /* clear it */
 854 pv_table[ppn].pv_pflags &= ~PV_MODIFIED;
 855 pmap_update_page(ppn);
 856 }
 857 return rv;
839} 858}
840 859
841bool 860bool
842pmap_clear_reference(struct vm_page *pg) 861pmap_clear_reference(struct vm_page *pg)
843{ 862{
844aprint_debug("pmap_clear_reference not implemented\n"); 863aprint_debug("pmap_clear_reference not implemented\n");
845 return true; 864 return true;
846} 865}
847 866
848bool 867bool
849pmap_is_modified(struct vm_page *pg) 868pmap_is_modified(struct vm_page *page)
850{ 869{
851aprint_debug("pmap_is_modified not implemented\n"); 870 intptr_t ppn;
852 return false; 871 bool rv;
 872
 873 ppn = atop(VM_PAGE_TO_PHYS(page));
 874 rv = (pv_table[ppn].pv_pflags & PV_MODIFIED) != 0;
 875
 876 aprint_debug("pmap_is_modified page %"PRIiPTR" : %s\n", ppn, rv?"yes":"no");
 877
 878 return rv;
853} 879}
854 880
855bool 881bool
856pmap_is_referenced(struct vm_page *pg) 882pmap_is_referenced(struct vm_page *pg)
857{ 883{
858aprint_debug("pmap_is_referenced not implemented\n"); 884aprint_debug("pmap_is_referenced not implemented\n");
859 return false; 885 return false;
860} 886}
861 887
862paddr_t 888paddr_t
863pmap_phys_address(paddr_t cookie) 889pmap_phys_address(paddr_t cookie)
864{ 890{
865 panic("pmap_phys_address not implemented\n"); 891 panic("pmap_phys_address not implemented\n");