summaryrefslogtreecommitdiff
path: root/src/cpu/intel
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2019-08-18 08:40:56 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2019-08-21 16:38:17 +0000
commit4c095fc9e91e68ab15d2ff256260acc9fd65dd91 (patch)
treefcf2f9f82ca790afd7efa6b79e573189b65d8f93 /src/cpu/intel
parentc2741855afacd073d370d47818d972cca9baba18 (diff)
downloadcoreboot-4c095fc9e91e68ab15d2ff256260acc9fd65dd91.tar.xz
cpu/intel/car: Make stack guards more useful on C_ENV_BOOTBLOCK
With C_ENVIRONMENT_BOOTBLOCK, CONFIG_DCACHE_BSP_STACK_SIZE needs to be set to define a stack region that can be shared over all stages using CAR. It makes sense to use that Kconfig option's value instead of a hardcoded value. This will result in less false positives when the stack size is big, for instance with FSP using the coreboot stack. In many configurations with C_ENVIRONMENT_BOOTBLOCK the stack_base is at the base of CAR. If the stack grows too large it operates out of CAR, typically resulting in a hang. Therefore the stack guards are extended to cover 256 bytes at the base to at least provide a warning when the romstage is dangerously close of running out of stack. Change-Id: I2ce1dda4d1f254e6c36de4d3fea26e12c34195ff Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/34976 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/cpu/intel')
-rw-r--r--src/cpu/intel/car/romstage.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cpu/intel/car/romstage.c b/src/cpu/intel/car/romstage.c
index 28801458cd..e24225e71e 100644
--- a/src/cpu/intel/car/romstage.c
+++ b/src/cpu/intel/car/romstage.c
@@ -21,6 +21,8 @@
#include <program_loading.h>
#include <timestamp.h>
+/* If we do not have a constrained _car_stack region size, use the
+ following as a guideline for acceptable stack usage. */
#define DCACHE_RAM_ROMSTAGE_STACK_SIZE 0x2000
static struct postcar_frame early_mtrrs;
@@ -43,16 +45,18 @@ static void prepare_and_run_postcar(struct postcar_frame *pcf)
static void romstage_main(unsigned long bist)
{
int i;
- const int num_guards = 4;
+ const int num_guards = 64;
const u32 stack_guard = 0xdeadbeef;
u32 *stack_base;
u32 size;
+ const size_t stack_size = MAX(CONFIG_DCACHE_BSP_STACK_SIZE,
+ DCACHE_RAM_ROMSTAGE_STACK_SIZE);
/* Size of unallocated CAR. */
size = ALIGN_DOWN(_car_stack_size, 16);
- size = MIN(size, DCACHE_RAM_ROMSTAGE_STACK_SIZE);
- if (size < DCACHE_RAM_ROMSTAGE_STACK_SIZE)
+ size = MIN(size, stack_size);
+ if (size < stack_size)
printk(BIOS_DEBUG, "Romstage stack size limited to 0x%x!\n",
size);