Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/57068 )
Change subject: soc/amd/common/fsp/fsp_validate: check FSP-M binary size ......................................................................
soc/amd/common/fsp/fsp_validate: check FSP-M binary size
When modules are added to the FSP and they won't fit into the FSP binary any more, the size can be increased in the FSP build. Especially in the case of debug builds the increased size might not fit into the memory region it gets put into which starts at FSP_M_ADDR and has a size of FSP_M_SIZE. SoCs can implement the soc_validate_fsp_version function that ends up being called by the FSP driver in romstage to check the FSP version, but since the image size is also present in the header we can also implement and use this function to check if it fits into the reserved region. Since the FSP-M memory region is located after romstage loading it won't clobber the romstage code where we do the check.
BUG=b:186149011 TEST=Mandolin still boots fine with the patch applied. When as a test the FSP_M_SIZE Kconfig option in soc/amd/picasso is decreased to 0x10000 which is by far not enough for the decompressed FSP-M binary to fit into it prints the newly added error message on the console and then stops.
Signed-off-by: Felix Held felix-coreboot@felixheld.de Change-Id: I9b74a2d03993ba50b166eb6e87d4e57b93afc069 --- M src/soc/amd/common/fsp/Makefile.inc A src/soc/amd/common/fsp/fsp_validate.c 2 files changed, 16 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/68/57068/1
diff --git a/src/soc/amd/common/fsp/Makefile.inc b/src/soc/amd/common/fsp/Makefile.inc index 8a5cef5..f1a78fb 100644 --- a/src/soc/amd/common/fsp/Makefile.inc +++ b/src/soc/amd/common/fsp/Makefile.inc @@ -1,5 +1,6 @@ ifeq ($(CONFIG_PLATFORM_USES_FSP2_0),y) romstage-y += fsp_reset.c +romstage-y += fsp_validate.c ramstage-y += fsp_reset.c ramstage-$(CONFIG_HAVE_ACPI_TABLES) += fsp-acpi.c ramstage-$(CONFIG_SOC_AMD_COMMON_FSP_DMI_TABLES) += dmi.c diff --git a/src/soc/amd/common/fsp/fsp_validate.c b/src/soc/amd/common/fsp/fsp_validate.c new file mode 100644 index 0000000..1a4f9b3 --- /dev/null +++ b/src/soc/amd/common/fsp/fsp_validate.c @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <fsp/util.h> +#include <types.h> + +/* Validate the FSP-M header in romstage */ +void soc_validate_fsp_version(const struct fsp_header *hdr) +{ + /* TODO: Add FSP version number check to see if the UPD interface is compatible. */ + + if (hdr->image_size > CONFIG_FSP_M_SIZE) + die("The FSP-M binary is larger than the memory region allocated for it! " + "Increase FSP_M_SIZE for it to fit into its memory region.\n"); +}