Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Increase KERNTEXTOFF from 1MB to 2MB on amd64. [1MB...



details:   https://anonhg.NetBSD.org/src/rev/2824c6760829
branches:  trunk
changeset: 821359:2824c6760829
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Feb 02 19:09:08 2017 +0000

description:
Increase KERNTEXTOFF from 1MB to 2MB on amd64. [1MB; 2MB[ is now handled
by UVM, so there is no physical loss.

On amd64 we always remap the kernel text with 2MB pages, and because of the
1MB start address we were forced to map [0MB; 2MB[ inside the first large
page. The problem is, the lower half is used by UVM to allocate physical
pages, and it is possible that some of these could be used by userland. We
could end up with userland-controllable data mapped into the kernel text on
a privileged page, which is far from being a good idea from a security pov.

I am not fixing i386 yet, because the large page size depends on PAE, and
we probably don't want to have a text located at 4MB on low-memory systems.

(note: I didn't introduce this issue, it was already there when I came in)

diffstat:

 sys/arch/amd64/conf/Makefile.amd64 |  4 ++--
 sys/arch/amd64/include/param.h     |  6 +++---
 sys/arch/xen/conf/Makefile.xen     |  4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diffs (59 lines):

diff -r 0287452ee629 -r 2824c6760829 sys/arch/amd64/conf/Makefile.amd64
--- a/sys/arch/amd64/conf/Makefile.amd64        Thu Feb 02 18:01:16 2017 +0000
+++ b/sys/arch/amd64/conf/Makefile.amd64        Thu Feb 02 19:09:08 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.amd64,v 1.55 2016/04/29 02:17:25 christos Exp $
+#      $NetBSD: Makefile.amd64,v 1.56 2017/02/02 19:09:08 maxv Exp $
 
 # Makefile for NetBSD
 #
@@ -60,7 +60,7 @@
 ##
 ## (5) link settings
 ##
-TEXTADDR?=     0xffffffff80100000
+TEXTADDR?=     0xffffffff80200000
 EXTRA_LINKFLAGS=       -z max-page-size=0x100000
 LINKFLAGS_NORMAL=      -X
 KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
diff -r 0287452ee629 -r 2824c6760829 sys/arch/amd64/include/param.h
--- a/sys/arch/amd64/include/param.h    Thu Feb 02 18:01:16 2017 +0000
+++ b/sys/arch/amd64/include/param.h    Thu Feb 02 19:09:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.20 2017/01/20 00:29:28 maya Exp $  */
+/*     $NetBSD: param.h,v 1.21 2017/02/02 19:09:08 maxv Exp $  */
 
 #ifdef __x86_64__
 
@@ -34,11 +34,11 @@
  * config info into account.
  */
 #define        KERNBASE        0xffffffff80000000 /* start of kernel virtual space */
-#define        KERNTEXTOFF     0xffffffff80100000 /* start of kernel text */
+#define        KERNTEXTOFF     0xffffffff80200000 /* start of kernel text */
 #define        BTOPKERNBASE    ((u_long)KERNBASE >> PGSHIFT)
 
 #define KERNTEXTOFF_HI 0xffffffff
-#define KERNTEXTOFF_LO 0x80100000
+#define KERNTEXTOFF_LO 0x80200000
 
 #define KERNBASE_HI    0xffffffff
 #define KERNBASE_LO    0x80000000
diff -r 0287452ee629 -r 2824c6760829 sys/arch/xen/conf/Makefile.xen
--- a/sys/arch/xen/conf/Makefile.xen    Thu Feb 02 18:01:16 2017 +0000
+++ b/sys/arch/xen/conf/Makefile.xen    Thu Feb 02 19:09:08 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.xen,v 1.40 2015/08/24 14:04:25 uebayasi Exp $
+#      $NetBSD: Makefile.xen,v 1.41 2017/02/02 19:09:08 maxv Exp $
 #      NetBSD: Makefile.i386,v 1.132 2003/07/05 16:56:10 simonb Exp 
 
 # Makefile for NetBSD
@@ -105,7 +105,7 @@
 .if ${XEN_BUILD} == i386
 TEXTADDR?=     0xc0100000
 .elif ${XEN_BUILD} == amd64
-TEXTADDR?=     0xffffffff80100000
+TEXTADDR?=     0xffffffff80200000
 .endif
 LINKFLAGS_NORMAL=      -X
 KERNLDSCRIPT?= $S/arch/${XEN_BUILD}/conf/kern.ldscript.Xen



Home | Main Index | Thread Index | Old Index