Dinesh Gehlot has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/75755?usp=email )
Change subject: soc/intel/cmd/blk/cse: Cache ISH version in CMOS memory for cold boots ......................................................................
soc/intel/cmd/blk/cse: Cache ISH version in CMOS memory for cold boots
This patch stores the current ISH version in CMOS memory.
BUG=b:280722061 Test=Verified the changes nissa board.
Signed-off-by: Dinesh Gehlot digehlot@google.com Change-Id: Ibc5a027aa2bb7217e5032f56fece0846783557a5 --- M src/soc/intel/common/block/cse/cse_lite.c 1 file changed, 69 insertions(+), 74 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/75755/1
diff --git a/src/soc/intel/common/block/cse/cse_lite.c b/src/soc/intel/common/block/cse/cse_lite.c index 925d2dc..3dc7b7d 100644 --- a/src/soc/intel/common/block/cse/cse_lite.c +++ b/src/soc/intel/common/block/cse/cse_lite.c @@ -1172,54 +1172,6 @@ timestamp_add_now(TS_CSE_FW_SYNC_END); }
-/* - * Helper function that stores current CSE firmware version to CBMEM memory, - * except during recovery mode. - */ -static void store_cse_rw_fw_version(void) -{ - if (vboot_recovery_mode_enabled()) - return; - - struct get_bp_info_rsp cse_bp_info; - if (cse_get_bp_info(&cse_bp_info) != CB_SUCCESS) { - 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 *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, struct fw_version_resp *resp) { @@ -1285,43 +1237,90 @@ * This is because the command relies on resources that are not available * until DRAM initialization command has been sent. */ -static void store_ish_version(void) +static void store_ish_version(struct cse_fw_partition_info *cbmem_fw) { - if (!ENV_RAMSTAGE) + if (!CONFIG(SOC_INTEL_STORE_CSE_FPT_PARTITION_VERSION) || + soc_is_ish_partition_enabled() == false) return;
- if (vboot_recovery_mode_enabled()) + /* Get current ISH firmware version from CSE */ + struct fw_version_resp resp; + if (cse_get_fpt_partition_info(FPT_PARTITION_NAME_ISHC, &resp) == CB_SUCCESS) { +#if CONFIG_SOC_INTEL_CACHE_ISH_VERSION_IN_CMOS + /* Update cmos stored ISH version with current version */ + set_cmos_ish_version(&(resp.manifest_data.version)); +#endif + /* Update cbmem stored ISH version with current version */ + memcpy(&(cbmem_fw->ish_partition_info.cur_ish_fw_version), + &(resp.manifest_data.version), sizeof(struct fw_version)); + } +} + +/* + * Helper function that stores current CSE firmware version to CBMEM memory, + * except during recovery mode. + */ +static void store_cse_rw_fw_version(void) +{ + if (!ENV_RAMSTAGE || vboot_recovery_mode_enabled()) return;
- struct cse_fw_partition_info *version; - size_t size = sizeof(struct fw_version); - version = cbmem_find(CBMEM_ID_CSE_PARTITION_VERSION); - if (version == NULL) + struct get_bp_info_rsp cse_bp_info; + if (cse_get_bp_info(&cse_bp_info) != CB_SUCCESS) { + 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 *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(&version->ish_partition_info.prev_cse_fw_version, - &version->cur_cse_fw_version, sizeof(struct fw_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); + store_ish_version(cbmem_fw); + } 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 firmware + * versions 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); +#if CONFIG_SOC_INTEL_CACHE_ISH_VERSION_IN_CMOS + if(soc_is_ish_partition_enabled()) { + struct fw_version cmos_ish_version; + get_cmos_ish_version(&cmos_ish_version); + memcpy(&(cbmem_fw->ish_partition_info.cur_ish_fw_version), + &cmos_ish_version, vers_size); + } +#endif /* CONFIG_SOC_INTEL_CACHE_ISH_VERSION_IN_CMOS */ + } + } +#else + memcpy(&(cbmem_fw->cur_cse_fw_version), &(cse_bp->fw_ver), vers_size); + if (memcmp(&cbmem_fw->ish_partition_info.prev_cse_fw_version, + &cbmem_fw->cur_cse_fw_version, vers_size)) { /* * Current running CSE version is different than previous stored CSE version * which could be due to CSE update or rollback, hence, need to send ISHC * partition info cmd to know the currently running ISH version. */ - - struct fw_version_resp resp; - if (cse_get_fpt_partition_info(FPT_PARTITION_NAME_ISHC, &resp) == CB_SUCCESS) { - /* Update stored cse version with current version */ - memcpy(&(version->ish_partition_info.prev_cse_fw_version), - &(version->cur_cse_fw_version), size); - - /* Since cse version has been updated, ish version needs to be updated. */ - memcpy(&(version->ish_partition_info.cur_ish_fw_version), - &(resp.manifest_data.version), size); - } + store_ish_version(cbmem_fw); + memcpy(&(cbmem_fw->ish_partition_info.prev_cse_fw_version), + &cbmem_fw->cur_cse_fw_version, vers_size); } +#endif /* CONFIG_SOC_INTEL_CACHE_CSE_VERSION_IN_CMOS */ }
static void ramstage_cse_misc_ops(void *unused) @@ -1332,16 +1331,12 @@ if (CONFIG(SOC_INTEL_CSE_LITE_SYNC_IN_RAMSTAGE)) cse_fw_sync();
- if (CONFIG(SOC_INTEL_STORE_CSE_VERSION)) - store_cse_rw_fw_version(); /* * Store the CSE/ISH RW Firmware Version into CBMEM if ISH partition * is available */ - if (CONFIG(SOC_INTEL_STORE_CSE_FPT_PARTITION_VERSION) && - soc_is_ish_partition_enabled()) { - store_ish_version(); - } + if (CONFIG(SOC_INTEL_STORE_CSE_VERSION)) + store_cse_rw_fw_version(); }
BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_EXIT, ramstage_cse_misc_ops, NULL);