Module Name: src Committed By: maxv Date: Thu Feb 2 19:09:08 UTC 2017
Modified Files: src/sys/arch/amd64/conf: Makefile.amd64 src/sys/arch/amd64/include: param.h src/sys/arch/xen/conf: Makefile.xen Log Message: 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) To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/arch/amd64/conf/Makefile.amd64 cvs rdiff -u -r1.20 -r1.21 src/sys/arch/amd64/include/param.h cvs rdiff -u -r1.40 -r1.41 src/sys/arch/xen/conf/Makefile.xen Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/amd64/conf/Makefile.amd64 diff -u src/sys/arch/amd64/conf/Makefile.amd64:1.55 src/sys/arch/amd64/conf/Makefile.amd64:1.56 --- src/sys/arch/amd64/conf/Makefile.amd64:1.55 Fri Apr 29 02:17:25 2016 +++ src/sys/arch/amd64/conf/Makefile.amd64 Thu Feb 2 19:09:08 2017 @@ -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 @@ KERN_AS= library ## ## (5) link settings ## -TEXTADDR?= 0xffffffff80100000 +TEXTADDR?= 0xffffffff80200000 EXTRA_LINKFLAGS= -z max-page-size=0x100000 LINKFLAGS_NORMAL= -X KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript Index: src/sys/arch/amd64/include/param.h diff -u src/sys/arch/amd64/include/param.h:1.20 src/sys/arch/amd64/include/param.h:1.21 --- src/sys/arch/amd64/include/param.h:1.20 Fri Jan 20 00:29:28 2017 +++ src/sys/arch/amd64/include/param.h Thu Feb 2 19:09:08 2017 @@ -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 Index: src/sys/arch/xen/conf/Makefile.xen diff -u src/sys/arch/xen/conf/Makefile.xen:1.40 src/sys/arch/xen/conf/Makefile.xen:1.41 --- src/sys/arch/xen/conf/Makefile.xen:1.40 Mon Aug 24 14:04:25 2015 +++ src/sys/arch/xen/conf/Makefile.xen Thu Feb 2 19:09:08 2017 @@ -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 @@ vector.o: $S/arch/${XEN_BUILD}/${XEN_BUI .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