Skip to content

Commit

Permalink
mem-map: Use a symbolic constant for exception vector size
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
npiggin authored and stewartsmith committed Mar 27, 2018
1 parent 8cabd06 commit 336f306
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion asm/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 10 additions & 8 deletions core/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}

Expand Down
5 changes: 5 additions & 0 deletions include/mem-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 336f306

Please sign in to comment.