Dinesh Gehlot has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/75752?usp=email )
Change subject: soc/intel/cmd/blk/cse: Cache CSE version in CMOS memory for cold boots ......................................................................
soc/intel/cmd/blk/cse: Cache CSE version in CMOS memory for cold boots
This patch stores the current CSE version in CMOS memory and update CBMEM version on cold boots.
BUG=b:280722061 Test=Verified the changes nissa board.
Signed-off-by: Dinesh Gehlot digehlot@google.com Change-Id: I80ed134ba4d5434b977faec6d0c69aa103ac0267 --- M src/soc/intel/common/block/cse/cse_lite.c 1 file changed, 32 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/52/75752/1
diff --git a/src/soc/intel/common/block/cse/cse_lite.c b/src/soc/intel/common/block/cse/cse_lite.c index 1865c4f..925d2dc 100644 --- a/src/soc/intel/common/block/cse/cse_lite.c +++ b/src/soc/intel/common/block/cse/cse_lite.c @@ -9,6 +9,7 @@ #include <fmap.h> #include <intelbasecode/debug_feature.h> #include <intelblocks/cse.h> +#include <intelblocks/cse_cmos.h> #include <intelblocks/cse_layout.h> #include <intelblocks/spi.h> #include <security/vboot/misc.h> @@ -1185,10 +1186,38 @@ printk(BIOS_ERR, "cse_lite: Failed to get CSE boot partition info\n"); return; } + size_t vers_size = sizeof(struct fw_version); const struct cse_bp_entry *cse_bp = cse_get_bp_entry(RW, &cse_bp_info.bp_info); - struct cse_fw_partition_info *version; - version = cbmem_add(CBMEM_ID_CSE_PARTITION_VERSION, sizeof(*version)); - memcpy(&(version->cur_cse_fw_version), &(cse_bp->fw_ver), sizeof(struct fw_version)); + struct cse_fw_partition_info *cbmem_fw; + cbmem_fw = cbmem_add(CBMEM_ID_CSE_PARTITION_VERSION, sizeof(*cbmem_fw)); + +#if CONFIG_SOC_INTEL_CACHE_CSE_VERSION_IN_CMOS + struct fw_version prev_cse_fw_version; + get_cmos_cse_version(&prev_cse_fw_version); + + /* + * Compare if stored cse version (from the previous boot) is same as current + * running cse version. + */ + if (memcmp(&prev_cse_fw_version, &(cse_bp->fw_ver), vers_size)) { + /* write cse rw fw version to CMOS */ + set_cmos_cse_version(&(cse_bp->fw_ver)); + + /* write cse rw fw version to CBMEM */ + memcpy(&(cbmem_fw->cur_cse_fw_version), &(cse_bp->fw_ver), vers_size); + } else { + /* Current running CSE version is same as previous stored CSE version */ + if (memcmp(&(cbmem_fw->cur_cse_fw_version), &(cse_bp->fw_ver), vers_size)) { + /* + * The CBMEM memory was reset during cold reboot, so the CSE version in + * CBMEM needs to be updated to the version stored in CMOS. + */ + memcpy(&(cbmem_fw->cur_cse_fw_version), &(cse_bp->fw_ver), vers_size); + } + } +#else + memcpy(&(cbmem_fw->cur_cse_fw_version), &(cse_bp->fw_ver), vers_size); +#endif }
static enum cb_err send_get_fpt_partition_info_cmd(enum fpt_partition_id id,