Attention is currently required from: Andrey Petrov.
Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/75921?usp=email )
Change subject: {commonlib/drivers}: Have option to store MRC version inside CBMEM ......................................................................
{commonlib/drivers}: Have option to store MRC version inside CBMEM
This patch introduces CBMEM ID to store the MRC version (similar to existing implementation that stores the FSP-M version inside CBMEM ID) inside cbmem so the version information is available across the different coreboot stages. For example:
* romstage: Use the CBMEM ID version information to check if the MRC cache is valid and need to erase the MRC cache * ramstage: Use the CBMEM ID to store the MRC cache into the non-volatile space.
BUG=b:261689642 TEST=Able to build and boot google/rex and dump the MRC version as below.
cbmem --list CBMEM table of contents: NAME ID START LENGTH ... 21. MRC VERSION 5f43524d 75ffeb60 00000004 ...
Signed-off-by: Subrata Banik subratabanik@google.com Change-Id: I91f735239b33c6f8ba41c076048903e4b213c6a2 --- M src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h M src/drivers/intel/fsp2_0/memory_init.c M src/drivers/intel/fsp2_0/save_mrc_data.c 3 files changed, 28 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/21/75921/1
diff --git a/src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h b/src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h index 5080812..8e6e6cd 100644 --- a/src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h +++ b/src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h @@ -27,6 +27,7 @@ #define CBMEM_ID_FSP_RESERVED_MEMORY 0x46535052 #define CBMEM_ID_FSP_RUNTIME 0x52505346 #define CBMEM_ID_FSPM_VERSION 0x56505346 +#define CBMEM_ID_MRC_VERSION 0x5f43524d #define CBMEM_ID_GDT 0x4c474454 #define CBMEM_ID_HOB_POINTER 0x484f4221 #define CBMEM_ID_IGD_OPREGION 0x4f444749 @@ -112,6 +113,7 @@ { CBMEM_ID_FSP_RESERVED_MEMORY, "FSP MEMORY " }, \ { CBMEM_ID_FSP_RUNTIME, "FSP RUNTIME" }, \ { CBMEM_ID_FSPM_VERSION, "FSPM VERSION" }, \ + { CBMEM_ID_MRC_VERSION, "MRC VERSION" }, \ { CBMEM_ID_GDT, "GDT " }, \ { CBMEM_ID_HOB_POINTER, "HOB " }, \ { CBMEM_ID_IGD_OPREGION, "IGD OPREGION" }, \ diff --git a/src/drivers/intel/fsp2_0/memory_init.c b/src/drivers/intel/fsp2_0/memory_init.c index 8c36587..9b4cf47 100644 --- a/src/drivers/intel/fsp2_0/memory_init.c +++ b/src/drivers/intel/fsp2_0/memory_init.c @@ -30,10 +30,25 @@
static uint8_t temp_ram[CONFIG_FSP_TEMP_RAM_SIZE] __aligned(sizeof(uint64_t));
+/* + * Helper function to store the MRC cache version into CBMEM + * + * ramstage uses either the MRC version or FSP-M version (depending on the config) + * when updating the MRC cache + */ +static void do_cbmem_version_entry(uint32_t cbmem_id, uint32_t version) +{ + uint32_t *cbmem_version_entry = cbmem_add(cbmem_id, sizeof(version)); + if (!cbmem_version_entry) { + printk(BIOS_ERR, "Failed to add cbmem entry id (%d).\n", cbmem_id); + return; + } + *cbmem_version_entry = version; +} + static void do_fsp_post_memory_init(bool s3wake, uint32_t version) { struct range_entry fsp_mem; - uint32_t *fsp_version_cbmem;
fsp_find_reserved_memory(&fsp_mem);
@@ -56,13 +71,11 @@ (uintptr_t)cbmem_find(CBMEM_ID_FSP_RESERVED_MEMORY)) die("Failed to accommodate FSP reserved memory request!\n");
- /* ramstage uses the FSP-M version when updating the MRC cache */ if (CONFIG(CACHE_MRC_SETTINGS) && !s3wake) { - fsp_version_cbmem = cbmem_add(CBMEM_ID_FSPM_VERSION, - sizeof(version)); - if (!fsp_version_cbmem) - printk(BIOS_ERR, "Failed to add FSP-M version to cbmem.\n"); - *fsp_version_cbmem = version; + if (CONFIG(MRC_CACHE_USING_MRC_VERSION)) + do_cbmem_version_entry(CBMEM_ID_MRC_VERSION, version); + else + do_cbmem_version_entry(CBMEM_ID_FSPM_VERSION, version); }
/* Create romstage handof information */ diff --git a/src/drivers/intel/fsp2_0/save_mrc_data.c b/src/drivers/intel/fsp2_0/save_mrc_data.c index d124942..b2b7334 100644 --- a/src/drivers/intel/fsp2_0/save_mrc_data.c +++ b/src/drivers/intel/fsp2_0/save_mrc_data.c @@ -16,9 +16,13 @@ if (acpi_is_wakeup_s3()) return;
- version = cbmem_find(CBMEM_ID_FSPM_VERSION); + if (CONFIG(MRC_CACHE_USING_MRC_VERSION)) + version = cbmem_find(CBMEM_ID_MRC_VERSION); + else + version = cbmem_find(CBMEM_ID_FSPM_VERSION); + if (!version) { - printk(BIOS_ERR, "Failed to read FSP-M version from cbmem.\n"); + printk(BIOS_ERR, "Failed to read FSP-M/MRC version from cbmem.\n"); return; }