diff --git a/futility/updater.c b/futility/updater.c index 71a498e3..fa008542 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -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, diff --git a/futility/updater.h b/futility/updater.h index a4f55806..69ba5e2d 100644 --- a/futility/updater.h +++ b/futility/updater.h @@ -45,6 +45,7 @@ enum quirk_types { QUIRK_EC_PARTIAL_RECOVERY, QUIRK_OVERRIDE_SIGNATURE_ID, QUIRK_PRESERVE_ME, + QUIRK_NO_CHECK_PLATFORM, QUIRK_MAX, }; diff --git a/futility/updater_quirks.c b/futility/updater_quirks.c index b3dea936..b9bdb2ca 100644 --- a/futility/updater_quirks.c +++ b/futility/updater_quirks.c @@ -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; } /* diff --git a/tests/futility/test_update.sh b/tests/futility/test_update.sh index ae4a3624..31f3ecbf 100755 --- a/tests/futility/test_update.sh +++ b/tests/futility/test_update.sh @@ -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"