summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2022-07-04 14:45:13 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-13 09:07:43 +0000
commit6d74ce8a95a3a0ed8adb41bde3172f5d7db96f64 (patch)
tree3fd6a8f2149b06f3512e31d75d34dbba3c5868fc
parent4756206b07f2250155c9c4c1d75577281ea111f5 (diff)
downloadvboot-6d74ce8a95a3a0ed8adb41bde3172f5d7db96f64.tar.gz
2lib/2auxfw_sync: Request recovery for missing auxfw
When the hash file of auxfw is not found in the CBFS, VB2_ERROR_UNKNOWN will be returned from vb2ex_auxfw_check(), causing the device to enter reboot loop. Similar to how we handle missing ecrw.hash, vb2api_fail() should be called, so that the device will try to boot from the other slot, and if the hash is still missing, recovery will be triggered. Call vb2api_fail() from vb2api_auxfw_sync() using the 3-argument form of VB2_TRY(). Add a unit test to prevent regression. BUG=b:237745301 TEST=make run2tests TEST=emerge-corsola libpayload BRANCH=none Change-Id: I789c63b10201bd1852bc087199ec7b226ec85ba8 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3742863 Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>
-rw-r--r--firmware/2lib/2auxfw_sync.c3
-rw-r--r--tests/vb2_auxfw_sync_tests.c18
2 files changed, 15 insertions, 6 deletions
diff --git a/firmware/2lib/2auxfw_sync.c b/firmware/2lib/2auxfw_sync.c
index a60165c1..76ad7226 100644
--- a/firmware/2lib/2auxfw_sync.c
+++ b/firmware/2lib/2auxfw_sync.c
@@ -54,7 +54,8 @@ vb2_error_t vb2api_auxfw_sync(struct vb2_context *ctx)
enum vb2_auxfw_update_severity fw_update = VB2_AUXFW_NO_UPDATE;
/* Check for update severity */
- VB2_TRY(auxfw_sync_check_update(ctx, &fw_update));
+ VB2_TRY(auxfw_sync_check_update(ctx, &fw_update), ctx,
+ VB2_RECOVERY_AUXFW_UPDATE);
if (fw_update > VB2_AUXFW_NO_UPDATE) {
VB2_DEBUG("Updating auxfw\n");
diff --git a/tests/vb2_auxfw_sync_tests.c b/tests/vb2_auxfw_sync_tests.c
index bcdd67a8..9cd4999d 100644
--- a/tests/vb2_auxfw_sync_tests.c
+++ b/tests/vb2_auxfw_sync_tests.c
@@ -25,7 +25,8 @@ static uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE]
static struct vb2_shared_data *sd;
static struct vb2_gbb_header gbb;
-static vb2_error_t auxfw_retval;
+static vb2_error_t auxfw_check_retval;
+static vb2_error_t auxfw_update_retval;
static int auxfw_update_req;
static enum vb2_auxfw_update_severity auxfw_mock_severity;
static enum vb2_auxfw_update_severity auxfw_update_severity;
@@ -46,7 +47,8 @@ static void ResetMocks(void)
memset(&gbb, 0, sizeof(gbb));
- auxfw_retval = VB2_SUCCESS;
+ auxfw_check_retval = VB2_SUCCESS;
+ auxfw_update_retval = VB2_SUCCESS;
auxfw_mock_severity = VB2_AUXFW_NO_UPDATE;
auxfw_update_severity = VB2_AUXFW_NO_UPDATE;
auxfw_mock_display_available = 1;
@@ -65,7 +67,7 @@ vb2_error_t vb2ex_auxfw_check(enum vb2_auxfw_update_severity *severity)
{
*severity = auxfw_mock_severity;
auxfw_update_severity = auxfw_mock_severity;
- return VB2_SUCCESS;
+ return auxfw_check_retval;
}
vb2_error_t vb2ex_auxfw_update(void)
@@ -77,7 +79,7 @@ vb2_error_t vb2ex_auxfw_update(void)
if (auxfw_update_severity != VB2_AUXFW_NO_DEVICE &&
auxfw_update_severity != VB2_AUXFW_NO_UPDATE)
auxfw_update_req = 1;
- return auxfw_retval;
+ return auxfw_update_retval;
}
vb2_error_t vb2ex_auxfw_finalize(struct vb2_context *c)
@@ -152,7 +154,13 @@ static void VbSoftwareSyncTest(void)
ResetMocks();
auxfw_mock_severity = VB2_AUXFW_FAST_UPDATE;
- auxfw_retval = VB2_ERROR_UNKNOWN;
+ auxfw_check_retval = VB2_ERROR_UNKNOWN;
+ test_auxsync(VB2_ERROR_UNKNOWN, VB2_RECOVERY_AUXFW_UPDATE,
+ "Error checking auxfw");
+
+ ResetMocks();
+ auxfw_mock_severity = VB2_AUXFW_FAST_UPDATE;
+ auxfw_update_retval = VB2_ERROR_UNKNOWN;
test_auxsync(VB2_ERROR_UNKNOWN, VB2_RECOVERY_AUXFW_UPDATE,
"Error updating auxfw");
}