Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm Support pmap_pv_track and friends



details:   https://anonhg.NetBSD.org/src/rev/11f59bfca86b
branches:  trunk
changeset: 811706:11f59bfca86b
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Nov 11 17:54:17 2015 +0000

description:
Support pmap_pv_track and friends

diffstat:

 sys/arch/arm/arm32/pmap.c         |  49 +++++++++++++++++++++++++++++++++-----
 sys/arch/arm/conf/files.arm       |   5 +++-
 sys/arch/arm/include/arm32/pmap.h |  33 +++++++++++++++++++-------
 3 files changed, 70 insertions(+), 17 deletions(-)

diffs (182 lines):

diff -r cac5e7e30cdc -r 11f59bfca86b sys/arch/arm/arm32/pmap.c
--- a/sys/arch/arm/arm32/pmap.c Wed Nov 11 16:41:52 2015 +0000
+++ b/sys/arch/arm/arm32/pmap.c Wed Nov 11 17:54:17 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.327 2015/11/06 08:44:35 skrll Exp $ */
+/*     $NetBSD: pmap.c,v 1.328 2015/11/11 17:54:17 skrll Exp $ */
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -213,10 +213,11 @@
 #include <sys/kernhist.h>
 
 #include <uvm/uvm.h>
+#include <uvm/pmap/pmap_pvt.h>
 
 #include <arm/locore.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.327 2015/11/06 08:44:35 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.328 2015/11/11 17:54:17 skrll Exp $");
 
 //#define PMAP_DEBUG
 #ifdef PMAP_DEBUG
@@ -757,6 +758,7 @@
 #endif
 #endif
 static void            pmap_page_remove(struct vm_page_md *, paddr_t);
+static void            pmap_pv_remove(paddr_t);
 
 #ifndef ARM_MMU_EXTENDED
 static void            pmap_init_l1(struct l1_ttable *, pd_entry_t *);
@@ -3118,15 +3120,20 @@
                 * If the physical address is different, lookup the
                 * vm_page.
                 */
-               if (l2pte_pa(opte) != pa)
+               if (l2pte_pa(opte) != pa) {
+                       KASSERT(!pmap_pv_tracked(pa));
                        opg = PHYS_TO_VM_PAGE(l2pte_pa(opte));
-               else
+               } else
                        opg = pg;
        } else
                opg = NULL;
 
