Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amd64/amd64 Use bootspace.



details:   https://anonhg.NetBSD.org/src/rev/57ee45b6e7de
branches:  trunk
changeset: 356770:57ee45b6e7de
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Oct 11 16:56:26 2017 +0000

description:
Use bootspace.

diffstat:

 sys/arch/amd64/amd64/machdep.c |  42 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 35 insertions(+), 7 deletions(-)

diffs (68 lines):

diff -r 82543ead2add -r 57ee45b6e7de sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Wed Oct 11 16:21:06 2017 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Wed Oct 11 16:56:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.263 2017/10/08 09:06:50 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.264 2017/10/11 16:56:26 maxv Exp $       */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.263 2017/10/08 09:06:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.264 2017/10/11 16:56:26 maxv Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -1994,16 +1994,44 @@
 int
 mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
 {
-       extern char start, __data_start;
        const vaddr_t v = (vaddr_t)ptr;
+       vaddr_t kva, kva_end;
 
-       if (v >= (vaddr_t)&start && v < (vaddr_t)kern_end) {
+       kva = bootspace.text.va;
+       kva_end = kva + bootspace.text.sz;
+       if (v >= kva && v < kva_end) {
+               *handled = true;
+               if (prot & VM_PROT_WRITE) {
+                       return EFAULT;
+               }
+               return 0;
+       }
+
+       kva = bootspace.rodata.va;
+       kva_end = kva + bootspace.rodata.sz;
+       if (v >= kva && v < kva_end) {
                *handled = true;
-               /* Either the text or rodata segment */
-               if (v < (vaddr_t)&__data_start && (prot & VM_PROT_WRITE))
+               if (prot & VM_PROT_WRITE) {
                        return EFAULT;
+               }
+               return 0;
+       }
 
-       } else if (v >= module_start && v < module_end) {
+       kva = bootspace.data.va;
+       kva_end = kva + bootspace.data.sz;
+       if (v >= kva && v < kva_end) {
+               *handled = true;
+               return 0;
+       }
+
+       kva = bootspace.boot.va;
+       kva_end = kva + bootspace.boot.sz;
+       if (v >= kva && v < kva_end) {
+               *handled = true;
+               return 0;
+       }
+
+       if (v >= module_start && v < module_end) {
                *handled = true;
                if (!uvm_map_checkprot(module_map, v, v + 1, prot))
                        return EFAULT;



Home | Main Index | Thread Index | Old Index