Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Elyes HAOUAS | 944da48 | 2021-02-01 21:30:13 +0100 | [diff] [blame] | 2 | |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 3 | #include <console/console.h> |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 4 | #include <cbfs.h> |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 5 | #include <commonlib/region.h> |
| 6 | #include <fmap.h> |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 7 | #include <intelblocks/cse.h> |
Krishna Prasad Bhat | 333edcc | 2021-11-26 06:52:27 +0530 | [diff] [blame^] | 8 | #include <intelblocks/cse_layout.h> |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 9 | #include <security/vboot/vboot_common.h> |
Sridhar Siricilla | 87e36c4 | 2020-05-03 19:08:18 +0530 | [diff] [blame] | 10 | #include <security/vboot/misc.h> |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 11 | #include <soc/intel/common/reset.h> |
Krishna Prasad Bhat | 333edcc | 2021-11-26 06:52:27 +0530 | [diff] [blame^] | 12 | #include <arch/cpu.h> |
| 13 | |
| 14 | #define BPDT_HEADER_SZ sizeof(struct bpdt_header) |
| 15 | #define BPDT_ENTRY_SZ sizeof(struct bpdt_entry) |
| 16 | #define SUBPART_HEADER_SZ sizeof(struct subpart_hdr) |
| 17 | #define SUBPART_ENTRY_SZ sizeof(struct subpart_entry) |
| 18 | #define SUBPART_MANIFEST_HDR_SZ sizeof(struct subpart_entry_manifest_header) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 19 | |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 20 | /* Converts bp index to boot partition string */ |
| 21 | #define GET_BP_STR(bp_index) (bp_index ? "RW" : "RO") |
| 22 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 23 | /* CSE RW boot partition signature */ |
| 24 | #define CSE_RW_SIGNATURE 0x000055aa |
| 25 | |
| 26 | /* CSE RW boot partition signature size */ |
| 27 | #define CSE_RW_SIGN_SIZE sizeof(uint32_t) |
| 28 | |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 29 | /* |
Sridhar Siricilla | 99dbca3 | 2020-05-12 21:05:04 +0530 | [diff] [blame] | 30 | * CSE Firmware supports 3 boot partitions. For CSE Lite SKU, only 2 boot partitions are |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 31 | * used and 3rd boot partition is set to BP_STATUS_PARTITION_NOT_PRESENT. |
Sridhar Siricilla | 99dbca3 | 2020-05-12 21:05:04 +0530 | [diff] [blame] | 32 | * CSE Lite SKU Image Layout: |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 33 | * ------------- ------------------- --------------------- |
| 34 | * |CSE REGION | => | RO | RW | DATA | => | BP1 | BP2 | DATA | |
| 35 | * ------------- ------------------- --------------------- |
| 36 | */ |
| 37 | #define CSE_MAX_BOOT_PARTITIONS 3 |
| 38 | |
Sridhar Siricilla | 99dbca3 | 2020-05-12 21:05:04 +0530 | [diff] [blame] | 39 | /* CSE Lite SKU's valid bootable partition identifiers */ |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 40 | enum boot_partition_id { |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 41 | /* RO(BP1) contains recovery/minimal boot firmware */ |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 42 | RO = 0, |
| 43 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 44 | /* RW(BP2) contains fully functional CSE firmware */ |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 45 | RW = 1 |
| 46 | }; |
| 47 | |
| 48 | /* |
| 49 | * Boot partition status. |
| 50 | * The status is returned in response to MKHI_BUP_COMMON_GET_BOOT_PARTITION_INFO cmd. |
| 51 | */ |
| 52 | enum bp_status { |
| 53 | /* This value is returned when a partition has no errors */ |
| 54 | BP_STATUS_SUCCESS = 0, |
| 55 | |
| 56 | /* |
| 57 | * This value is returned when a partition should be present based on layout, but it is |
| 58 | * not valid. |
| 59 | */ |
| 60 | BP_STATUS_GENERAL_FAILURE = 1, |
| 61 | |
| 62 | /* This value is returned when a partition is not present per initial image layout */ |
| 63 | BP_STATUS_PARTITION_NOT_PRESENT = 2, |
| 64 | |
Sridhar Siricilla | 2f6d555 | 2020-04-19 23:39:02 +0530 | [diff] [blame] | 65 | /* |
| 66 | * This value is returned when unexpected issues are detected in CSE Data area |
| 67 | * and CSE TCB-SVN downgrade scenario. |
| 68 | */ |
| 69 | BP_STATUS_DATA_FAILURE = 3, |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | /* |
| 73 | * Boot Partition Info Flags |
| 74 | * The flags are returned in response to MKHI_BUP_COMMON_GET_BOOT_PARTITION_INFO cmd. |
| 75 | */ |
| 76 | enum bp_info_flags { |
| 77 | |
| 78 | /* Redundancy Enabled: It indicates CSE supports RO(BP1) and RW(BP2) regions */ |
| 79 | BP_INFO_REDUNDANCY_EN = 1 << 0, |
| 80 | |
| 81 | /* It indicates RO(BP1) supports Minimal Recovery Mode */ |
| 82 | BP_INFO_MIN_RECOV_MODE_EN = 1 << 1, |
| 83 | |
| 84 | /* |
| 85 | * Read-only Config Enabled: It indicates HW protection to CSE RO region is enabled. |
| 86 | * The option is relevant only if the BP_INFO_MIN_RECOV_MODE_EN flag is enabled. |
| 87 | */ |
| 88 | BP_INFO_READ_ONLY_CFG = 1 << 2, |
| 89 | }; |
| 90 | |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 91 | /* CSE boot partition entry info */ |
| 92 | struct cse_bp_entry { |
| 93 | /* Boot partition version */ |
| 94 | struct fw_version fw_ver; |
| 95 | |
| 96 | /* Boot partition status */ |
| 97 | uint32_t status; |
| 98 | |
| 99 | /* Starting offset of the partition within CSE region */ |
| 100 | uint32_t start_offset; |
| 101 | |
| 102 | /* Ending offset of the partition within CSE region */ |
| 103 | uint32_t end_offset; |
| 104 | uint8_t reserved[12]; |
| 105 | } __packed; |
| 106 | |
| 107 | /* CSE boot partition info */ |
| 108 | struct cse_bp_info { |
| 109 | /* Number of boot partitions */ |
| 110 | uint8_t total_number_of_bp; |
| 111 | |
| 112 | /* Current boot partition */ |
| 113 | uint8_t current_bp; |
| 114 | |
| 115 | /* Next boot partition */ |
| 116 | uint8_t next_bp; |
| 117 | |
| 118 | /* Boot Partition Info Flags */ |
| 119 | uint8_t flags; |
| 120 | |
| 121 | /* Boot Partition Entry Info */ |
| 122 | struct cse_bp_entry bp_entries[CSE_MAX_BOOT_PARTITIONS]; |
| 123 | } __packed; |
| 124 | |
| 125 | struct get_bp_info_rsp { |
| 126 | struct mkhi_hdr hdr; |
| 127 | struct cse_bp_info bp_info; |
| 128 | } __packed; |
| 129 | |
| 130 | static uint8_t cse_get_current_bp(const struct cse_bp_info *cse_bp_info) |
| 131 | { |
| 132 | return cse_bp_info->current_bp; |
| 133 | } |
| 134 | |
| 135 | static const struct cse_bp_entry *cse_get_bp_entry(enum boot_partition_id bp, |
| 136 | const struct cse_bp_info *cse_bp_info) |
| 137 | { |
| 138 | return &cse_bp_info->bp_entries[bp]; |
| 139 | } |
| 140 | |
| 141 | static void cse_print_boot_partition_info(const struct cse_bp_info *cse_bp_info) |
| 142 | { |
| 143 | const struct cse_bp_entry *cse_bp; |
| 144 | |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 145 | printk(BIOS_DEBUG, "cse_lite: Number of partitions = %d\n", |
| 146 | cse_bp_info->total_number_of_bp); |
| 147 | printk(BIOS_DEBUG, "cse_lite: Current partition = %s\n", |
| 148 | GET_BP_STR(cse_bp_info->current_bp)); |
| 149 | printk(BIOS_DEBUG, "cse_lite: Next partition = %s\n", GET_BP_STR(cse_bp_info->next_bp)); |
| 150 | printk(BIOS_DEBUG, "cse_lite: Flags = 0x%x\n", cse_bp_info->flags); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 151 | |
| 152 | /* Log version info of RO & RW partitions */ |
| 153 | cse_bp = cse_get_bp_entry(RO, cse_bp_info); |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 154 | printk(BIOS_DEBUG, "cse_lite: %s version = %d.%d.%d.%d (Status=0x%x, Start=0x%x, End=0x%x)\n", |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 155 | GET_BP_STR(RO), cse_bp->fw_ver.major, cse_bp->fw_ver.minor, |
| 156 | cse_bp->fw_ver.hotfix, cse_bp->fw_ver.build, |
| 157 | cse_bp->status, cse_bp->start_offset, |
| 158 | cse_bp->end_offset); |
| 159 | |
| 160 | cse_bp = cse_get_bp_entry(RW, cse_bp_info); |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 161 | printk(BIOS_DEBUG, "cse_lite: %s version = %d.%d.%d.%d (Status=0x%x, Start=0x%x, End=0x%x)\n", |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 162 | GET_BP_STR(RW), cse_bp->fw_ver.major, cse_bp->fw_ver.minor, |
| 163 | cse_bp->fw_ver.hotfix, cse_bp->fw_ver.build, |
| 164 | cse_bp->status, cse_bp->start_offset, |
| 165 | cse_bp->end_offset); |
| 166 | } |
| 167 | |
| 168 | /* |
| 169 | * Checks prerequisites for MKHI_BUP_COMMON_GET_BOOT_PARTITION_INFO and |
| 170 | * MKHI_BUP_COMMON_SET_BOOT_PARTITION_INFO HECI commands. |
| 171 | * It allows execution of the Boot Partition commands in below scenarios: |
| 172 | * - When CSE boots from RW partition (COM: Normal and CWS: Normal) |
| 173 | * - When CSE boots from RO partition (COM: Soft Temp Disable and CWS: Normal) |
| 174 | * - After HMRFPO_ENABLE command is issued to CSE (COM: SECOVER_MEI_MSG and CWS: Normal) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 175 | * The prerequisite check should be handled in cse_get_bp_info() and |
| 176 | * cse_set_next_boot_partition() since the CSE's current operation mode is changed between these |
| 177 | * cmd handler calls. |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 178 | */ |
| 179 | static bool cse_is_bp_cmd_info_possible(void) |
| 180 | { |
| 181 | if (cse_is_hfs1_cws_normal()) { |
| 182 | if (cse_is_hfs1_com_normal()) |
| 183 | return true; |
| 184 | if (cse_is_hfs1_com_secover_mei_msg()) |
| 185 | return true; |
| 186 | if (cse_is_hfs1_com_soft_temp_disable()) |
| 187 | return true; |
| 188 | } |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | static bool cse_get_bp_info(struct get_bp_info_rsp *bp_info_rsp) |
| 193 | { |
| 194 | struct get_bp_info_req { |
| 195 | struct mkhi_hdr hdr; |
| 196 | uint8_t reserved[4]; |
| 197 | } __packed; |
| 198 | |
| 199 | struct get_bp_info_req info_req = { |
| 200 | .hdr.group_id = MKHI_GROUP_ID_BUP_COMMON, |
| 201 | .hdr.command = MKHI_BUP_COMMON_GET_BOOT_PARTITION_INFO, |
| 202 | .reserved = {0}, |
| 203 | }; |
| 204 | |
| 205 | if (!cse_is_bp_cmd_info_possible()) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 206 | printk(BIOS_ERR, "cse_lite: CSE does not meet prerequisites\n"); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 207 | return false; |
| 208 | } |
| 209 | |
| 210 | size_t resp_size = sizeof(struct get_bp_info_rsp); |
| 211 | |
Rizwan Qureshi | 957857d | 2021-08-30 16:43:57 +0530 | [diff] [blame] | 212 | if (!heci_send_receive(&info_req, sizeof(info_req), bp_info_rsp, &resp_size, |
| 213 | HECI_MKHI_ADDR)) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 214 | printk(BIOS_ERR, "cse_lite: Could not get partition info\n"); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 215 | return false; |
| 216 | } |
| 217 | |
| 218 | if (bp_info_rsp->hdr.result) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 219 | printk(BIOS_ERR, "cse_lite: Get partition info resp failed: %d\n", |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 220 | bp_info_rsp->hdr.result); |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | cse_print_boot_partition_info(&bp_info_rsp->bp_info); |
| 225 | |
| 226 | return true; |
| 227 | } |
| 228 | /* |
| 229 | * It sends HECI command to notify CSE about its next boot partition. When coreboot wants |
| 230 | * CSE to boot from certain partition (BP1 <RO> or BP2 <RW>), then this command can be used. |
| 231 | * The CSE's valid bootable partitions are BP1(RO) and BP2(RW). |
| 232 | * This function must be used before EOP. |
| 233 | * Returns false on failure and true on success. |
| 234 | */ |
| 235 | static bool cse_set_next_boot_partition(enum boot_partition_id bp) |
| 236 | { |
| 237 | struct set_boot_partition_info_req { |
| 238 | struct mkhi_hdr hdr; |
| 239 | uint8_t next_bp; |
| 240 | uint8_t reserved[3]; |
| 241 | } __packed; |
| 242 | |
| 243 | struct set_boot_partition_info_req switch_req = { |
| 244 | .hdr.group_id = MKHI_GROUP_ID_BUP_COMMON, |
| 245 | .hdr.command = MKHI_BUP_COMMON_SET_BOOT_PARTITION_INFO, |
| 246 | .next_bp = bp, |
| 247 | .reserved = {0}, |
| 248 | }; |
| 249 | |
| 250 | if (bp != RO && bp != RW) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 251 | printk(BIOS_ERR, "cse_lite: Incorrect partition id(%d) is provided", bp); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 252 | return false; |
| 253 | } |
| 254 | |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 255 | printk(BIOS_INFO, "cse_lite: Set Boot Partition Info Command (%s)\n", GET_BP_STR(bp)); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 256 | |
| 257 | if (!cse_is_bp_cmd_info_possible()) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 258 | printk(BIOS_ERR, "cse_lite: CSE does not meet prerequisites\n"); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 259 | return false; |
| 260 | } |
| 261 | |
| 262 | struct mkhi_hdr switch_resp; |
| 263 | size_t sw_resp_sz = sizeof(struct mkhi_hdr); |
| 264 | |
Rizwan Qureshi | 957857d | 2021-08-30 16:43:57 +0530 | [diff] [blame] | 265 | if (!heci_send_receive(&switch_req, sizeof(switch_req), &switch_resp, &sw_resp_sz, |
| 266 | HECI_MKHI_ADDR)) |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 267 | return false; |
| 268 | |
| 269 | if (switch_resp.result) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 270 | printk(BIOS_ERR, "cse_lite: Set Boot Partition Info Response Failed: %d\n", |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 271 | switch_resp.result); |
| 272 | return false; |
| 273 | } |
| 274 | |
| 275 | return true; |
| 276 | } |
| 277 | |
V Sowmya | f990552 | 2020-11-12 20:19:04 +0530 | [diff] [blame] | 278 | static bool cse_data_clear_request(const struct cse_bp_info *cse_bp_info) |
| 279 | { |
| 280 | struct data_clr_request { |
| 281 | struct mkhi_hdr hdr; |
| 282 | uint8_t reserved[4]; |
| 283 | } __packed; |
| 284 | |
| 285 | struct data_clr_request data_clr_rq = { |
| 286 | .hdr.group_id = MKHI_GROUP_ID_BUP_COMMON, |
| 287 | .hdr.command = MKHI_BUP_COMMON_DATA_CLEAR, |
| 288 | .reserved = {0}, |
| 289 | }; |
| 290 | |
| 291 | if (!cse_is_hfs1_cws_normal() || !cse_is_hfs1_com_soft_temp_disable() || |
| 292 | cse_get_current_bp(cse_bp_info) != RO) { |
| 293 | printk(BIOS_ERR, "cse_lite: CSE doesn't meet DATA CLEAR cmd prerequisites\n"); |
| 294 | return false; |
| 295 | } |
| 296 | |
| 297 | printk(BIOS_DEBUG, "cse_lite: Sending DATA CLEAR HECI command\n"); |
| 298 | |
| 299 | struct mkhi_hdr data_clr_rsp; |
| 300 | size_t data_clr_rsp_sz = sizeof(data_clr_rsp); |
| 301 | |
| 302 | if (!heci_send_receive(&data_clr_rq, sizeof(data_clr_rq), &data_clr_rsp, |
Rizwan Qureshi | 957857d | 2021-08-30 16:43:57 +0530 | [diff] [blame] | 303 | &data_clr_rsp_sz, HECI_MKHI_ADDR)) { |
V Sowmya | f990552 | 2020-11-12 20:19:04 +0530 | [diff] [blame] | 304 | return false; |
| 305 | } |
| 306 | |
| 307 | if (data_clr_rsp.result) { |
| 308 | printk(BIOS_ERR, "cse_lite: CSE DATA CLEAR command response failed: %d\n", |
| 309 | data_clr_rsp.result); |
| 310 | return false; |
| 311 | } |
| 312 | |
| 313 | return true; |
| 314 | } |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 315 | |
Karthikeyan Ramasubramanian | f9cc637 | 2020-08-04 16:38:58 -0600 | [diff] [blame] | 316 | __weak void cse_board_reset(void) |
| 317 | { |
| 318 | /* Default weak implementation, does nothing. */ |
| 319 | } |
| 320 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 321 | /* Set the CSE's next boot partition and issues system reset */ |
| 322 | static bool cse_set_and_boot_from_next_bp(enum boot_partition_id bp) |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 323 | { |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 324 | if (!cse_set_next_boot_partition(bp)) |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 325 | return false; |
| 326 | |
Karthikeyan Ramasubramanian | f9cc637 | 2020-08-04 16:38:58 -0600 | [diff] [blame] | 327 | /* Allow the board to perform a reset for CSE RO<->RW jump */ |
| 328 | cse_board_reset(); |
| 329 | |
| 330 | /* If board does not perform the reset, then perform global_reset */ |
Furquan Shaikh | b13bd1e | 2020-09-21 22:44:27 +0000 | [diff] [blame] | 331 | do_global_reset(); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 332 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 333 | die("cse_lite: Failed to reset the system\n"); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 334 | |
| 335 | /* Control never reaches here */ |
| 336 | return false; |
| 337 | } |
| 338 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 339 | static bool cse_boot_to_rw(const struct cse_bp_info *cse_bp_info) |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 340 | { |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 341 | if (cse_get_current_bp(cse_bp_info) == RW) |
| 342 | return true; |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 343 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 344 | return cse_set_and_boot_from_next_bp(RW); |
| 345 | } |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 346 | |
V Sowmya | f990552 | 2020-11-12 20:19:04 +0530 | [diff] [blame] | 347 | /* Check if CSE RW data partition is valid or not */ |
| 348 | static bool cse_is_rw_dp_valid(const struct cse_bp_info *cse_bp_info) |
| 349 | { |
| 350 | const struct cse_bp_entry *rw_bp; |
| 351 | |
| 352 | rw_bp = cse_get_bp_entry(RW, cse_bp_info); |
| 353 | return rw_bp->status != BP_STATUS_DATA_FAILURE; |
| 354 | } |
| 355 | |
| 356 | /* |
| 357 | * It returns true if RW partition doesn't indicate BP_STATUS_DATA_FAILURE |
| 358 | * otherwise false if any operation fails. |
| 359 | */ |
| 360 | static bool cse_fix_data_failure_err(const struct cse_bp_info *cse_bp_info) |
| 361 | { |
| 362 | /* |
| 363 | * If RW partition status indicates BP_STATUS_DATA_FAILURE, |
| 364 | * - Send DATA CLEAR HECI command to CSE |
| 365 | * - Send SET BOOT PARTITION INFO(RW) command to set CSE's next partition |
| 366 | * - Issue GLOBAL RESET HECI command. |
| 367 | */ |
| 368 | if (cse_is_rw_dp_valid(cse_bp_info)) |
| 369 | return true; |
| 370 | |
| 371 | if (!cse_data_clear_request(cse_bp_info)) |
| 372 | return false; |
| 373 | |
| 374 | return cse_boot_to_rw(cse_bp_info); |
| 375 | } |
| 376 | |
V Sowmya | f990552 | 2020-11-12 20:19:04 +0530 | [diff] [blame] | 377 | static const struct fw_version *cse_get_bp_entry_version(enum boot_partition_id bp, |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 378 | const struct cse_bp_info *bp_info) |
V Sowmya | f990552 | 2020-11-12 20:19:04 +0530 | [diff] [blame] | 379 | { |
| 380 | const struct cse_bp_entry *cse_bp; |
| 381 | |
| 382 | cse_bp = cse_get_bp_entry(bp, bp_info); |
| 383 | return &cse_bp->fw_ver; |
| 384 | } |
| 385 | |
| 386 | static const struct fw_version *cse_get_rw_version(const struct cse_bp_info *cse_bp_info) |
| 387 | { |
| 388 | return cse_get_bp_entry_version(RW, cse_bp_info); |
| 389 | } |
| 390 | |
| 391 | static void cse_get_bp_entry_range(const struct cse_bp_info *cse_bp_info, |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 392 | enum boot_partition_id bp, uint32_t *start_offset, uint32_t *end_offset) |
V Sowmya | f990552 | 2020-11-12 20:19:04 +0530 | [diff] [blame] | 393 | { |
| 394 | const struct cse_bp_entry *cse_bp; |
| 395 | |
| 396 | cse_bp = cse_get_bp_entry(bp, cse_bp_info); |
| 397 | |
| 398 | if (start_offset) |
| 399 | *start_offset = cse_bp->start_offset; |
| 400 | |
| 401 | if (end_offset) |
| 402 | *end_offset = cse_bp->end_offset; |
| 403 | |
| 404 | } |
| 405 | |
| 406 | static bool cse_is_rw_bp_status_valid(const struct cse_bp_info *cse_bp_info) |
| 407 | { |
| 408 | const struct cse_bp_entry *rw_bp; |
| 409 | |
| 410 | rw_bp = cse_get_bp_entry(RW, cse_bp_info); |
| 411 | |
| 412 | if (rw_bp->status == BP_STATUS_PARTITION_NOT_PRESENT || |
| 413 | rw_bp->status == BP_STATUS_GENERAL_FAILURE) { |
| 414 | printk(BIOS_ERR, "cse_lite: RW BP (status:%u) is not valid\n", rw_bp->status); |
| 415 | return false; |
| 416 | } |
| 417 | return true; |
| 418 | } |
| 419 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 420 | static bool cse_boot_to_ro(const struct cse_bp_info *cse_bp_info) |
| 421 | { |
| 422 | if (cse_get_current_bp(cse_bp_info) == RO) |
| 423 | return true; |
| 424 | |
| 425 | return cse_set_and_boot_from_next_bp(RO); |
| 426 | } |
| 427 | |
| 428 | static bool cse_get_rw_rdev(struct region_device *rdev) |
| 429 | { |
| 430 | if (fmap_locate_area_as_rdev_rw(CONFIG_SOC_INTEL_CSE_FMAP_NAME, rdev) < 0) { |
| 431 | printk(BIOS_ERR, "cse_lite: Failed to locate %s in FMAP\n", |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 432 | CONFIG_SOC_INTEL_CSE_FMAP_NAME); |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 433 | return false; |
| 434 | } |
| 435 | |
| 436 | return true; |
| 437 | } |
| 438 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 439 | static bool cse_is_rw_bp_sign_valid(const struct region_device *target_rdev) |
| 440 | { |
| 441 | uint32_t cse_bp_sign; |
| 442 | |
| 443 | if (rdev_readat(target_rdev, &cse_bp_sign, 0, CSE_RW_SIGN_SIZE) != CSE_RW_SIGN_SIZE) { |
| 444 | printk(BIOS_ERR, "cse_lite: Failed to read RW boot partition signature\n"); |
| 445 | return false; |
| 446 | } |
| 447 | |
| 448 | return cse_bp_sign == CSE_RW_SIGNATURE; |
| 449 | } |
| 450 | |
| 451 | static bool cse_get_target_rdev(const struct cse_bp_info *cse_bp_info, |
| 452 | struct region_device *target_rdev) |
| 453 | { |
| 454 | struct region_device cse_region_rdev; |
| 455 | size_t size; |
| 456 | uint32_t start_offset; |
| 457 | uint32_t end_offset; |
| 458 | |
| 459 | if (!cse_get_rw_rdev(&cse_region_rdev)) |
| 460 | return false; |
| 461 | |
| 462 | cse_get_bp_entry_range(cse_bp_info, RW, &start_offset, &end_offset); |
| 463 | size = end_offset + 1 - start_offset; |
| 464 | |
| 465 | if (rdev_chain(target_rdev, &cse_region_rdev, start_offset, size)) |
| 466 | return false; |
| 467 | |
| 468 | printk(BIOS_DEBUG, "cse_lite: CSE RW partition: offset = 0x%x, size = 0x%x\n", |
| 469 | (uint32_t)start_offset, (uint32_t) size); |
| 470 | |
| 471 | return true; |
| 472 | } |
| 473 | |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 474 | static const char *cse_get_source_rdev_fmap(void) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 475 | { |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 476 | struct vb2_context *ctx = vboot_get_context(); |
| 477 | if (ctx == NULL) |
| 478 | return NULL; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 479 | |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 480 | if (vboot_is_firmware_slot_a(ctx)) |
| 481 | return CONFIG_SOC_INTEL_CSE_RW_A_FMAP_NAME; |
| 482 | |
| 483 | return CONFIG_SOC_INTEL_CSE_RW_B_FMAP_NAME; |
| 484 | } |
| 485 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 486 | /* |
Sridhar Siricilla | b9277ba | 2021-11-27 13:57:40 +0530 | [diff] [blame] | 487 | * Compare versions of CSE CBFS sub-component and CSE sub-component partition |
| 488 | * In case of CSE component comparison: |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 489 | * If ver_cmp_status = 0, no update is required |
| 490 | * If ver_cmp_status < 0, coreboot downgrades CSE RW region |
| 491 | * If ver_cmp_status > 0, coreboot upgrades CSE RW region |
| 492 | */ |
Sridhar Siricilla | b9277ba | 2021-11-27 13:57:40 +0530 | [diff] [blame] | 493 | static int cse_compare_sub_part_version(const struct fw_version *a, const struct fw_version *b) |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 494 | { |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 495 | if (a->major != b->major) |
| 496 | return a->major - b->major; |
| 497 | else if (a->minor != b->minor) |
| 498 | return a->minor - b->minor; |
| 499 | else if (a->hotfix != b->hotfix) |
| 500 | return a->hotfix - b->hotfix; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 501 | else |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 502 | return a->build - b->build; |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | /* The function calculates SHA-256 of CSE RW blob and compares it with the provided SHA value */ |
| 506 | static bool cse_verify_cbfs_rw_sha256(const uint8_t *expected_rw_blob_sha, |
| 507 | const void *rw_blob, const size_t rw_blob_sz) |
| 508 | |
| 509 | { |
| 510 | uint8_t rw_comp_sha[VB2_SHA256_DIGEST_SIZE]; |
| 511 | |
| 512 | if (vb2_digest_buffer(rw_blob, rw_blob_sz, VB2_HASH_SHA256, rw_comp_sha, |
| 513 | VB2_SHA256_DIGEST_SIZE)) { |
| 514 | printk(BIOS_ERR, "cse_lite: CSE CBFS RW's SHA-256 calculation has failed\n"); |
| 515 | return false; |
| 516 | } |
| 517 | |
| 518 | if (memcmp(expected_rw_blob_sha, rw_comp_sha, VB2_SHA256_DIGEST_SIZE)) { |
| 519 | printk(BIOS_ERR, "cse_lite: Computed CBFS RW's SHA-256 does not match with" |
| 520 | "the provided SHA in the metadata\n"); |
| 521 | return false; |
| 522 | } |
| 523 | printk(BIOS_SPEW, "cse_lite: Computed SHA of CSE CBFS RW Image matches the" |
| 524 | " provided hash in the metadata\n"); |
| 525 | return true; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | static bool cse_erase_rw_region(const struct region_device *target_rdev) |
| 529 | { |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 530 | if (rdev_eraseat(target_rdev, 0, region_device_sz(target_rdev)) < 0) { |
| 531 | printk(BIOS_ERR, "cse_lite: CSE RW partition could not be erased\n"); |
| 532 | return false; |
| 533 | } |
| 534 | return true; |
| 535 | } |
| 536 | |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 537 | static bool cse_copy_rw(const struct region_device *target_rdev, const void *buf, |
| 538 | size_t offset, size_t size) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 539 | { |
| 540 | if (rdev_writeat(target_rdev, buf, offset, size) < 0) { |
| 541 | printk(BIOS_ERR, "cse_lite: Failed to update CSE firmware\n"); |
| 542 | return false; |
| 543 | } |
| 544 | |
| 545 | return true; |
| 546 | } |
| 547 | |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 548 | enum cse_update_status { |
| 549 | CSE_UPDATE_NOT_REQUIRED, |
| 550 | CSE_UPDATE_UPGRADE, |
| 551 | CSE_UPDATE_DOWNGRADE, |
| 552 | CSE_UPDATE_CORRUPTED, |
| 553 | CSE_UPDATE_METADATA_ERROR, |
| 554 | }; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 555 | |
Furquan Shaikh | d2da870 | 2021-10-07 00:08:59 -0700 | [diff] [blame] | 556 | static bool read_ver_field(const char *start, char **curr, size_t size, uint16_t *ver_field) |
| 557 | { |
| 558 | if ((*curr - start) >= size) { |
| 559 | printk(BIOS_ERR, "cse_lite: Version string read overflow!\n"); |
| 560 | return false; |
| 561 | } |
| 562 | |
| 563 | *ver_field = skip_atoi(curr); |
| 564 | (*curr)++; |
| 565 | return true; |
| 566 | } |
Sridhar Siricilla | 2f6d555 | 2020-04-19 23:39:02 +0530 | [diff] [blame] | 567 | |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 568 | static enum cse_update_status cse_check_update_status(const struct cse_bp_info *cse_bp_info, |
| 569 | struct region_device *target_rdev) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 570 | { |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 571 | int ret; |
Furquan Shaikh | d2da870 | 2021-10-07 00:08:59 -0700 | [diff] [blame] | 572 | struct fw_version cbfs_rw_version; |
| 573 | char *version_str, *ptr; |
| 574 | size_t size; |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 575 | |
| 576 | if (!cse_is_rw_bp_sign_valid(target_rdev)) |
| 577 | return CSE_UPDATE_CORRUPTED; |
| 578 | |
Furquan Shaikh | d2da870 | 2021-10-07 00:08:59 -0700 | [diff] [blame] | 579 | ptr = version_str = cbfs_map(CONFIG_SOC_INTEL_CSE_RW_VERSION_CBFS_NAME, &size); |
| 580 | if (!version_str) { |
| 581 | printk(BIOS_ERR, "cse_lite: Failed to get %s\n", |
| 582 | CONFIG_SOC_INTEL_CSE_RW_VERSION_CBFS_NAME); |
| 583 | return CSE_UPDATE_METADATA_ERROR; |
| 584 | } |
| 585 | |
| 586 | if (!read_ver_field(version_str, &ptr, size, &cbfs_rw_version.major) || |
| 587 | !read_ver_field(version_str, &ptr, size, &cbfs_rw_version.minor) || |
| 588 | !read_ver_field(version_str, &ptr, size, &cbfs_rw_version.hotfix) || |
| 589 | !read_ver_field(version_str, &ptr, size, &cbfs_rw_version.build)) { |
| 590 | cbfs_unmap(version_str); |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 591 | return CSE_UPDATE_METADATA_ERROR; |
| 592 | } |
| 593 | |
| 594 | printk(BIOS_DEBUG, "cse_lite: CSE CBFS RW version : %d.%d.%d.%d\n", |
Furquan Shaikh | d2da870 | 2021-10-07 00:08:59 -0700 | [diff] [blame] | 595 | cbfs_rw_version.major, |
| 596 | cbfs_rw_version.minor, |
| 597 | cbfs_rw_version.hotfix, |
| 598 | cbfs_rw_version.build); |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 599 | |
Furquan Shaikh | d2da870 | 2021-10-07 00:08:59 -0700 | [diff] [blame] | 600 | cbfs_unmap(version_str); |
| 601 | |
Sridhar Siricilla | b9277ba | 2021-11-27 13:57:40 +0530 | [diff] [blame] | 602 | ret = cse_compare_sub_part_version(&cbfs_rw_version, cse_get_rw_version(cse_bp_info)); |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 603 | if (ret == 0) |
| 604 | return CSE_UPDATE_NOT_REQUIRED; |
| 605 | else if (ret < 0) |
| 606 | return CSE_UPDATE_DOWNGRADE; |
| 607 | else |
| 608 | return CSE_UPDATE_UPGRADE; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | static bool cse_write_rw_region(const struct region_device *target_rdev, |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 612 | const void *cse_cbfs_rw, const size_t cse_cbfs_rw_sz) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 613 | { |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 614 | /* Points to CSE CBFS RW image after boot partition signature */ |
| 615 | uint8_t *cse_cbfs_rw_wo_sign = (uint8_t *)cse_cbfs_rw + CSE_RW_SIGN_SIZE; |
| 616 | |
| 617 | /* Size of CSE CBFS RW image without boot partition signature */ |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 618 | uint32_t cse_cbfs_rw_wo_sign_sz = cse_cbfs_rw_sz - CSE_RW_SIGN_SIZE; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 619 | |
| 620 | /* Update except CSE RW signature */ |
| 621 | if (!cse_copy_rw(target_rdev, cse_cbfs_rw_wo_sign, CSE_RW_SIGN_SIZE, |
| 622 | cse_cbfs_rw_wo_sign_sz)) |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 623 | return false; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 624 | |
| 625 | /* Update CSE RW signature to indicate update is complete */ |
| 626 | if (!cse_copy_rw(target_rdev, (void *)cse_cbfs_rw, 0, CSE_RW_SIGN_SIZE)) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 627 | return false; |
| 628 | |
| 629 | printk(BIOS_INFO, "cse_lite: CSE RW Update Successful\n"); |
| 630 | return true; |
| 631 | } |
| 632 | |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 633 | static enum csme_failure_reason cse_update_rw(const struct cse_bp_info *cse_bp_info, |
| 634 | const void *cse_cbfs_rw, const size_t cse_blob_sz, |
| 635 | struct region_device *target_rdev) |
| 636 | { |
Sridhar Siricilla | abeb688 | 2020-12-07 15:55:10 +0530 | [diff] [blame] | 637 | if (region_device_sz(target_rdev) < cse_blob_sz) { |
Krishna Prasad Bhat | 333edcc | 2021-11-26 06:52:27 +0530 | [diff] [blame^] | 638 | printk(BIOS_ERR, "RW update does not fit. CSE RW flash region size: %zx," |
| 639 | "Update blob size:%zx\n", region_device_sz(target_rdev), cse_blob_sz); |
Sridhar Siricilla | abeb688 | 2020-12-07 15:55:10 +0530 | [diff] [blame] | 640 | return CSE_LITE_SKU_LAYOUT_MISMATCH_ERROR; |
| 641 | } |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 642 | |
| 643 | if (!cse_erase_rw_region(target_rdev)) |
| 644 | return CSE_LITE_SKU_FW_UPDATE_ERROR; |
| 645 | |
| 646 | if (!cse_write_rw_region(target_rdev, cse_cbfs_rw, cse_blob_sz)) |
| 647 | return CSE_LITE_SKU_FW_UPDATE_ERROR; |
| 648 | |
Tim Wawrzynczak | e380a43 | 2021-06-18 09:54:55 -0600 | [diff] [blame] | 649 | return CSE_NO_ERROR; |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 650 | } |
| 651 | |
Sridhar Siricilla | 2f6d555 | 2020-04-19 23:39:02 +0530 | [diff] [blame] | 652 | static bool cse_prep_for_rw_update(const struct cse_bp_info *cse_bp_info, |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 653 | enum cse_update_status status) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 654 | { |
| 655 | /* |
| 656 | * To set CSE's operation mode to HMRFPO mode: |
| 657 | * 1. Ensure CSE to boot from RO(BP1) |
| 658 | * 2. Send HMRFPO_ENABLE command to CSE |
| 659 | */ |
| 660 | if (!cse_boot_to_ro(cse_bp_info)) |
| 661 | return false; |
| 662 | |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 663 | if ((status == CSE_UPDATE_DOWNGRADE) || (status == CSE_UPDATE_CORRUPTED)) { |
| 664 | if (!cse_data_clear_request(cse_bp_info)) { |
| 665 | printk(BIOS_ERR, "cse_lite: CSE data clear failed!\n"); |
| 666 | return false; |
| 667 | } |
Sridhar Siricilla | 2f6d555 | 2020-04-19 23:39:02 +0530 | [diff] [blame] | 668 | } |
| 669 | |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 670 | return cse_hmrfpo_enable(); |
| 671 | } |
| 672 | |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 673 | static enum csme_failure_reason cse_trigger_fw_update(const struct cse_bp_info *cse_bp_info, |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 674 | enum cse_update_status status, |
| 675 | struct region_device *target_rdev) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 676 | { |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 677 | enum csme_failure_reason rv; |
Furquan Shaikh | d2da870 | 2021-10-07 00:08:59 -0700 | [diff] [blame] | 678 | uint8_t *cbfs_rw_hash; |
Julius Werner | 18881f99 | 2021-04-13 15:28:12 -0700 | [diff] [blame] | 679 | size_t size; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 680 | |
Julius Werner | 18881f99 | 2021-04-13 15:28:12 -0700 | [diff] [blame] | 681 | const char *area_name = cse_get_source_rdev_fmap(); |
| 682 | if (!area_name) |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 683 | return CSE_LITE_SKU_RW_BLOB_NOT_FOUND; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 684 | |
Julius Werner | 18881f99 | 2021-04-13 15:28:12 -0700 | [diff] [blame] | 685 | void *cse_cbfs_rw = cbfs_unverified_area_map(area_name, |
| 686 | CONFIG_SOC_INTEL_CSE_RW_CBFS_NAME, &size); |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 687 | if (!cse_cbfs_rw) { |
| 688 | printk(BIOS_ERR, "cse_lite: CSE CBFS RW blob could not be mapped\n"); |
| 689 | return CSE_LITE_SKU_RW_BLOB_NOT_FOUND; |
| 690 | } |
| 691 | |
Furquan Shaikh | d2da870 | 2021-10-07 00:08:59 -0700 | [diff] [blame] | 692 | cbfs_rw_hash = cbfs_map(CONFIG_SOC_INTEL_CSE_RW_HASH_CBFS_NAME, NULL); |
| 693 | if (!cbfs_rw_hash) { |
| 694 | printk(BIOS_ERR, "cse_lite: Failed to get %s\n", |
| 695 | CONFIG_SOC_INTEL_CSE_RW_HASH_CBFS_NAME); |
| 696 | rv = CSE_LITE_SKU_RW_METADATA_NOT_FOUND; |
| 697 | goto error_exit; |
| 698 | } |
| 699 | |
Julius Werner | 18881f99 | 2021-04-13 15:28:12 -0700 | [diff] [blame] | 700 | if (!cse_verify_cbfs_rw_sha256(cbfs_rw_hash, cse_cbfs_rw, size)) { |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 701 | rv = CSE_LITE_SKU_RW_BLOB_SHA256_MISMATCH; |
| 702 | goto error_exit; |
| 703 | } |
| 704 | |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 705 | if (!cse_prep_for_rw_update(cse_bp_info, status)) { |
Tim Wawrzynczak | e380a43 | 2021-06-18 09:54:55 -0600 | [diff] [blame] | 706 | rv = CSE_COMMUNICATION_ERROR; |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 707 | goto error_exit; |
| 708 | } |
| 709 | |
Julius Werner | 18881f99 | 2021-04-13 15:28:12 -0700 | [diff] [blame] | 710 | rv = cse_update_rw(cse_bp_info, cse_cbfs_rw, size, target_rdev); |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 711 | |
| 712 | error_exit: |
Furquan Shaikh | d2da870 | 2021-10-07 00:08:59 -0700 | [diff] [blame] | 713 | cbfs_unmap(cbfs_rw_hash); |
Julius Werner | 18881f99 | 2021-04-13 15:28:12 -0700 | [diff] [blame] | 714 | cbfs_unmap(cse_cbfs_rw); |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 715 | return rv; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 716 | } |
| 717 | |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 718 | static uint8_t cse_fw_update(const struct cse_bp_info *cse_bp_info) |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 719 | { |
| 720 | struct region_device target_rdev; |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 721 | enum cse_update_status status; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 722 | |
| 723 | if (!cse_get_target_rdev(cse_bp_info, &target_rdev)) { |
| 724 | printk(BIOS_ERR, "cse_lite: Failed to get CSE RW Partition\n"); |
| 725 | return CSE_LITE_SKU_RW_ACCESS_ERROR; |
| 726 | } |
| 727 | |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 728 | status = cse_check_update_status(cse_bp_info, &target_rdev); |
| 729 | if (status == CSE_UPDATE_NOT_REQUIRED) |
| 730 | return CSE_NO_ERROR; |
| 731 | if (status == CSE_UPDATE_METADATA_ERROR) |
| 732 | return CSE_LITE_SKU_RW_METADATA_NOT_FOUND; |
Rizwan Qureshi | ec32109 | 2019-09-06 20:28:43 +0530 | [diff] [blame] | 733 | |
Furquan Shaikh | c45e0be | 2021-10-06 23:28:03 -0700 | [diff] [blame] | 734 | printk(BIOS_DEBUG, "cse_lite: CSE RW update is initiated\n"); |
| 735 | return cse_trigger_fw_update(cse_bp_info, status, &target_rdev); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 736 | } |
| 737 | |
Krishna Prasad Bhat | 333edcc | 2021-11-26 06:52:27 +0530 | [diff] [blame^] | 738 | static const char *cse_sub_part_str(enum bpdt_entry_type type) |
| 739 | { |
| 740 | switch (type) { |
| 741 | case IOM_FW: |
| 742 | return "IOM"; |
| 743 | case NPHY_FW: |
| 744 | return "NPHY"; |
| 745 | default: |
| 746 | return "Unknown"; |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | static bool cse_sub_part_get_target_rdev(struct region_device *target_rdev, |
| 751 | const char *region_name, enum bpdt_entry_type type) |
| 752 | { |
| 753 | struct bpdt_header bpdt_hdr; |
| 754 | struct region_device cse_rdev; |
| 755 | struct bpdt_entry bpdt_entries[MAX_SUBPARTS]; |
| 756 | uint8_t i; |
| 757 | |
| 758 | if (fmap_locate_area_as_rdev_rw(region_name, &cse_rdev) < 0) { |
| 759 | printk(BIOS_ERR, "cse_lite: Failed to locate %s in the FMAP\n", region_name); |
| 760 | return false; |
| 761 | } |
| 762 | |
| 763 | if ((rdev_readat(&cse_rdev, &bpdt_hdr, 0, BPDT_HEADER_SZ)) != BPDT_HEADER_SZ) { |
| 764 | printk(BIOS_ERR, "cse_lite: Failed to read BPDT header from CSE region\n"); |
| 765 | return false; |
| 766 | } |
| 767 | |
| 768 | if ((rdev_readat(&cse_rdev, bpdt_entries, BPDT_HEADER_SZ, |
| 769 | (bpdt_hdr.descriptor_count * BPDT_ENTRY_SZ))) != |
| 770 | (bpdt_hdr.descriptor_count * BPDT_ENTRY_SZ)) { |
| 771 | printk(BIOS_ERR, "cse_lite: Failed to read BPDT entries from CSE region\n"); |
| 772 | return false; |
| 773 | } |
| 774 | |
| 775 | /* walk through BPDT entries to identify sub-partition's payload offset and size */ |
| 776 | for (i = 0; i < bpdt_hdr.descriptor_count; i++) { |
| 777 | if (bpdt_entries[i].type == type) { |
| 778 | printk(BIOS_INFO, "cse_lite: Sub-partition %s- offset = 0x%x," |
| 779 | "size = 0x%x\n", cse_sub_part_str(type), bpdt_entries[i].offset, |
| 780 | bpdt_entries[i].size); |
| 781 | |
| 782 | if (rdev_chain(target_rdev, &cse_rdev, bpdt_entries[i].offset, |
| 783 | bpdt_entries[i].size)) |
| 784 | return false; |
| 785 | else |
| 786 | return true; |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | printk(BIOS_ERR, "cse_lite: Sub-partition %s is not found\n", cse_sub_part_str(type)); |
| 791 | return false; |
| 792 | } |
| 793 | |
| 794 | static bool cse_get_sub_part_fw_version(enum bpdt_entry_type type, |
| 795 | const struct region_device *rdev, |
| 796 | struct fw_version *fw_ver) |
| 797 | { |
| 798 | struct subpart_entry subpart_entry; |
| 799 | struct subpart_entry_manifest_header man_hdr; |
| 800 | |
| 801 | if ((rdev_readat(rdev, &subpart_entry, SUBPART_HEADER_SZ, SUBPART_ENTRY_SZ)) |
| 802 | != SUBPART_ENTRY_SZ) { |
| 803 | printk(BIOS_ERR, "cse_lite: Failed to read %s sub partition entry\n", |
| 804 | cse_sub_part_str(type)); |
| 805 | return false; |
| 806 | } |
| 807 | |
| 808 | if ((rdev_readat(rdev, &man_hdr, subpart_entry.offset_bytes, SUBPART_MANIFEST_HDR_SZ)) |
| 809 | != SUBPART_MANIFEST_HDR_SZ) { |
| 810 | printk(BIOS_ERR, "cse_lite: Failed to read %s Sub part entry #0 manifest\n", |
| 811 | cse_sub_part_str(type)); |
| 812 | return false; |
| 813 | } |
| 814 | |
| 815 | fw_ver->major = man_hdr.binary_version.major; |
| 816 | fw_ver->minor = man_hdr.binary_version.minor; |
| 817 | fw_ver->hotfix = man_hdr.binary_version.hotfix; |
| 818 | fw_ver->build = man_hdr.binary_version.build; |
| 819 | |
| 820 | return true; |
| 821 | } |
| 822 | |
| 823 | static void cse_sub_part_get_source_fw_version(void *subpart_cbfs_rw, struct fw_version *fw_ver) |
| 824 | { |
| 825 | uint8_t *ptr = (uint8_t *)subpart_cbfs_rw; |
| 826 | struct subpart_entry *subpart_entry; |
| 827 | struct subpart_entry_manifest_header *man_hdr; |
| 828 | |
| 829 | subpart_entry = (struct subpart_entry *) (ptr + SUBPART_HEADER_SZ); |
| 830 | man_hdr = (struct subpart_entry_manifest_header *) (ptr + subpart_entry->offset_bytes); |
| 831 | |
| 832 | fw_ver->major = man_hdr->binary_version.major; |
| 833 | fw_ver->minor = man_hdr->binary_version.minor; |
| 834 | fw_ver->hotfix = man_hdr->binary_version.hotfix; |
| 835 | fw_ver->build = man_hdr->binary_version.build; |
| 836 | } |
| 837 | |
| 838 | static bool cse_prep_for_component_update(const struct cse_bp_info *cse_bp_info) |
| 839 | { |
| 840 | /* |
| 841 | * To set CSE's operation mode to HMRFPO mode: |
| 842 | * 1. Ensure CSE to boot from RO(BP1) |
| 843 | * 2. Send HMRFPO_ENABLE command to CSE |
| 844 | */ |
| 845 | if (!cse_boot_to_ro(cse_bp_info)) |
| 846 | return false; |
| 847 | |
| 848 | return cse_hmrfpo_enable(); |
| 849 | } |
| 850 | |
| 851 | static uint8_t cse_sub_part_trigger_update(enum bpdt_entry_type type, uint8_t bp, |
| 852 | const void *subpart_cbfs_rw, const size_t blob_sz, |
| 853 | struct region_device *target_rdev) |
| 854 | { |
| 855 | if (region_device_sz(target_rdev) < blob_sz) { |
| 856 | printk(BIOS_ERR, "cse_lite: %s Target sub-partition size: %zx, " |
| 857 | "smaller than blob size:%zx, abort update\n", |
| 858 | cse_sub_part_str(type), region_device_sz(target_rdev), blob_sz); |
| 859 | return CSE_LITE_SKU_SUB_PART_LAYOUT_MISMATCH_ERROR; |
| 860 | } |
| 861 | |
| 862 | /* Erase CSE Lite sub-partition */ |
| 863 | if (!cse_erase_rw_region(target_rdev)) |
| 864 | return CSE_LITE_SKU_SUB_PART_UPDATE_FAIL; |
| 865 | |
| 866 | /* Update CSE Lite sub-partition */ |
| 867 | if (!cse_copy_rw(target_rdev, (void *)subpart_cbfs_rw, 0, blob_sz)) |
| 868 | return CSE_LITE_SKU_SUB_PART_UPDATE_FAIL; |
| 869 | |
| 870 | printk(BIOS_INFO, "cse_lite: CSE %s %s Update successful\n", GET_BP_STR(bp), |
| 871 | cse_sub_part_str(type)); |
| 872 | |
| 873 | return CSE_LITE_SKU_PART_UPDATE_SUCCESS; |
| 874 | } |
| 875 | |
| 876 | static uint8_t handle_cse_sub_part_fw_update_rv(uint8_t rv) |
| 877 | { |
| 878 | switch (rv) { |
| 879 | case CSE_LITE_SKU_PART_UPDATE_SUCCESS: |
| 880 | case CSE_LITE_SKU_SUB_PART_UPDATE_NOT_REQ: |
| 881 | return rv; |
| 882 | default: |
| 883 | cse_trigger_vboot_recovery(rv); |
| 884 | } |
| 885 | /* Control never reaches here */ |
| 886 | return rv; |
| 887 | } |
| 888 | |
| 889 | static enum csme_failure_reason cse_sub_part_fw_component_update(enum bpdt_entry_type type, |
| 890 | const struct cse_bp_info *cse_bp_info, const char *name) |
| 891 | { |
| 892 | struct region_device target_rdev; |
| 893 | struct fw_version target_fw_ver, source_fw_ver; |
| 894 | enum csme_failure_reason rv; |
| 895 | size_t size; |
| 896 | static const char * const cse_regions[] = {"CSE_RO", "CSE_RW"}; |
| 897 | |
| 898 | void *subpart_cbfs_rw = cbfs_map(name, &size); |
| 899 | if (!subpart_cbfs_rw) { |
| 900 | printk(BIOS_ERR, "cse_lite: Not able to map %s CBFS file\n", |
| 901 | cse_sub_part_str(type)); |
| 902 | return CSE_LITE_SKU_SUB_PART_BLOB_ACCESS_ERR; |
| 903 | } |
| 904 | |
| 905 | cse_sub_part_get_source_fw_version(subpart_cbfs_rw, &source_fw_ver); |
| 906 | printk(BIOS_INFO, "cse_lite: CBFS %s FW Version: %x.%x.%x.%x\n", cse_sub_part_str(type), |
| 907 | source_fw_ver.major, source_fw_ver.minor, source_fw_ver.hotfix, |
| 908 | source_fw_ver.build); |
| 909 | |
| 910 | /* Trigger sub-partition update in CSE RO and CSE RW */ |
| 911 | for (size_t bp = 0; bp < ARRAY_SIZE(cse_regions); bp++) { |
| 912 | if (!cse_sub_part_get_target_rdev(&target_rdev, cse_regions[bp], type)) { |
| 913 | rv = CSE_LITE_SKU_SUB_PART_ACCESS_ERR; |
| 914 | goto error_exit; |
| 915 | } |
| 916 | |
| 917 | if (!cse_get_sub_part_fw_version(type, &target_rdev, &target_fw_ver)) { |
| 918 | rv = CSE_LITE_SKU_SUB_PART_ACCESS_ERR; |
| 919 | goto error_exit; |
| 920 | } |
| 921 | |
| 922 | printk(BIOS_INFO, "cse_lite: %s %s FW Version: %x.%x.%x.%x\n", cse_regions[bp], |
| 923 | cse_sub_part_str(type), target_fw_ver.major, |
| 924 | target_fw_ver.minor, target_fw_ver.hotfix, target_fw_ver.build); |
| 925 | |
| 926 | if (!cse_compare_sub_part_version(&target_fw_ver, &source_fw_ver)) { |
| 927 | printk(BIOS_INFO, "cse_lite: %s %s update is not required\n", |
| 928 | cse_regions[bp], cse_sub_part_str(type)); |
| 929 | rv = CSE_LITE_SKU_SUB_PART_UPDATE_NOT_REQ; |
| 930 | continue; |
| 931 | } |
| 932 | |
| 933 | printk(BIOS_INFO, "CSE %s %s Update initiated\n", GET_BP_STR(bp), |
| 934 | cse_sub_part_str(type)); |
| 935 | |
| 936 | if (!cse_prep_for_component_update(cse_bp_info)) { |
| 937 | rv = CSE_LITE_SKU_SUB_PART_ACCESS_ERR; |
| 938 | goto error_exit; |
| 939 | } |
| 940 | |
| 941 | rv = cse_sub_part_trigger_update(type, bp, subpart_cbfs_rw, |
| 942 | size, &target_rdev); |
| 943 | |
| 944 | if (rv != CSE_LITE_SKU_PART_UPDATE_SUCCESS) |
| 945 | goto error_exit; |
| 946 | } |
| 947 | error_exit: |
| 948 | cbfs_unmap(subpart_cbfs_rw); |
| 949 | return rv; |
| 950 | } |
| 951 | |
| 952 | static uint8_t cse_sub_part_fw_update(const struct cse_bp_info *cse_bp_info) |
| 953 | { |
| 954 | if (skip_cse_sub_part_update()) { |
| 955 | printk(BIOS_INFO, "CSE Sub-partition update not required\n"); |
| 956 | return CSE_LITE_SKU_SUB_PART_UPDATE_NOT_REQ; |
| 957 | } |
| 958 | |
| 959 | int rv; |
| 960 | rv = cse_sub_part_fw_component_update(IOM_FW, cse_bp_info, |
| 961 | CONFIG_SOC_INTEL_CSE_IOM_CBFS_NAME); |
| 962 | |
| 963 | handle_cse_sub_part_fw_update_rv(rv); |
| 964 | |
| 965 | rv = cse_sub_part_fw_component_update(NPHY_FW, cse_bp_info, |
| 966 | CONFIG_SOC_INTEL_CSE_NPHY_CBFS_NAME); |
| 967 | |
| 968 | return handle_cse_sub_part_fw_update_rv(rv); |
| 969 | } |
| 970 | |
Sridhar Siricilla | 1a2b702 | 2020-12-04 02:22:28 +0530 | [diff] [blame] | 971 | void cse_fw_sync(void) |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 972 | { |
| 973 | static struct get_bp_info_rsp cse_bp_info; |
| 974 | |
Krishna Prasad Bhat | 333edcc | 2021-11-26 06:52:27 +0530 | [diff] [blame^] | 975 | /* |
| 976 | * If system is in recovery mode, skip CSE Lite update if CSE sub-partition update |
| 977 | * is not enabled and continue to update CSE sub-partitions. |
| 978 | */ |
| 979 | if (vboot_recovery_mode_enabled() && !CONFIG(SOC_INTEL_CSE_SUB_PART_UPDATE)) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 980 | printk(BIOS_DEBUG, "cse_lite: Skip switching to RW in the recovery path\n"); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 981 | return; |
| 982 | } |
| 983 | |
Sridhar Siricilla | 99dbca3 | 2020-05-12 21:05:04 +0530 | [diff] [blame] | 984 | /* If CSE SKU type is not Lite, skip enabling CSE Lite SKU */ |
| 985 | if (!cse_is_hfs3_fw_sku_lite()) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 986 | printk(BIOS_ERR, "cse_lite: Not a CSE Lite SKU\n"); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 987 | return; |
| 988 | } |
| 989 | |
| 990 | if (!cse_get_bp_info(&cse_bp_info)) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 991 | printk(BIOS_ERR, "cse_lite: Failed to get CSE boot partition info\n"); |
Krishna Prasad Bhat | 333edcc | 2021-11-26 06:52:27 +0530 | [diff] [blame^] | 992 | |
| 993 | /* If system is in recovery mode, don't trigger recovery again */ |
| 994 | if (!vboot_recovery_mode_enabled()) { |
| 995 | cse_trigger_vboot_recovery(CSE_COMMUNICATION_ERROR); |
| 996 | } else { |
| 997 | printk(BIOS_ERR, "cse_lite: System is already in Recovery Mode, " |
| 998 | "so no action\n"); |
| 999 | return; |
| 1000 | } |
| 1001 | } |
| 1002 | |
| 1003 | /* |
| 1004 | * If system is in recovery mode, CSE Lite update has to be skipped but CSE |
| 1005 | * sub-partitions like NPHY and IOM have to to be updated. If CSE sub-parition update |
| 1006 | * fails during recovery, just continue to boot. |
| 1007 | */ |
| 1008 | if (CONFIG(SOC_INTEL_CSE_SUB_PART_UPDATE) && vboot_recovery_mode_enabled()) { |
| 1009 | if (cse_sub_part_fw_update(&cse_bp_info.bp_info) == |
| 1010 | CSE_LITE_SKU_PART_UPDATE_SUCCESS) { |
| 1011 | cse_board_reset(); |
| 1012 | do_global_reset(); |
| 1013 | die("ERROR: GLOBAL RESET Failed to reset the system\n"); |
| 1014 | } |
| 1015 | |
| 1016 | return; |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 1017 | } |
| 1018 | |
Sridhar Siricilla | 2f6d555 | 2020-04-19 23:39:02 +0530 | [diff] [blame] | 1019 | if (!cse_fix_data_failure_err(&cse_bp_info.bp_info)) |
Tim Wawrzynczak | 09635f4 | 2021-06-18 10:08:47 -0600 | [diff] [blame] | 1020 | cse_trigger_vboot_recovery(CSE_LITE_SKU_DATA_WIPE_ERROR); |
Sridhar Siricilla | 2f6d555 | 2020-04-19 23:39:02 +0530 | [diff] [blame] | 1021 | |
Sridhar Siricilla | 361e364 | 2020-10-18 20:14:07 +0530 | [diff] [blame] | 1022 | /* |
| 1023 | * If SOC_INTEL_CSE_RW_UPDATE is defined , then trigger CSE firmware update. The driver |
| 1024 | * triggers recovery if CSE CBFS RW metadata or CSE CBFS RW blob is not available. |
| 1025 | */ |
Sridhar Siricilla | 4c2890d | 2020-12-09 00:28:30 +0530 | [diff] [blame] | 1026 | if (CONFIG(SOC_INTEL_CSE_RW_UPDATE)) { |
| 1027 | uint8_t rv; |
| 1028 | rv = cse_fw_update(&cse_bp_info.bp_info); |
| 1029 | if (rv) |
Tim Wawrzynczak | 09635f4 | 2021-06-18 10:08:47 -0600 | [diff] [blame] | 1030 | cse_trigger_vboot_recovery(rv); |
Sridhar Siricilla | 4c2890d | 2020-12-09 00:28:30 +0530 | [diff] [blame] | 1031 | } |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 1032 | |
Krishna Prasad Bhat | 333edcc | 2021-11-26 06:52:27 +0530 | [diff] [blame^] | 1033 | if (CONFIG(SOC_INTEL_CSE_SUB_PART_UPDATE)) |
| 1034 | cse_sub_part_fw_update(&cse_bp_info.bp_info); |
| 1035 | |
Sridahr Siricilla | 54b0356 | 2021-06-18 10:59:30 +0530 | [diff] [blame] | 1036 | if (!cse_is_rw_bp_status_valid(&cse_bp_info.bp_info)) |
Tim Wawrzynczak | f2801f4 | 2021-06-22 11:25:14 -0600 | [diff] [blame] | 1037 | cse_trigger_vboot_recovery(CSE_LITE_SKU_RW_JUMP_ERROR); |
Sridahr Siricilla | 54b0356 | 2021-06-18 10:59:30 +0530 | [diff] [blame] | 1038 | |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 1039 | if (!cse_boot_to_rw(&cse_bp_info.bp_info)) { |
Sridhar Siricilla | 9f71b17 | 2020-06-01 14:50:52 +0530 | [diff] [blame] | 1040 | printk(BIOS_ERR, "cse_lite: Failed to switch to RW\n"); |
Tim Wawrzynczak | 09635f4 | 2021-06-18 10:08:47 -0600 | [diff] [blame] | 1041 | cse_trigger_vboot_recovery(CSE_LITE_SKU_RW_SWITCH_ERROR); |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 1042 | } |
Sridhar Siricilla | f87ff33 | 2019-09-12 17:18:20 +0530 | [diff] [blame] | 1043 | } |