Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Add and use bootspace.smodule. Initialize it in loc...



details:   https://anonhg.NetBSD.org/src/rev/59a4c20f992b
branches:  trunk
changeset: 323563:59a4c20f992b
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Jun 20 11:49:37 2018 +0000

description:
Add and use bootspace.smodule. Initialize it in locore/prekern to better
hide the specifics from the "upper" layers. This allows for greater
flexibility.

diffstat:

 sys/arch/amd64/amd64/machdep.c         |  33 ++++++++++++---------------------
 sys/arch/amd64/stand/prekern/mm.c      |   3 ++-
 sys/arch/amd64/stand/prekern/prekern.h |   3 ++-
 sys/arch/x86/include/pmap.h            |   5 +++--
 4 files changed, 19 insertions(+), 25 deletions(-)

diffs (143 lines):

diff -r 6c68213acfb6 -r 59a4c20f992b sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Wed Jun 20 11:45:25 2018 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Wed Jun 20 11:49:37 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.304 2018/05/08 17:20:44 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.305 2018/06/20 11:49:37 maxv Exp $       */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,9 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.304 2018/05/08 17:20:44 maxv Exp $");
-
-/* #define XENDEBUG_LOW  */
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.305 2018/06/20 11:49:37 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -261,11 +259,9 @@
 vaddr_t ldt_vaddr;
 paddr_t ldt_paddr;
 
-vaddr_t module_start, module_end;
 static struct vm_map module_map_store;
 extern struct vm_map *module_map;
 extern struct bootspace bootspace;
-vaddr_t kern_end;
 
 struct vm_map *phys_map = NULL;
 
@@ -374,15 +370,15 @@
         * Create the module map.
         *
         * The kernel uses RIP-relative addressing with a maximum offset of
-        * 2GB. The problem is, kernel_map is too far away in memory from
-        * the kernel .text. So we cannot use it, and have to create a
-        * special module_map.
+        * 2GB. Because of that, we can't put the kernel modules in kernel_map
+        * (like i386 does), since kernel_map is too far away in memory from
+        * the kernel sections. So we have to create a special module_map.
         *
         * The module map is taken as what is left of the bootstrap memory
-        * created in locore.S. This memory is right above the kernel
-        * image, so this is the best place to put our modules.
+        * created in locore/prekern.
         */
-       uvm_map_setup(&module_map_store, module_start, module_end, 0);
+       uvm_map_setup(&module_map_store, bootspace.smodule,
+           bootspace.emodule, 0);
        module_map_store.pmap = pmap_kernel();
        module_map = &module_map_store;
 
@@ -1577,9 +1573,11 @@
        /* In locore.S, we allocated a tmp va. We will use it now. */
        bootspace.spareva = KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2;
 
-       /* Virtual address of the L4 page */
+       /* Virtual address of the L4 page. */
        bootspace.pdir = (vaddr_t)(PDPpaddr + KERNBASE);
 
+       /* Kernel module map. */
+       bootspace.smodule = (vaddr_t)atdevbase + IOM_SIZE;
        bootspace.emodule = KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2;
 }
 
@@ -1665,13 +1663,6 @@
        pmap_pa_end = avail_end;
 #endif
 
-       /* End of the virtual space we have created so far. */
-       kern_end = (vaddr_t)atdevbase + IOM_SIZE;
-
-       /* The area for the module map. */
-       module_start = kern_end;
-       module_end = bootspace.emodule;
-
        /*
         * Call pmap initialization to make new kernel address space.
         * We must do this before loading pages into the VM system.
@@ -2123,7 +2114,7 @@
                return 0;
        }
 
-       if (v >= module_start && v < module_end) {
+       if (v >= bootspace.smodule && v < bootspace.emodule) {
                *handled = true;
                if (!uvm_map_checkprot(module_map, v, v + 1, prot))
                        return EFAULT;
diff -r 6c68213acfb6 -r 59a4c20f992b sys/arch/amd64/stand/prekern/mm.c
--- a/sys/arch/amd64/stand/prekern/mm.c Wed Jun 20 11:45:25 2018 +0000
+++ b/sys/arch/amd64/stand/prekern/mm.c Wed Jun 20 11:49:37 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mm.c,v 1.21 2017/12/21 14:32:06 maxv Exp $     */
+/*     $NetBSD: mm.c,v 1.22 2018/06/20 11:49:37 maxv Exp $     */
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -420,6 +420,7 @@
        extern uint64_t PDPpaddr;
        bootspace.spareva = bootspace.boot.va + NKL2_KIMG_ENTRIES * NBPD_L2;
        bootspace.pdir = bootspace.boot.va + (PDPpaddr - bootspace.boot.pa);
+       bootspace.smodule = (vaddr_t)iom_base + IOM_SIZE;
        bootspace.emodule = bootspace.boot.va + NKL2_KIMG_ENTRIES * NBPD_L2;
 }
 
diff -r 6c68213acfb6 -r 59a4c20f992b sys/arch/amd64/stand/prekern/prekern.h
--- a/sys/arch/amd64/stand/prekern/prekern.h    Wed Jun 20 11:45:25 2018 +0000
+++ b/sys/arch/amd64/stand/prekern/prekern.h    Wed Jun 20 11:49:37 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prekern.h,v 1.19 2018/01/15 22:38:01 christos Exp $    */
+/*     $NetBSD: prekern.h,v 1.20 2018/06/20 11:49:37 maxv Exp $        */
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -75,6 +75,7 @@
        } boot;
        vaddr_t spareva;
        vaddr_t pdir;
+       vaddr_t smodule;
        vaddr_t emodule;
 };
 
diff -r 6c68213acfb6 -r 59a4c20f992b sys/arch/x86/include/pmap.h
--- a/sys/arch/x86/include/pmap.h       Wed Jun 20 11:45:25 2018 +0000
+++ b/sys/arch/x86/include/pmap.h       Wed Jun 20 11:49:37 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.79 2018/05/19 16:55:59 jakllsch Exp $       */
+/*     $NetBSD: pmap.h,v 1.80 2018/06/20 11:49:38 maxv Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -149,7 +149,8 @@
        /* Virtual address of the page directory. */
        vaddr_t pdir;
 
-       /* End of the area dedicated to kernel modules (amd64 only). */
+       /* Area dedicated to kernel modules (amd64 only). */
+       vaddr_t smodule;
        vaddr_t emodule;
 };
 



Home | Main Index | Thread Index | Old Index