Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86 Add the remaining pmap callbacks, will be used ...



details:   https://anonhg.NetBSD.org/src/rev/2975211c51d1
branches:  trunk
changeset: 838829:2975211c51d1
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Feb 01 11:35:13 2019 +0000

description:
Add the remaining pmap callbacks, will be used by NVMM-VMX.

diffstat:

 sys/arch/x86/include/pmap.h |  10 ++++++++-
 sys/arch/x86/x86/pmap.c     |  48 +++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 53 insertions(+), 5 deletions(-)

diffs (145 lines):

diff -r db98e09ee98e -r 2975211c51d1 sys/arch/x86/include/pmap.h
--- a/sys/arch/x86/include/pmap.h       Fri Feb 01 10:39:48 2019 +0000
+++ b/sys/arch/x86/include/pmap.h       Fri Feb 01 11:35:13 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.94 2019/02/01 05:44:29 maxv Exp $   */
+/*     $NetBSD: pmap.h,v 1.95 2019/02/01 11:35:13 maxv Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -263,7 +263,15 @@
 
        /* Used by NVMM. */
        int (*pm_enter)(struct pmap *, vaddr_t, paddr_t, vm_prot_t, u_int);
+       bool (*pm_extract)(struct pmap *, vaddr_t, paddr_t *);
        void (*pm_remove)(struct pmap *, vaddr_t, vaddr_t);
+       int (*pm_sync_pv)(struct vm_page *, vaddr_t, paddr_t, int, uint8_t *,
+           pt_entry_t *);
+       void (*pm_pp_remove_ent)(struct pmap *, struct vm_page *, pt_entry_t,
+           vaddr_t);
+       void (*pm_write_protect)(struct pmap *, vaddr_t, vaddr_t, vm_prot_t);
+       void (*pm_unwire)(struct pmap *, vaddr_t);
+
        void (*pm_tlb_flush)(struct pmap *);
        void *pm_data;
 };
diff -r db98e09ee98e -r 2975211c51d1 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Fri Feb 01 10:39:48 2019 +0000
+++ b/sys/arch/x86/x86/pmap.c   Fri Feb 01 11:35:13 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.318 2019/02/01 05:44:29 maxv Exp $  */
+/*     $NetBSD: pmap.c,v 1.319 2019/02/01 11:35:13 maxv Exp $  */
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.318 2019/02/01 05:44:29 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.319 2019/02/01 11:35:13 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -2387,8 +2387,14 @@
        pmap->pm_flags = 0;
        pmap->pm_gc_ptp = NULL;
 
+       /* Used by NVMM. */
        pmap->pm_enter = NULL;
+       pmap->pm_extract = NULL;
        pmap->pm_remove = NULL;
+       pmap->pm_sync_pv = NULL;
+       pmap->pm_pp_remove_ent = NULL;
+       pmap->pm_write_protect = NULL;
+       pmap->pm_unwire = NULL;
        pmap->pm_tlb_flush = NULL;
        pmap->pm_data = NULL;
 
@@ -2542,7 +2548,11 @@
 
        pmap_free_ptps(pmap->pm_gc_ptp);
 
-       pool_cache_put(&pmap_pdp_cache, pmap->pm_pdir);
+       if (__predict_false(pmap->pm_enter != NULL)) {
+               pool_cache_destruct_object(&pmap_pdp_cache, pmap->pm_pdir);
+       } else {
+               pool_cache_put(&pmap_pdp_cache, pmap->pm_pdir);
+       }
 
 #ifdef USER_LDT
        if (pmap->pm_ldt != NULL) {
@@ -3051,6 +3061,10 @@
        lwp_t *l;
        bool hard, rv;
 
+       if (__predict_false(pmap->pm_extract != NULL)) {
+               return (*pmap->pm_extract)(pmap, va, pap);
+       }
+
 #ifdef __HAVE_DIRECT_MAP
        if (va >= PMAP_DIRECT_BASE && va < PMAP_DIRECT_END) {
                if (pap != NULL) {
@@ -3625,6 +3639,11 @@
        KASSERT(ptp == NULL || ptp_va2o(va, 1) == ptp->offset);
        pmap = ptp_to_pmap(ptp);
 
+       if (__predict_false(pmap->pm_sync_pv != NULL)) {
+               return (*pmap->pm_sync_pv)(ptp, va, pa, clearbits, oattrs,
+                   optep);
+       }
+
        if (clearbits != ~0) {
                KASSERT((clearbits & ~(PP_ATTRS_M|PP_ATTRS_U|PP_ATTRS_W)) == 0);
                clearbits = pmap_pp_attrs_to_pte(clearbits);
@@ -3762,7 +3781,11 @@
                if (ptp != NULL) {
                        KASSERT(pmap != pmap_kernel());
                        pmap_tlb_shootnow();
-                       pmap_pp_remove_ent(pmap, ptp, opte, va);
+                       if (__predict_false(pmap->pm_pp_remove_ent != NULL)) {
+                               (*pmap->pm_pp_remove_ent)(pmap, ptp, opte, va);
+                       } else {
+                               pmap_pp_remove_ent(pmap, ptp, opte, va);
+                       }
                        pmap_destroy(pmap);
                } else {
                        KASSERT(pmap == pmap_kernel());
@@ -3980,6 +4003,11 @@
 
        KASSERT(curlwp->l_md.md_gc_pmap != pmap);
 
+       if (__predict_false(pmap->pm_write_protect != NULL)) {
+               (*pmap->pm_write_protect)(pmap, sva, eva, prot);
+               return;
+       }
+
        bit_rem = 0;
        if (!(prot & VM_PROT_WRITE))
                bit_rem = PG_RW;
@@ -4048,6 +4076,11 @@
        pd_entry_t * const *pdes;
        struct pmap *pmap2;
 
+       if (__predict_false(pmap->pm_unwire != NULL)) {
+               (*pmap->pm_unwire)(pmap, va);
+               return;
+       }
+
        /* Acquire pmap. */
        kpreempt_disable();
        pmap_map_ptes(pmap, &pmap2, &ptes, &pdes);
@@ -4545,6 +4578,13 @@
 
                mutex_enter(&pmaps_lock);
                LIST_FOREACH(pm, &pmaps, pm_list) {
+                       if (__predict_false(pm->pm_enter != NULL)) {
+                               /*
+                                * Not a native pmap, the kernel is not mapped,
+                                * so nothing to synchronize.
+                                */
+                               continue;
+                       }
                        memcpy(&pm->pm_pdir[PDIR_SLOT_KERN + old],
                            &kpm->pm_pdir[PDIR_SLOT_KERN + old],
                            newpdes * sizeof(pd_entry_t));



Home | Main Index | Thread Index | Old Index