[Skiboot] [PATCH 2/3] mem-map: Use a symbolic constant for exception vector size

Nicholas Piggin npiggin at gmail.com
Sun Mar 25 11:44:32 AEDT 2018


Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 asm/head.S        |  2 +-
 core/init.c       | 18 ++++++++++--------
 include/mem-map.h |  5 +++++
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/asm/head.S b/asm/head.S
index fb4b95f7..8049d785 100644
--- a/asm/head.S
+++ b/asm/head.S
@@ -224,7 +224,7 @@ _exception:
 exception_entry_foo:
 	b	exception_entry
 
-	.= 0x2000
+	.= EXCEPTION_VECTORS_END
 	/* This is the OPAL branch table. It's populated at boot time
 	 * with function pointers to the various OPAL functions from
 	 * the content of the .opal_table section, indexed by Token.
diff --git a/core/init.c b/core/init.c
index 3de89a72..d13b17c3 100644
--- a/core/init.c
+++ b/core/init.c
@@ -59,7 +59,7 @@ static size_t kernel_size;
 static bool kernel_32bit;
 
 /* We backup the previous vectors here before copying our own */
-static uint8_t old_vectors[0x2000];
+static uint8_t old_vectors[EXCEPTION_VECTORS_END];
 
 #ifdef SKIBOOT_GCOV
 void skiboot_gcov_done(void);
@@ -379,9 +379,9 @@ static bool load_kernel(void)
 		 * If the kernel is at 0, restore it as it was overwritten
 		 * by our vectors.
 		 */
-		if (kernel_entry < 0x2000) {
+		if (kernel_entry < EXCEPTION_VECTORS_END) {
 			cpu_set_sreset_enable(false);
-			memcpy(NULL, old_vectors, 0x2000);
+			memcpy(NULL, old_vectors, EXCEPTION_VECTORS_END);
 			sync_icache();
 		}
 	} else {
@@ -739,14 +739,16 @@ void copy_exception_vectors(void)
 	/* Backup previous vectors as this could contain a kernel
 	 * image.
 	 */
-	memcpy(old_vectors, NULL, 0x2000);
+	memcpy(old_vectors, NULL, EXCEPTION_VECTORS_END);
 
-	/* Copy from 0x100 to 0x2000, avoid below 0x100 as this is
-	 * the boot flag used by CPUs still potentially entering
+	/* Copy from 0x100 to EXCEPTION_VECTORS_END, avoid below 0x100 as
+	 * this is the boot flag used by CPUs still potentially entering
 	 * skiboot.
 	 */
-	BUILD_ASSERT((&reset_patch_end - &reset_patch_start) < 0x1f00);
-	memcpy((void *)0x100, (void *)(SKIBOOT_BASE + 0x100), 0x1f00);
+	BUILD_ASSERT((&reset_patch_end - &reset_patch_start) <
+			EXCEPTION_VECTORS_END - 0x100);
+	memcpy((void *)0x100, (void *)(SKIBOOT_BASE + 0x100),
+			EXCEPTION_VECTORS_END - 0x100);
 	sync_icache();
 }
 
diff --git a/include/mem-map.h b/include/mem-map.h
index 05733518..d2bc23fc 100644
--- a/include/mem-map.h
+++ b/include/mem-map.h
@@ -29,6 +29,11 @@
 #define STACK_SHIFT		14
 #define STACK_SIZE		(1 << STACK_SHIFT)
 
+/* End of the exception region we copy from 0x0. 0x0-0x100 will have
+ * IPL data and is not actually for exception vectors.
+ */
+#define EXCEPTION_VECTORS_END	0x2000
+
 /* The NACA and other stuff in head.S need to be at the start: we
  * give it 64k before placing the SPIRA and related data.
  */
-- 
2.16.1



More information about the Skiboot mailing list