-       if (pg) {
-               struct vm_page_md *md = VM_PAGE_TO_MD(pg);
+       struct pmap_page *pp = pmap_pv_tracked(pa);
+
+       if (pg || pp) {
+               KASSERT((pg != NULL) != (pp != NULL));
+               struct vm_page_md *md = (pg != NULL) ? VM_PAGE_TO_MD(pg) :
+                   PMAP_PAGE_TO_MD(pp);
 
                /*
                 * This is to be a managed mapping.
@@ -3180,7 +3187,7 @@
                } else
                        npte |= pte_l2_s_cache_mode;
 
-               if (pg == opg) {
+               if (pg != NULL && pg == opg) {
                        /*
                         * We're changing the attrs of an existing mapping.
                         */
@@ -3949,6 +3956,34 @@
        return true;
 }
 
+/*
+ * pmap_pv_remove: remove an unmanaged pv-tracked page from all pmaps
+ *     that map it
+ */
+
+static void
+pmap_pv_remove(paddr_t pa)
+{
+       struct pmap_page *pp;
+
+       pp = pmap_pv_tracked(pa);
+       if (pp == NULL)
+               panic("pmap_pv_protect: page not pv-tracked: 0x%"PRIxPADDR,
+                   pa);
+
+       struct vm_page_md *md = PMAP_PAGE_TO_MD(pp);
+       pmap_page_remove(md, pa);
+}
+
+void
+pmap_pv_protect(paddr_t pa, vm_prot_t prot)
+{
+
+       /* the only case is remove at the moment */
+       KASSERT(prot == VM_PROT_NONE);
+       pmap_pv_remove(pa);
+}
+
 void
 pmap_protect(pmap_t pm, vaddr_t sva, vaddr_t eva, vm_prot_t prot)
 {
diff -r cac5e7e30cdc -r 11f59bfca86b sys/arch/arm/conf/files.arm
--- a/sys/arch/arm/conf/files.arm       Wed Nov 11 16:41:52 2015 +0000
+++ b/sys/arch/arm/conf/files.arm       Wed Nov 11 17:54:17 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.arm,v 1.130 2015/02/07 17:14:32 jmcneill Exp $
+#      $NetBSD: files.arm,v 1.131 2015/11/11 17:54:17 skrll Exp $
 
 # temporary define to allow easy moving to ../arch/arm/arm32
 defflag                                ARM32
@@ -213,6 +213,9 @@
 file   arch/arm/arm32/arm32_tlb.c              (cpu_armv7 | cpu_arm11) & (!arm11_compat_mmu & !cpu_pre_armv6)
 file   uvm/pmap/pmap_tlb.c                     (cpu_armv7 | cpu_arm11) & (!arm11_compat_mmu & !cpu_pre_armv6)
 
+# generic pmap files for arm32 implementations
+file   uvm/pmap/pmap_pvt.c                     arm32
+
 # arm32 library functions
 file   arch/arm/arm32/bcopy_page.S             arm32
 
diff -r cac5e7e30cdc -r 11f59bfca86b sys/arch/arm/include/arm32/pmap.h
--- a/sys/arch/arm/include/arm32/pmap.h Wed Nov 11 16:41:52 2015 +0000
+++ b/sys/arch/arm/include/arm32/pmap.h Wed Nov 11 17:54:17 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.142 2015/09/09 07:37:36 skrll Exp $ */
+/*     $NetBSD: pmap.h,v 1.143 2015/11/11 17:54:17 skrll Exp $ */
 
 /*
  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -80,6 +80,7 @@
 #include <arm/cpufunc.h>
 #include <arm/locore.h>
 #include <uvm/uvm_object.h>
+#include <uvm/pmap/pmap_pvt.h>
 #endif
 
 #ifdef ARM_MMU_EXTENDED
@@ -1066,11 +1067,11 @@
 #define PMAP_UNMAP_POOLPAGE(va)        pmap_unmap_poolpage(va)
 #endif
 
-/*
- * pmap-specific data store in the vm_page structure.
- */
-#define        __HAVE_VM_PAGE_MD
-struct vm_page_md {
+#define __HAVE_PMAP_PV_TRACK   1
+
+void pmap_pv_protect(paddr_t, vm_prot_t);
+
+struct pmap_page {
        SLIST_HEAD(,pv_entry) pvh_list;         /* pv_entry list */
        int pvh_attrs;                          /* page attributes */
        u_int uro_mappings;
@@ -1079,12 +1080,26 @@
                u_short s_mappings[2];  /* Assume kernel count <= 65535 */
                u_int i_mappings;
        } k_u;
-#define        kro_mappings    k_u.s_mappings[0]
-#define        krw_mappings    k_u.s_mappings[1]
-#define        k_mappings      k_u.i_mappings
 };
 
 /*
+ * pmap-specific data store in the vm_page structure.
+ */
+#define        __HAVE_VM_PAGE_MD
+struct vm_page_md {
+       struct pmap_page pp;
+#define        pvh_list        pp.pvh_list
+#define        pvh_attrs       pp.pvh_attrs
+#define        uro_mappings    pp.uro_mappings
+#define        urw_mappings    pp.urw_mappings
+#define        kro_mappings    pp.k_u.s_mappings[0]
+#define        krw_mappings    pp.k_u.s_mappings[1]
+#define        k_mappings      pp.k_u.i_mappings
+};
+
+#define PMAP_PAGE_TO_MD(ppage) container_of((ppage), struct vm_page_md, pp)
+
+/*
  * Set the default color of each page.
  */
 #if ARM_MMU_V6 > 0



Home | Main Index | Thread Index | Old Index