diff options
author | Arthur Heymans <arthur@aheymans.xyz> | 2019-01-08 23:25:04 +0100 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-01-10 12:14:47 +0000 |
commit | 61b22cb930388510d057cdd79392529660fa4a8c (patch) | |
tree | 445957669f60bafb0c98f57f8b79d84f282369e8 /src/drivers | |
parent | 0421ea277c95934d845aa01a47aa1713f16e0bd4 (diff) |
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>
Reviewed-on: https://review.coreboot.org/c/30751
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/intel/fsp1_1/car.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/drivers/intel/fsp1_1/car.c b/src/drivers/intel/fsp1_1/car.c index 13161d66d5..63c5042776 100644 --- a/src/drivers/intel/fsp1_1/car.c +++ b/src/drivers/intel/fsp1_1/car.c @@ -35,6 +35,21 @@ static inline void set_fih_car(FSP_INFO_HEADER *fih) 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 @@ asmlinkage void *cache_as_ram_main(struct cache_as_ram_params *car_params) 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); } |