From 44ffb5dedfcf7aea473f34e43073ffedaec55261 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Thu, 24 May 2018 10:51:29 +0530 Subject: [PATCH] drivers/intel/fsp2_0: Make use of xmalloc for FSP-S UPD Don't allocate FSP-S UPD over stack. This patch reduces stack usage for Cannonlake platform. TEST=On CNL platform stack usage reduces from ~3.6KiB to ~1KiB. Change-Id: I07ef0db6720d7e6865ac1641ce2661009332907c Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/26501 Reviewed-by: Furquan Shaikh Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/drivers/intel/fsp2_0/silicon_init.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/drivers/intel/fsp2_0/silicon_init.c b/src/drivers/intel/fsp2_0/silicon_init.c index bda88d11ca..0461b68078 100644 --- a/src/drivers/intel/fsp2_0/silicon_init.c +++ b/src/drivers/intel/fsp2_0/silicon_init.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,7 @@ struct fsp_header fsps_hdr; static void do_silicon_init(struct fsp_header *hdr) { - FSPS_UPD upd, *supd; + FSPS_UPD *upd, *supd; fsp_silicon_init_fn silicon_init; uint32_t status; @@ -35,19 +36,21 @@ static void do_silicon_init(struct fsp_header *hdr) if (supd->FspUpdHeader.Signature != FSPS_UPD_SIGNATURE) die("Invalid FSPS signature\n"); - memcpy(&upd, supd, sizeof(upd)); + upd = xmalloc(sizeof(FSPS_UPD)); + + memcpy(upd, supd, sizeof(FSPS_UPD)); /* Give SoC/mainboard a chance to populate entries */ - platform_fsp_silicon_init_params_cb(&upd); + platform_fsp_silicon_init_params_cb(upd); /* Call SiliconInit */ silicon_init = (void *) (hdr->image_base + hdr->silicon_init_entry_offset); - fsp_debug_before_silicon_init(silicon_init, supd, &upd); + fsp_debug_before_silicon_init(silicon_init, supd, upd); timestamp_add_now(TS_FSP_SILICON_INIT_START); post_code(POST_FSP_SILICON_INIT); - status = silicon_init(&upd); + status = silicon_init(upd); timestamp_add_now(TS_FSP_SILICON_INIT_END); post_code(POST_FSP_SILICON_EXIT);