futility: update: add new quirk 'no_check_platform'

Some devices may have flashed firmware with different platform name in
their early stage (especially in the first build of leading devices),
so we do want to provide an explicit way (not just --force) to skip
checking platform name.

The change CL:2059621 does not help because the loaded system
firmware looks good.

This is implemented as a quirk so we can enable it using a CBFS quirk
file, making it easier to be deployed by auto update.

BRANCH=None
BUG=None
TEST=make runtests

Change-Id: I888d5848921d31c9b7cba1b96c42d38fda71927e
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2573999
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
This commit is contained in:
Hung-Te Lin 2020-12-04 16:15:00 +08:00 committed by Commit Bot
parent ebd1261eb5
commit 21b7225caf
4 changed files with 32 additions and 1 deletions

View File

@ -1209,8 +1209,13 @@ enum updater_error_codes update_firmware(struct updater_config *cfg)
image_from->file_name, image_from->ro_version,
image_from->rw_version_a, image_from->rw_version_b);
if (cfg->check_platform && check_compatible_platform(cfg))
try_apply_quirk(QUIRK_NO_CHECK_PLATFORM, cfg);
if (cfg->check_platform && check_compatible_platform(cfg)) {
ERROR("The firmware image is not compatible with your system. "
"If you really want to proceed, please run again with: "
"--quirks=no_check_platform\n");
return UPDATE_ERR_PLATFORM;
}
wp_enabled = is_write_protection_enabled(cfg);
STATUS("Write protection: %d (%s; HW=%d, SW=%d).\n", wp_enabled,

View File

@ -45,6 +45,7 @@ enum quirk_types {
QUIRK_EC_PARTIAL_RECOVERY,
QUIRK_OVERRIDE_SIGNATURE_ID,
QUIRK_PRESERVE_ME,
QUIRK_NO_CHECK_PLATFORM,
QUIRK_MAX,
};

View File

@ -414,6 +414,16 @@ static int quirk_preserve_me(struct updater_config *cfg)
return 1;
}
/*
* Disable checking platform compatibility.
*/
static int quirk_no_check_platform(struct updater_config *cfg)
{
WARN("Disabled checking platform. You are on your own.\n");
cfg->check_platform = 0;
return 0;
}
/*
* Registers known quirks to a updater_config object.
*/
@ -473,6 +483,11 @@ void updater_register_quirks(struct updater_config *cfg)
quirks->help = "b/165590952; Preserve ME during firmware update except "
"for factory update or developer images.";
quirks->apply = quirk_preserve_me;
quirks = &cfg->quirks[QUIRK_NO_CHECK_PLATFORM];
quirks->name = "no_check_platform";
quirks->help = "Do not check platform name.";
quirks->apply = quirk_no_check_platform;
}
/*

View File

@ -48,6 +48,7 @@ cp -f ${LINK_BIOS} ${TO_IMAGE}
cp -f ${PEPPY_BIOS} ${FROM_IMAGE}
"${FUTILITY}" load_fmap "${FROM_IMAGE}" \
RO_VPD:"${RO_VPD_BLOB}" RW_VPD:"${RO_VPD_BLOB}"
cp -f "${FROM_IMAGE}" "${FROM_IMAGE}".unpatched
patch_file() {
local file="$1"
@ -347,6 +348,15 @@ test_update "Full update (--quirks min_platform_version)" \
--quirks min_platform_version=3 \
-i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1,3
test_update "Full update (incompatible platform)" \
"${FROM_IMAGE}".unpatched "!platform is not compatible" \
-i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1
test_update "Full update (--quirks no_check_platform)" \
"${FROM_IMAGE}".unpatched "${TMP}.expected.full" \
--quirks no_check_platform \
-i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1
# Test archive and manifest.
A="${TMP}.archive"
mkdir -p "${A}/bin"