Module Name: src
Committed By: maxv
Date: Thu May 12 09:05:16 UTC 2016
Modified Files:
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/amd64/conf: kern.ldscript
Log Message:
Map the data+bss chunk independently on amd64, and remove the X
permission on it.
To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/amd64/conf/kern.ldscript
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/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.89 src/sys/arch/amd64/amd64/locore.S:1.90
--- src/sys/arch/amd64/amd64/locore.S:1.89 Thu May 12 07:51:09 2016
+++ src/sys/arch/amd64/amd64/locore.S Thu May 12 09:05:16 2016
@@ -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 @@ no_NOX:
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
Index: src/sys/arch/amd64/conf/kern.ldscript
diff -u src/sys/arch/amd64/conf/kern.ldscript:1.20 src/sys/arch/amd64/conf/kern.ldscript:1.21
--- src/sys/arch/amd64/conf/kern.ldscript:1.20 Thu May 12 07:21:18 2016
+++ src/sys/arch/amd64/conf/kern.ldscript Thu May 12 09:05:16 2016
@@ -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 @@ __LARGE_PAGE_SIZE = 0x200000 ;
ENTRY(_start)
SECTIONS
{
- /* Read-only sections, merged into text segment: */
.text :
{
*(.text)
@@ -66,7 +65,12 @@ SECTIONS
*(COMMON)
. = ALIGN(64 / 8);
}
- . = ALIGN(64 / 8);
+
+ . = ALIGN(__PAGE_SIZE);
+
+ /* End of the kernel image */
+ __kernel_end = . ;
+
_end = . ;
PROVIDE (end = .) ;
.note.netbsd.ident :