[8/9] skiboot.lds.S: introduce PAGE_SIZE, use it to lay out sections
diff mbox series

Message ID 20200226183408.1626737-9-npiggin@gmail.com
State New
Headers show
Series
  • assorted fixes and preparation
Related show

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (f123417068e51842004bdc047c8c5107b70442ef)

Commit Message

Nicholas Piggin Feb. 26, 2020, 6:34 p.m. UTC
Separate code, data, read-only data, and other significant sections
with PAGE_SIZE alignment. This enables memory protection for these
sections with a later patch.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 include/config.h |  3 +++
 skiboot.lds.S    | 22 ++++++++++++++--------
 2 files changed, 17 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/include/config.h b/include/config.h
index d7a64b712..2877007fb 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4,6 +4,9 @@ 
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
+/* Alignment to which skiboot lays out memory. */
+#define PAGE_SIZE	0x10000
+
 #define HAVE_TYPEOF			1
 #define HAVE_BUILTIN_TYPES_COMPATIBLE_P	1
 
diff --git a/skiboot.lds.S b/skiboot.lds.S
index 64efa7765..f5a6ed396 100644
--- a/skiboot.lds.S
+++ b/skiboot.lds.S
@@ -75,6 +75,7 @@  SECTIONS
 	}
 
 	_head_end = .;
+	. = ALIGN(PAGE_SIZE);
 
 	/*
 	 * The following sections are read-write at runtime. We need
@@ -107,14 +108,14 @@  SECTIONS
 	}
 
 	/* ...and back to RO */
-
-	. = ALIGN(0x10);
+	. = ALIGN(PAGE_SIZE);
 	_stext = .;
  	.text : {
 		*(.text*)
 		*(.sfpr .glink)
 	}
 	_etext = .;
+	. = ALIGN(PAGE_SIZE);
 
 	.rodata : {
 		__rodata_start = .;
@@ -177,6 +178,7 @@  SECTIONS
 		*(.rela*)
 		__rela_dyn_end = .;
 	}
+
 	.hash          : { *(.hash)   }
 	.gnu.hash      : { *(.gnu.hash) }
 	.gnu.version   : { *(.gnu.version) }
@@ -196,22 +198,26 @@  SECTIONS
 	 */
 	_romem_end = .;
 
+	. = ALIGN(PAGE_SIZE);
+
+	_sdata = .;
 	.data : {
 		/*
 		 * A couple of things that need to be 4K aligned and
 		 * to reside in their own pages for the sake of TCE
-		 * mappings
+		 * mappings, so use PAGE_SIZE alignment.
 		 */
-		. = ALIGN(0x1000);
+		. = ALIGN(PAGE_SIZE);
 		*(.data.memcons);
-		. = ALIGN(0x10000);
+		. = ALIGN(PAGE_SIZE);
 		*(.data.boot_trace);
-		. = ALIGN(0x10000);
+		. = ALIGN(PAGE_SIZE);
 		*(.data*)
 		*(.force.data)
 		*(.toc1)
 		*(.branch_lt)
 	}
+	_edata = .;
 
 	/* We locate the BSS at 4M to leave room for the symbol map */
 	. = 0x400000;
@@ -221,7 +227,7 @@  SECTIONS
 		*(.dynbss)
 		*(.bss*)
 	}
-	. = ALIGN(0x10000);
+	. = ALIGN(PAGE_SIZE);
 	_ebss = .;
 	_end = .;
 
@@ -230,7 +236,7 @@  SECTIONS
 	DEBUG_SECTIONS
 
 	/* Optional kernel image */
-       . = ALIGN(0x10000);
+       . = ALIGN(PAGE_SIZE);
        .builtin_kernel : {
 		__builtin_kernel_start = .;
 		KEEP(*(.builtin_kernel))