futility: updater: Check and use larger regions in EC RO update

Unlike STM32 (used on ARM Chromebooks), EC images on most x86
Chromebooks used to have a header before EC_RO section describing the
size and attributes of firmware to load.  However, partial updating with
only 'EC_RO' by flashrom will not include those data. So we should use
'WP_RO' to update whole RO area.

This also implies EC RO software sync, which usually only updates
ec.RO.bin in EC_RO, is not safe on devices with extra data. A quick
solution is to only allow RO software sync when EC_RO is aligned to top
of EC firmware image. Also in future devices cannot run EC software sync
may skip generating EC RO blobs in AP coreboot CBFS so the updater won't
try to do RO software sync.

BUG=chromium:1024401
TEST=(kukui) chromeos-firmwareupdate --mode=recovery # updated and boot
     (laser) chromeos-firmwareupdate --mode=recovery # updated and boot
     also verified we can update from old x86 EC (EC_RO does not
     include header) to new style (EC_RO contains header).

Change-Id: I2c90320ffbfd79ba0cbaf70016446d8ab489e6ac
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1919097
Reviewed-by: Shelley Chen <shchen@chromium.org>
This commit is contained in:
Hung-Te Lin 2019-11-16 04:10:23 +08:00 committed by Commit Bot
parent 32b5c34d13
commit 6737b9e9a7
1 changed files with 10 additions and 1 deletions

View File

@ -1553,6 +1553,11 @@ static int ec_ro_software_sync(struct updater_config *cfg)
ERROR("EC image has invalid section '%s'.\n", "EC_RO");
return 1;
}
if (ec_ro_sec.data != cfg->ec_image.data) {
/* http://crbug.com/1024401: EC_RO is not enough. */
ERROR("EC may need to update data outside EC RO Sync.");
return 1;
}
if (cbfs_extract_file(tmp_path, FMAP_RO_SECTION, "ecro", ec_ro_path) ||
!cbfs_file_exists(tmp_path, FMAP_RO_SECTION, "ecro.hash")) {
INFO("No valid EC RO for software sync in AP firmware.\n");
@ -1605,7 +1610,11 @@ static int is_ec_in_rw(void)
*/
static int update_ec_firmware(struct updater_config *cfg)
{
const char *ec_ro = "EC_RO";
/*
* http://crbug.com/1024401: Some EC needs extra header outside EC_RO so
* we have to update whole WP_RO, not just EC_RO.
*/
const char *ec_ro = "WP_RO";
struct firmware_image *ec_image = &cfg->ec_image;
/* TODO(hungte) Check if we have EC RO in AP image without --ec_image */