Attention is currently required from: Tarun Tuli, Subrata Banik.
Rizwan Qureshi has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/70015 )
Change subject: soc/intel/{common, alderlake}: implement vboot phase 1 handler ......................................................................
soc/intel/{common, alderlake}: implement vboot phase 1 handler
implement a vboot phase 1 platform handler to switch CSE boot partion early in the boot flow
TEST=Build and boot nirwen, make sure CSE parition is switched based on the vboot boot mode. Also make sure that the partition switch does not happen when CSE update is in progress.
Signed-off-by: Rizwan Qureshi rizwan.qureshi@intel.com Change-Id: I2d12fac7dd9f0555d28115275d60934beb85a5e7 --- M src/soc/intel/alderlake/Kconfig M src/soc/intel/common/block/cse/cse_lite.c 2 files changed, 98 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/15/70015/1
diff --git a/src/soc/intel/alderlake/Kconfig b/src/soc/intel/alderlake/Kconfig index 08d4132..622ae5d 100644 --- a/src/soc/intel/alderlake/Kconfig +++ b/src/soc/intel/alderlake/Kconfig @@ -117,6 +117,7 @@ select SOC_INTEL_COMMON_FSP_RESET select SOC_INTEL_COMMON_PCH_CLIENT select SOC_INTEL_COMMON_RESET + select SOC_INTEL_CSE_LITE_SYNC_IN_BOOTBLOCK select SOC_INTEL_CSE_SEND_EOP_EARLY select SOC_INTEL_CSE_SET_EOP select SOC_INTEL_MEM_MAPPED_PM_CONFIGURATION diff --git a/src/soc/intel/common/block/cse/cse_lite.c b/src/soc/intel/common/block/cse/cse_lite.c index f051061..1a7493c 100644 --- a/src/soc/intel/common/block/cse/cse_lite.c +++ b/src/soc/intel/common/block/cse/cse_lite.c @@ -14,6 +14,7 @@ #include <security/vboot/vboot_common.h> #include <soc/intel/common/reset.h> #include <timestamp.h> +#include <vb2_api.h>
#define BPDT_HEADER_SZ sizeof(struct bpdt_header) #define BPDT_ENTRY_SZ sizeof(struct bpdt_entry) @@ -1048,6 +1049,85 @@ return handle_cse_sub_part_fw_update_rv(rv); }
+/* + * Use the vboot_platform_hook_phase1 to switch to the right CSE partition + * WE SHOULD NOT perform any updates to CSE partition here + * +*/ +int vboot_platform_hook_phase1(struct vb2_context *ctx, enum vb2_nv_recovery *rec_reason, + uint8_t *subcode) +{ + static struct get_bp_info_rsp cse_bp_info; + uint8_t boot_mode = ctx->boot_mode; + uint8_t hmrfpo_status = HMRFPO_STATUS_DISABLED; + + printk(BIOS_DEBUG, "Syncing CSE boot partition\n"); + + /* If CSE SKU type is not Lite, skip enabling CSE Lite SKU */ + if (!cse_is_hfs3_fw_sku_lite()) { + printk(BIOS_ERR, "cse_lite: Not a CSE Lite SKU\n"); + return 0; + } + + if (!cse_get_bp_info(&cse_bp_info)) { + printk(BIOS_ERR, "cse_lite: Failed to get CSE boot partition info\n"); + *subcode = CSE_COMMUNICATION_ERROR; + goto failure; + } + + /* + * If HMRFPO is enabled, then update is in progress just alow the system to boot + * in the same mode + */ + if (!cse_hmrfpo_get_status(&hmrfpo_status)) { + printk(BIOS_ERR, "cse_lite: CSE could not get HMRFPO status\n"); + *subcode = CSE_COMMUNICATION_ERROR; + goto failure; + } + + printk(BIOS_DEBUG, "cse_lite: HMRFPO status %d\n", hmrfpo_status); + if (hmrfpo_status == HMRFPO_STATUS_ENABLED) { + printk(BIOS_DEBUG, "HMRFPO Enabled, not switching\n"); + return 0; + } + + /* + * If there are any errors, dont try to fix here and also dont try switch boot mode + * allow the errors to be handled later + */ + if (!cse_fix_data_failure_err(&cse_bp_info.bp_info)) { + printk(BIOS_ERR, "cse_lite: CSE data error could not be fixed\n"); + return 0; + } + + if (!cse_is_rw_bp_status_valid(&cse_bp_info.bp_info)) { + printk(BIOS_ERR, "cse_lite: Boot partition errors\n"); + return 0; + } + + if ((boot_mode == VB2_BOOT_MODE_NORMAL || boot_mode == VB2_BOOT_MODE_DEVELOPER) + && cse_bp_info.bp_info.current_bp == 0) { + if (!cse_boot_to_rw(&cse_bp_info.bp_info)) { + printk(BIOS_ERR, "cse_lite: Failed to switch to RW\n"); + *subcode = CSE_LITE_SKU_RW_SWITCH_ERROR; + goto failure; + } + } else if (boot_mode == VB2_BOOT_MODE_MANUAL_RECOVERY && + cse_bp_info.bp_info.current_bp == 1) { + if (!cse_boot_to_ro(&cse_bp_info.bp_info)){ + printk(BIOS_ERR, "cse_lite: Failed to switch to RO\n"); + *subcode = CSE_LITE_SKU_RW_SWITCH_ERROR; + goto failure; + } + } + + return 0; + +failure: + *rec_reason = VB2_RECOVERY_INTEL_CSE_LITE_SKU; + return 1; +} + void cse_fw_sync(void) { static struct get_bp_info_rsp cse_bp_info;