summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@google.com>2017-08-11 17:07:10 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-02-12 19:49:03 +0000
commitbc046644029a9b9af7f59ffde42308ed3d89b196 (patch)
tree109e02266eb69bffdf7f2f20167bc037d491c43f
parent1e557c2ff297a4402c82e3dadc64c723a925523f (diff)
downloadvboot-bc046644029a9b9af7f59ffde42308ed3d89b196.tar.gz
ec_sync: always call VbExUpdateAuxFw
call VbExUpdateAuxFw() uncontidionally, instead of when we know we need to do an update. Vb*AuxFw() already maintains state, so this doesn't change when we (attempt) to update firmware. however, this does allow us to iterate over all firmware drivers to call their .protect() method. previously, we would only call .protect() after an actual firmware update. updated unit tests to match the new logic. BRANCH=none BUG=b:35585700 TEST=verified i2c tunnels are protected on reef using ectool i2cprotect N status. Change-Id: I341035188e622772d64b98414bdf81d9444b9a89 Signed-off-by: Duncan Laurie <dlaurie@google.com> Original-Commit-Id: 5afa7faf7bfc4ec5efd22af5f2124a575bc64e52 Original-Change-Id: I9244db28ed181f568d117092307293202257735b Original-Signed-off-by: Caveh Jalali <caveh@google.com> Original-Reviewed-on: https://chromium-review.googlesource.com/620281 Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/914549
-rw-r--r--firmware/lib/ec_sync_all.c8
-rw-r--r--tests/ec_sync_tests.c25
2 files changed, 21 insertions, 12 deletions
diff --git a/firmware/lib/ec_sync_all.c b/firmware/lib/ec_sync_all.c
index af06b0ec..aeec6079 100644
--- a/firmware/lib/ec_sync_all.c
+++ b/firmware/lib/ec_sync_all.c
@@ -71,11 +71,9 @@ VbError_t ec_sync_all(struct vb2_context *ctx, struct VbCommonParams *cparams)
/*
* Do software sync for devices tunneled throught the EC.
*/
- if (fw_update != VB_AUX_FW_NO_UPDATE) {
- rv = VbExUpdateAuxFw();
- if (rv)
- return rv;
- }
+ rv = VbExUpdateAuxFw();
+ if (rv)
+ return rv;
/*
* Reboot to unload VGA Option ROM if:
diff --git a/tests/ec_sync_tests.c b/tests/ec_sync_tests.c
index 66ea1ca2..dc708c1f 100644
--- a/tests/ec_sync_tests.c
+++ b/tests/ec_sync_tests.c
@@ -61,7 +61,9 @@ static uint32_t screens_displayed[8];
static uint32_t screens_count = 0;
static int ec_aux_fw_update_req;
+static VbAuxFwUpdateSeverity_t ec_aux_fw_mock_severity;
static VbAuxFwUpdateSeverity_t ec_aux_fw_update_severity;
+static int ec_aux_fw_protected;
/* Reset mock data (for use before each test) */
static void ResetMocks(void)
@@ -121,8 +123,10 @@ static void ResetMocks(void)
memset(screens_displayed, 0, sizeof(screens_displayed));
screens_count = 0;
+ ec_aux_fw_mock_severity = VB_AUX_FW_NO_UPDATE;
ec_aux_fw_update_severity = VB_AUX_FW_NO_UPDATE;
ec_aux_fw_update_req = 0;
+ ec_aux_fw_protected = 0;
}
/* Mock functions */
@@ -221,13 +225,15 @@ VbError_t VbDisplayScreen(struct vb2_context *ctx, VbCommonParams *cparams,
VbError_t VbExCheckAuxFw(VbAuxFwUpdateSeverity_t *severity)
{
- *severity = ec_aux_fw_update_severity;
+ *severity = ec_aux_fw_mock_severity;
+ ec_aux_fw_update_severity = ec_aux_fw_mock_severity;
return VBERROR_SUCCESS;
}
VbError_t VbExUpdateAuxFw()
{
- ec_aux_fw_update_req = 1;
+ ec_aux_fw_update_req = ec_aux_fw_update_severity != VB_AUX_FW_NO_UPDATE;
+ ec_aux_fw_protected = 1;
return VBERROR_SUCCESS;
}
@@ -419,41 +425,46 @@ static void VbSoftwareSyncTest(void)
ResetMocks();
cparams.gbb->flags |= GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC;
- ec_aux_fw_update_severity = VB_AUX_FW_FAST_UPDATE;
+ ec_aux_fw_mock_severity = VB_AUX_FW_FAST_UPDATE;
test_ssync(VBERROR_SUCCESS, 0,
"GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC"
" disables auxiliary FW update request");
TEST_EQ(ec_aux_fw_update_req, 0, " aux fw update disabled");
+ TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected");
ResetMocks();
cparams.gbb->flags |= GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC;
- ec_aux_fw_update_severity = VB_AUX_FW_FAST_UPDATE;
+ ec_aux_fw_mock_severity = VB_AUX_FW_FAST_UPDATE;
test_ssync(VBERROR_SUCCESS, 0,
"GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC"
" disables auxiliary FW update request");
TEST_EQ(ec_aux_fw_update_req, 0, " aux fw update disabled");
+ TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected");
ResetMocks();
- ec_aux_fw_update_severity = VB_AUX_FW_NO_UPDATE;
+ ec_aux_fw_mock_severity = VB_AUX_FW_NO_UPDATE;
test_ssync(VBERROR_SUCCESS, 0,
"No auxiliary FW update needed");
TEST_EQ(screens_count, 0,
" wait screen skipped");
TEST_EQ(ec_aux_fw_update_req, 0, " no aux fw update requested");
+ TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected");
ResetMocks();
- ec_aux_fw_update_severity = VB_AUX_FW_FAST_UPDATE;
+ ec_aux_fw_mock_severity = VB_AUX_FW_FAST_UPDATE;
test_ssync(VBERROR_SUCCESS, 0,
"Fast auxiliary FW update needed");
TEST_EQ(screens_count, 0,
" wait screen skipped");
TEST_EQ(ec_aux_fw_update_req, 1, " aux fw update requested");
+ TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected");
ResetMocks();
- ec_aux_fw_update_severity = VB_AUX_FW_SLOW_UPDATE;
+ ec_aux_fw_mock_severity = VB_AUX_FW_SLOW_UPDATE;
test_ssync(VBERROR_SUCCESS, 0,
"Slow auxiliary FW update needed");
TEST_EQ(ec_aux_fw_update_req, 1, " aux fw update requested");
+ TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected");
TEST_EQ(screens_displayed[0], VB_SCREEN_WAIT,
" wait screen forced");
}