Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amd64 Map the data+bss chunk independently on amd64...



details:   https://anonhg.NetBSD.org/src/rev/08abb800d518
branches:  trunk
changeset: 815339:08abb800d518
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu May 12 09:05:16 2016 +0000

description:
Map the data+bss chunk independently on amd64, and remove the X
permission on it.

diffstat:

 sys/arch/amd64/amd64/locore.S     |  20 ++++++++++++++------
 sys/arch/amd64/conf/kern.ldscript |  10 +++++++---
 2 files changed, 21 insertions(+), 9 deletions(-)

diffs (72 lines):

diff -r 5f748d191371 -r 08abb800d518 sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Thu May 12 08:43:49 2016 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Thu May 12 09:05:16 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.89 2016/05/12 07:51:09 maxv Exp $ */
+/*     $NetBSD: locore.S,v 1.90 2016/05/12 09:05:16 maxv Exp $ */
 
 /*
  * Copyright-o-rama!
@@ -646,18 +646,26 @@
        orl     $(PG_V|PG_KR),%eax
        fillkpt_nox
 
+       /* Map the kernel data+bss RW. */
+       movl    $RELOC(__data_start),%eax
+       movl    $RELOC(__kernel_end),%ecx
+       subl    %eax,%ecx
+       shrl    $PGSHIFT,%ecx
+       orl     $(PG_V|PG_KW),%eax
+       fillkpt_nox
+
        /*
         * We actually have to be careful here. The memory layout is as
         * follows:
-        *  +--------+----------+-------------------+------------------+
-        *  | RODATA < DATA+BSS | PRELOADED MODULES | BOOTSTRAP TABLES >
-        *  +--------+----------+-------------------+------------------+
+        *    +----------+---------------------+------------------+
+        *    | DATA+BSS < [PRELOADED MODULES] | BOOTSTRAP TABLES >
+        *    +----------+---------------------+------------------+
         * We just map everything from < to > with RWX rights.
         */
-       movl    $RELOC(__data_start),%eax
+       movl    $RELOC(__kernel_end),%eax
        movl    %esi,%ecx               /* start of BOOTSTRAP TABLES */
        addl    $TABLESIZE,%ecx         /* end of BOOTSTRAP TABLES */
-       subl    %eax,%ecx               /* subtract start of DATA */
+       subl    %eax,%ecx               /* subtract end of kernel image */
        shrl    $PGSHIFT,%ecx
        orl     $(PG_V|PG_KW),%eax
        fillkpt
diff -r 5f748d191371 -r 08abb800d518 sys/arch/amd64/conf/kern.ldscript
--- a/sys/arch/amd64/conf/kern.ldscript Thu May 12 08:43:49 2016 +0000
+++ b/sys/arch/amd64/conf/kern.ldscript Thu May 12 09:05:16 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern.ldscript,v 1.20 2016/05/12 07:21:18 maxv Exp $    */
+/*     $NetBSD: kern.ldscript,v 1.21 2016/05/12 09:05:16 maxv Exp $    */
 
 #include "assym.h"
 
@@ -13,7 +13,6 @@
 ENTRY(_start)
 SECTIONS
 {
-       /* Read-only sections, merged into text segment: */
        .text :
        {
                *(.text)
@@ -66,7 +65,12 @@
                *(COMMON)
                . = ALIGN(64 / 8);
        }
-       . = ALIGN(64 / 8);
+
+       . = ALIGN(__PAGE_SIZE);
+
+       /* End of the kernel image */
+       __kernel_end = . ;
+
        _end = . ;
        PROVIDE (end = .) ;
        .note.netbsd.ident :



Home | Main Index | Thread Index | Old Index