Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/30751
Change subject: drivers/intel/fsp1_1: Add stack guards ......................................................................
drivers/intel/fsp1_1: Add stack guards
This allows to check if stack overflows the car globals.
Change-Id: I369b2d846f35914facb3e69cc762f7e555271bec Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/drivers/intel/fsp1_1/car.c 1 file changed, 22 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/30751/1
diff --git a/src/drivers/intel/fsp1_1/car.c b/src/drivers/intel/fsp1_1/car.c index 13161d6..63c5042 100644 --- a/src/drivers/intel/fsp1_1/car.c +++ b/src/drivers/intel/fsp1_1/car.c @@ -35,6 +35,21 @@
asmlinkage void *cache_as_ram_main(struct cache_as_ram_params *car_params) { + int i; + const int num_guards = 4; + const u32 stack_guard = 0xdeadbeef; + u32 *stack_base; + u32 size; + + /* Size of unallocated CAR. */ + size = _car_region_end - _car_relocatable_data_end; + size = ALIGN_DOWN(size, 16); + + stack_base = (u32 *) (_car_region_end - size); + + for (i = 0; i < num_guards; i++) + stack_base[i] = stack_guard; + /* Initialize timestamp book keeping only once. */ timestamp_init(car_params->tsc);
@@ -63,6 +78,13 @@
set_fih_car(car_params->fih);
+ /* Check the stack. */ + for (i = 0; i < num_guards; i++) { + if (stack_base[i] == stack_guard) + continue; + printk(BIOS_DEBUG, "Smashed stack detected in romstage!\n"); + } + /* Return new stack value in RAM back to assembly stub. */ return cache_as_ram_stage_main(car_params->fih); }