Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86 Use variables in PMAP_DIRECT_*, so that the loc...



details:   https://anonhg.NetBSD.org/src/rev/4eced0c9de22
branches:  trunk
changeset: 358416:4eced0c9de22
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Dec 28 14:34:39 2017 +0000

description:
Use variables in PMAP_DIRECT_*, so that the location of the direct map can
change.

diffstat:

 sys/arch/x86/include/pmap.h |  11 ++++++++---
 sys/arch/x86/x86/pmap.c     |  22 +++++++++++++++++-----
 2 files changed, 25 insertions(+), 8 deletions(-)

diffs (94 lines):

diff -r 51505ffcdb56 -r 4eced0c9de22 sys/arch/x86/include/pmap.h
--- a/sys/arch/x86/include/pmap.h       Thu Dec 28 14:03:13 2017 +0000
+++ b/sys/arch/x86/include/pmap.h       Thu Dec 28 14:34:39 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.71 2017/11/11 12:51:05 maxv Exp $   */
+/*     $NetBSD: pmap.h,v 1.72 2017/12/28 14:34:39 maxv Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -528,13 +528,18 @@
 
 #ifdef __HAVE_DIRECT_MAP
 
+extern vaddr_t pmap_direct_base;
+extern vaddr_t pmap_direct_end;
+
 #define L4_SLOT_DIRECT         456
 #define PDIR_SLOT_DIRECT       L4_SLOT_DIRECT
 
 #define NL4_SLOT_DIRECT                32
 
-#define PMAP_DIRECT_BASE       (VA_SIGN_NEG((L4_SLOT_DIRECT * NBPD_L4)))
-#define PMAP_DIRECT_END                (PMAP_DIRECT_BASE + NL4_SLOT_DIRECT * NBPD_L4)
+#define PMAP_DIRECT_DEFAULT_BASE (VA_SIGN_NEG((L4_SLOT_DIRECT * NBPD_L4)))
+
+#define PMAP_DIRECT_BASE       pmap_direct_base
+#define PMAP_DIRECT_END                pmap_direct_end
 
 #define PMAP_DIRECT_MAP(pa)    ((vaddr_t)PMAP_DIRECT_BASE + (pa))
 #define PMAP_DIRECT_UNMAP(va)  ((paddr_t)(va) - PMAP_DIRECT_BASE)
diff -r 51505ffcdb56 -r 4eced0c9de22 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Thu Dec 28 14:03:13 2017 +0000
+++ b/sys/arch/x86/x86/pmap.c   Thu Dec 28 14:34:39 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.269 2017/12/28 14:03:13 maxv Exp $  */
+/*     $NetBSD: pmap.c,v 1.270 2017/12/28 14:34:39 maxv Exp $  */
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.269 2017/12/28 14:03:13 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.270 2017/12/28 14:34:39 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -495,6 +495,13 @@
  */
 static struct pool_cache pmap_pv_cache;
 
+#ifdef __HAVE_DIRECT_MAP
+vaddr_t pmap_direct_base __read_mostly;
+vaddr_t pmap_direct_end __read_mostly;
+size_t pmap_direct_pdpe __read_mostly;
+size_t pmap_direct_npdp __read_mostly;
+#endif
+
 #ifndef __HAVE_DIRECT_MAP
 /*
  * Special VAs and the PTEs that map them
@@ -1438,7 +1445,7 @@
        extern phys_ram_seg_t mem_clusters[];
        extern int mem_cluster_cnt;
 
-       const vaddr_t startva = PMAP_DIRECT_BASE;
+       const vaddr_t startva = PMAP_DIRECT_DEFAULT_BASE;
        size_t nL4e, nL3e, nL2e;
        size_t L4e_idx, L3e_idx, L2e_idx;
        size_t spahole, epahole;
@@ -1523,6 +1530,11 @@
        *pte = 0;
        pmap_update_pg(tmpva);
 
+       pmap_direct_base = startva;
+       pmap_direct_end = endva;
+       pmap_direct_pdpe = L4e_idx;
+       pmap_direct_npdp = nL4e;
+
        tlbflush();
 }
 #endif /* __HAVE_DIRECT_MAP */
@@ -2213,8 +2225,8 @@
        }
 
 #ifdef __HAVE_DIRECT_MAP
-       memcpy(&pdir[PDIR_SLOT_DIRECT], &PDP_BASE[PDIR_SLOT_DIRECT],
-           NL4_SLOT_DIRECT * sizeof(pd_entry_t));
+       memcpy(&pdir[pmap_direct_pdpe], &PDP_BASE[pmap_direct_pdpe],
+           pmap_direct_npdp * sizeof(pd_entry_t));
 #endif
 #endif /* XEN  && __x86_64__*/
 



Home | Main Index | Thread Index | Old Index