Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 Declare pmap_remap_global, and map the four...



details:   https://anonhg.NetBSD.org/src/rev/7c9c4bcdc761
branches:  trunk
changeset: 356509:7c9c4bcdc761
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Sep 30 12:29:58 2017 +0000

description:
Declare pmap_remap_global, and map the four regions independently with
bootspace.

diffstat:

 sys/arch/x86/x86/pmap.c |  71 ++++++++++++++++++++++++++++++++++--------------
 1 files changed, 50 insertions(+), 21 deletions(-)

diffs (113 lines):

diff -r a3562be3f55b -r 7c9c4bcdc761 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Sat Sep 30 12:29:05 2017 +0000
+++ b/sys/arch/x86/x86/pmap.c   Sat Sep 30 12:29:58 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.258 2017/09/30 11:43:57 maxv Exp $  */
+/*     $NetBSD: pmap.c,v 1.259 2017/09/30 12:29:58 maxv Exp $  */
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.258 2017/09/30 11:43:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.259 2017/09/30 12:29:58 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -549,6 +549,7 @@
 #endif
 #ifndef XEN
 static void pmap_init_lapic(void);
+static void pmap_remap_global(void);
 static void pmap_remap_largepages(void);
 #endif
 
@@ -1210,10 +1211,6 @@
        struct pmap *kpm;
        int i;
        vaddr_t kva;
-#ifndef XEN
-       unsigned long p1i;
-       vaddr_t kva_end;
-#endif
 
        pmap_pg_nx = (cpu_feature[2] & CPUID_NOX ? PG_NX : 0);
 
@@ -1287,21 +1284,7 @@
                pmap_pg_g = PG_G;               /* enable software */
 
                /* add PG_G attribute to already mapped kernel pages */
-
-               if (KERNBASE == VM_MIN_KERNEL_ADDRESS) {
-                       /* i386 only */
-                       kva_end = virtual_avail;
-               } else {
-                       /* amd64 only */
-                       extern vaddr_t kern_end;
-                       kva_end = kern_end;
-               }
-
-               for (kva = bootspace.text.va; kva < kva_end; kva += PAGE_SIZE) {
-                       p1i = pl1_i(kva);
-                       if (pmap_valid_entry(PTE_BASE[p1i]))
-                               PTE_BASE[p1i] |= PG_G;
-               }
+               pmap_remap_global();
        }
 
        /*
@@ -1566,6 +1549,52 @@
 
 #ifndef XEN
 /*
+ * Remap all of the virtual pages created so far with the PG_G bit.
+ */
+static void
+pmap_remap_global(void)
+{
+       vaddr_t kva, kva_end;
+       unsigned long p1i;
+
+       /* kernel text */
+       kva = bootspace.text.va;
+       kva_end = kva + bootspace.text.sz;
+       for ( ; kva < kva_end; kva += PAGE_SIZE) {
+               p1i = pl1_i(kva);
+               if (pmap_valid_entry(PTE_BASE[p1i]))
+                       PTE_BASE[p1i] |= PG_G;
+       }
+
+       /* kernel rodata */
+       kva = bootspace.rodata.va;
+       kva_end = kva + bootspace.rodata.sz;
+       for ( ; kva < kva_end; kva += PAGE_SIZE) {
+               p1i = pl1_i(kva);
+               if (pmap_valid_entry(PTE_BASE[p1i]))
+                       PTE_BASE[p1i] |= PG_G;
+       }
+
+       /* kernel data */
+       kva = bootspace.data.va;
+       kva_end = kva + bootspace.data.sz;
+       for ( ; kva < kva_end; kva += PAGE_SIZE) {
+               p1i = pl1_i(kva);
+               if (pmap_valid_entry(PTE_BASE[p1i]))
+                       PTE_BASE[p1i] |= PG_G;
+       }
+
+       /* boot space */
+       kva = bootspace.boot.va;
+       kva_end = kva + bootspace.boot.sz;
+       for ( ; kva < kva_end; kva += PAGE_SIZE) {
+               p1i = pl1_i(kva);
+               if (pmap_valid_entry(PTE_BASE[p1i]))
+                       PTE_BASE[p1i] |= PG_G;
+       }
+}
+
+/*
  * Remap several kernel segments with large pages. We cover as many pages as we
  * can. Called only once at boot time, if the CPU supports large pages.
  */



Home | Main Index | Thread Index | Old Index