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 rodata segment independently on amd64...
details: https://anonhg.NetBSD.org/src/rev/cd93ab7aa4a4
branches: trunk
changeset: 345194:cd93ab7aa4a4
user: maxv <maxv%NetBSD.org@localhost>
date: Thu May 12 07:21:18 2016 +0000
description:
Map the rodata segment independently on amd64, and remove the W permission
on it.
diffstat:
sys/arch/amd64/amd64/locore.S | 31 +++++++++++++++++--------------
sys/arch/amd64/conf/kern.ldscript | 4 +++-
2 files changed, 20 insertions(+), 15 deletions(-)
diffs (79 lines):
diff -r f717c2e3e8f3 -r cd93ab7aa4a4 sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S Thu May 12 06:57:55 2016 +0000
+++ b/sys/arch/amd64/amd64/locore.S Thu May 12 07:21:18 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.87 2016/05/12 06:45:16 maxv Exp $ */
+/* $NetBSD: locore.S,v 1.88 2016/05/12 07:21:18 maxv Exp $ */
/*
* Copyright-o-rama!
@@ -564,6 +564,8 @@
*
* (PROC0 STK + L4 + L3 + L2 + L1) is later referred to as BOOTSTRAP TABLES.
*
+ * Important note: the kernel segments are properly 4k-aligned
+ * (see kern.ldscript), so there's no need to enforce alignment.
*/
/* Find end of kernel image; brings us on (1). */
@@ -616,16 +618,16 @@
shrl $(PGSHIFT-3),%ecx /* ((n >> PGSHIFT) << 3) for # PDEs */
addl %ecx,%ebx
- /*
- * Compute &__rodata_start - KERNBASE. This can't be > 4G, or we can't
- * deal with it anyway, since we can't load it in 32 bit mode. So use
- * the bottom 32 bits.
- */
- movl $RELOC(__rodata_start),%edx
- andl $~PGOFSET,%edx
+ /* Map the kernel text RX. */
+ movl $RELOC(__rodata_start),%ecx
+ subl %eax,%ecx
+ shrl $PGSHIFT,%ecx
+ orl $(PG_V|PG_KR),%eax
+ fillkpt
- /* Map the kernel text read-only. */
- movl %edx,%ecx
+ /* Map the kernel rodata ROX. */
+ movl $RELOC(__rodata_start),%eax
+ movl $RELOC(__data_start),%ecx
subl %eax,%ecx
shrl $PGSHIFT,%ecx
orl $(PG_V|PG_KR),%eax
@@ -639,11 +641,12 @@
* +--------+----------+-------------------+------------------+
* We just map everything from < to > with RWX rights.
*/
- leal (PG_V|PG_KW)(%edx),%eax
- movl $TABLESIZE,%ecx
- addl %esi,%ecx /* end of tables */
- subl %edx,%ecx /* subtract end of text */
+ movl $RELOC(__data_start),%eax
+ movl %esi,%ecx /* start of BOOTSTRAP TABLES */
+ addl $TABLESIZE,%ecx /* end of BOOTSTRAP TABLES */
+ subl %eax,%ecx /* subtract start of DATA */
shrl $PGSHIFT,%ecx
+ orl $(PG_V|PG_KW),%eax
fillkpt
/* We are on (4). Map ISA I/O mem (later atdevbase) RWX. */
diff -r f717c2e3e8f3 -r cd93ab7aa4a4 sys/arch/amd64/conf/kern.ldscript
--- a/sys/arch/amd64/conf/kern.ldscript Thu May 12 06:57:55 2016 +0000
+++ b/sys/arch/amd64/conf/kern.ldscript Thu May 12 07:21:18 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern.ldscript,v 1.19 2016/05/12 06:45:16 maxv Exp $ */
+/* $NetBSD: kern.ldscript,v 1.20 2016/05/12 07:21:18 maxv Exp $ */
#include "assym.h"
@@ -36,6 +36,8 @@
*(.rodata.*)
}
+ . = ALIGN(__PAGE_SIZE);
+
__data_start = . ;
.data :
{
Home |
Main Index |
Thread Index |
Old Index