Skip to content

Commit 336f306

Browse files
npigginstewartsmith
authored andcommitted
mem-map: Use a symbolic constant for exception vector size
Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
1 parent 8cabd06 commit 336f306

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

asm/head.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ _exception:
224224
exception_entry_foo:
225225
b exception_entry
226226

227-
.= 0x2000
227+
.= EXCEPTION_VECTORS_END
228228
/* This is the OPAL branch table. It's populated at boot time
229229
* with function pointers to the various OPAL functions from
230230
* the content of the .opal_table section, indexed by Token.

core/init.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static size_t kernel_size;
5959
static bool kernel_32bit;
6060

6161
/* We backup the previous vectors here before copying our own */
62-
static uint8_t old_vectors[0x2000];
62+
static uint8_t old_vectors[EXCEPTION_VECTORS_END];
6363

6464
#ifdef SKIBOOT_GCOV
6565
void skiboot_gcov_done(void);
@@ -379,9 +379,9 @@ static bool load_kernel(void)
379379
* If the kernel is at 0, restore it as it was overwritten
380380
* by our vectors.
381381
*/
382-
if (kernel_entry < 0x2000) {
382+
if (kernel_entry < EXCEPTION_VECTORS_END) {
383383
cpu_set_sreset_enable(false);
384-
memcpy(NULL, old_vectors, 0x2000);
384+
memcpy(NULL, old_vectors, EXCEPTION_VECTORS_END);
385385
sync_icache();
386386
}
387387
} else {
@@ -739,14 +739,16 @@ void copy_exception_vectors(void)
739739
/* Backup previous vectors as this could contain a kernel
740740
* image.
741741
*/
742-
memcpy(old_vectors, NULL, 0x2000);
742+
memcpy(old_vectors, NULL, EXCEPTION_VECTORS_END);
743743

744-
/* Copy from 0x100 to 0x2000, avoid below 0x100 as this is
745-
* the boot flag used by CPUs still potentially entering
744+
/* Copy from 0x100 to EXCEPTION_VECTORS_END, avoid below 0x100 as
745+
* this is the boot flag used by CPUs still potentially entering
746746
* skiboot.
747747
*/
748-
BUILD_ASSERT((&reset_patch_end - &reset_patch_start) < 0x1f00);
749-
memcpy((void *)0x100, (void *)(SKIBOOT_BASE + 0x100), 0x1f00);
748+
BUILD_ASSERT((&reset_patch_end - &reset_patch_start) <
749+
EXCEPTION_VECTORS_END - 0x100);
750+
memcpy((void *)0x100, (void *)(SKIBOOT_BASE + 0x100),
751+
EXCEPTION_VECTORS_END - 0x100);
750752
sync_icache();
751753
}
752754

include/mem-map.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#define STACK_SHIFT 14
3030
#define STACK_SIZE (1 << STACK_SHIFT)
3131

32+
/* End of the exception region we copy from 0x0. 0x0-0x100 will have
33+
* IPL data and is not actually for exception vectors.
34+
*/
35+
#define EXCEPTION_VECTORS_END 0x2000
36+
3237
/* The NACA and other stuff in head.S need to be at the start: we
3338
* give it 64k before placing the SPIRA and related data.
3439
*/

0 commit comments

Comments
 (0)