Patrick Georgi submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Julius Werner: Looks good to me, approved
EC sync: Properly handle VBERROR return codes from vb2api_ec_sync

Some return codes were missed when implementing this initially; the vboot
logic can require the system to command the EC to reboot to its RO, switch
RW slots or it can require a poweroff of the SoC. This patch appropriately
handles these return codes.

BUG=b:145768046
BRANCH=firmware-hatch-12672.B
TEST=ODM verified this patch fixes the issues seen.

Change-Id: I2748cf626d49c255cb0274cb336b072dcdf8cded
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/37562
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
---
M src/security/vboot/ec_sync.c
1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/security/vboot/ec_sync.c b/src/security/vboot/ec_sync.c
index 8a3ba71..ecceff5 100644
--- a/src/security/vboot/ec_sync.c
+++ b/src/security/vboot/ec_sync.c
@@ -16,6 +16,7 @@
#include <console/console.h>
#include <delay.h>
#include <ec/google/chromeec/ec.h>
+#include <halt.h>
#include <security/vboot/misc.h>
#include <security/vboot/vbnv.h>
#include <security/vboot/vboot_common.h>
@@ -60,9 +61,38 @@
retval = vb2api_ec_sync(ctx);
vboot_save_nvdata_only(ctx);

- if (retval != VB2_SUCCESS) {
- printk(BIOS_ERR, "EC software sync failed (%#x), rebooting\n", retval);
+ switch (retval) {
+ case VB2_SUCCESS:
+ break;
+
+ case VBERROR_EC_REBOOT_TO_RO_REQUIRED:
+ printk(BIOS_INFO, "EC Reboot requested. Doing cold reboot\n");
+ if (google_chromeec_reboot(0, EC_REBOOT_COLD, 0))
+ printk(BIOS_EMERG, "Failed to get EC to cold reboot\n");
+
+ halt();
+ break;
+
+ /* Only for EC-EFS */
+ case VBERROR_EC_REBOOT_TO_SWITCH_RW:
+ printk(BIOS_INFO, "Switch EC slot requested. Doing cold reboot\n");
+ if (google_chromeec_reboot(0, EC_REBOOT_COLD,
+ EC_REBOOT_FLAG_SWITCH_RW_SLOT))
+ printk(BIOS_EMERG, "Failed to get EC to cold reboot\n");
+
+ halt();
+ break;
+
+ case VBERROR_REBOOT_REQUIRED:
+ printk(BIOS_INFO, "Reboot requested. Doing warm reboot\n");
vboot_reboot();
+ break;
+
+ default:
+ printk(BIOS_ERR, "EC software sync failed (%#x),"
+ " rebooting\n", retval);
+ vboot_reboot();
+ break;
}

timestamp_add_now(TS_END_EC_SYNC);

To view, visit change 37562. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I2748cf626d49c255cb0274cb336b072dcdf8cded
Gerrit-Change-Number: 37562
Gerrit-PatchSet: 5
Gerrit-Owner: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-Reviewer: Aaron Durbin <adurbin@chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan@google.com>
Gerrit-Reviewer: Joel Kitching <kitching@google.com>
Gerrit-Reviewer: Julius Werner <jwerner@chromium.org>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-Reviewer: SH Kim <sh_.kim@samsung.corp-partner.google.com>
Gerrit-Reviewer: Shelley Chen <shchen@google.com>
Gerrit-Reviewer: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged