From a319ac3a19883bd826a47a85d1c6586d38446a7b Mon Sep 17 00:00:00 2001 From: Felix Held Date: Tue, 14 Jul 2020 00:52:14 +0200 Subject: soc/amd/picasso/fsp_params: add asserts for descriptor count With the updated FSP UPD headers there are enough DXIO descriptor slots in the UPD, so we can now add asserts to make sure that the mainboard doesn't pass more DXIO/DDI descriptors than the UPD has slots for. This is part of the DXIO/DDI descriptor handling cleanup. BUG=b:158695393 Change-Id: Ia220d5a9d4ff11707b795b04662ff7eead4e2888 Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/c/coreboot/+/43435 Reviewed-by: Angel Pons Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/soc/amd/picasso/fsp_params.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/soc/amd') diff --git a/src/soc/amd/picasso/fsp_params.c b/src/soc/amd/picasso/fsp_params.c index 8683e9b836..e7169d1283 100644 --- a/src/soc/amd/picasso/fsp_params.c +++ b/src/soc/amd/picasso/fsp_params.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include #include #include #include @@ -60,6 +61,9 @@ static void fill_dxio_descriptors(FSP_S_CONFIG *scfg, { size_t i; + ASSERT_MSG(num <= FSPS_UPD_DXIO_DESCRIPTOR_COUNT, + "Too many DXIO descriptors provided."); + for (i = 0; i < num; i++) { memcpy(scfg->dxio_descriptor[i], &descs[i], sizeof(scfg->dxio_descriptor[0])); } @@ -70,6 +74,9 @@ static void fill_ddi_descriptors(FSP_S_CONFIG *scfg, { size_t i; + ASSERT_MSG(num <= FSPS_UPD_DDI_DESCRIPTOR_COUNT, + "Too many DDI descriptors provided."); + for (i = 0; i < num; i++) { memcpy(&scfg->ddi_descriptor[i], &descs[i], sizeof(scfg->ddi_descriptor[0])); } -- cgit v1.2.3