diff options
-rw-r--r-- | futility/updater.c | 31 | ||||
-rw-r--r-- | futility/updater.h | 8 | ||||
-rw-r--r-- | futility/updater_archive.c | 71 | ||||
-rw-r--r-- | futility/updater_quirks.c | 35 | ||||
-rwxr-xr-x | tests/futility/models/customtip/setvars.sh (renamed from tests/futility/models/whitetip/setvars.sh) | 4 | ||||
-rwxr-xr-x | tests/futility/test_update.sh | 73 |
6 files changed, 117 insertions, 105 deletions
diff --git a/futility/updater.c b/futility/updater.c index 06a696c3..6e91d6f8 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -1450,19 +1450,19 @@ static int updater_output_image(const struct firmware_image *image, } /* - * Applies white label information to an existing model config. + * Applies custom label information to an existing model config. * Returns 0 on success, otherwise failure. */ -static int updater_apply_white_label(struct updater_config *cfg, +static int updater_apply_custom_label(struct updater_config *cfg, struct model_config *model, const char *signature_id) { const char *tmp_image = NULL; - assert(model->is_white_label); + assert(model->is_custom_label); if (!signature_id) { if (!cfg->image_current.data) { - INFO("Loading system firmware for white label...\n"); + INFO("Loading system firmware for custom label...\n"); load_system_firmware(&cfg->image_current, &cfg->tempfiles, get_io_retries(cfg), @@ -1479,7 +1479,7 @@ static int updater_apply_white_label(struct updater_config *cfg, quirk_override_signature_id( cfg, model, &signature_id); } - return !!model_apply_white_label( + return !!model_apply_custom_label( model, cfg->archive, signature_id, tmp_image); } @@ -1508,33 +1508,34 @@ static int updater_setup_archive( if (!model) return ++errorcnt; - /* Load images now so we can get quirks in WL checks. */ + /* Load images now so we can get quirks in custom label checks. */ errorcnt += updater_load_images( cfg, arg, model->image, model->ec_image, model->pd_image); - if (model->is_white_label && !manifest->has_keyset) { + if (model->is_custom_label && !manifest->has_keyset) { /* * Developers running unsigned updaters (usually local build) - * won't be able match any white label tags. + * won't be able match any custom label tags. */ WARN("No keysets found - this is probably a local build of \n" - "unsigned firmware updater. Skip applying white label."); - } else if (model->is_white_label) { + "unsigned firmware updater. Skip applying custom label."); + } else if (model->is_custom_label) { /* - * It is fine to fail in updater_apply_white_label for factory + * It is fine to fail in updater_apply_custom_label for factory * mode so we are not checking the return value; instead we * verify if the patches do contain new root key. */ - updater_apply_white_label(cfg, (struct model_config *)model, + updater_apply_custom_label(cfg, (struct model_config *)model, arg->signature_id); if (!model->patches.rootkey) { if (is_factory || is_write_protection_enabled(cfg) || - get_config_quirk(QUIRK_ALLOW_EMPTY_WLTAG, cfg)) { - WARN("No VPD for white label.\n"); + get_config_quirk(QUIRK_ALLOW_EMPTY_CUSTOMLABEL_TAG, + cfg)) { + WARN("No VPD for custom label.\n"); } else { - ERROR("Need VPD set for white label.\n"); + ERROR("Need VPD set for custom label.\n"); return ++errorcnt; } } diff --git a/futility/updater.h b/futility/updater.h index 6dda9283..4e10fc7f 100644 --- a/futility/updater.h +++ b/futility/updater.h @@ -42,7 +42,7 @@ enum quirk_types { QUIRK_UNLOCK_ME_FOR_UPDATE, QUIRK_UNLOCK_WILCO_ME_FOR_UPDATE, QUIRK_EVE_SMM_STORE, - QUIRK_ALLOW_EMPTY_WLTAG, + QUIRK_ALLOW_EMPTY_CUSTOMLABEL_TAG, QUIRK_EC_PARTIAL_RECOVERY, QUIRK_OVERRIDE_SIGNATURE_ID, QUIRK_PRESERVE_ME, @@ -105,7 +105,7 @@ struct model_config { char *image, *ec_image, *pd_image; struct patch_config patches; char *signature_id; - int is_white_label; + int is_custom_label; }; struct manifest { @@ -273,12 +273,12 @@ const struct model_config *manifest_find_model(const struct manifest *manifest, const char *model_name); /* - * Applies white label information to an existing model configuration. + * Applies custom label information to an existing model configuration. * Collects signature ID information from either parameter signature_id or * image file (via VPD) and updates model.patches for key files. * Returns 0 on success, otherwise failure. */ -int model_apply_white_label( +int model_apply_custom_label( struct model_config *model, struct archive *archive, const char *signature_id, diff --git a/futility/updater_archive.c b/futility/updater_archive.c index 9c3a608d..fb917228 100644 --- a/futility/updater_archive.c +++ b/futility/updater_archive.c @@ -48,27 +48,28 @@ * - host: 'image.bin' (or 'bios.bin' as legacy name before CL:1318712) * - ec: 'ec.bin' * - pd: 'pd.bin' - * If white label is supported, a 'keyset/' folder will be available, with key + * If custom label is supported, a 'keyset/' folder will be available, with key * files in it: - * - rootkey.$WLTAG - * - vblock_A.$WLTAG - * - vblock_B.$WLTAG - * The $WLTAG should come from VPD value 'whitelabel_tag', or the - * 'customization_id'. Note 'customization_id' is in format LOEM[-VARIANT] and - * we can only take LOEM as $WLTAG, for example A-B => $WLTAG=A. + * - rootkey.$CLTAG + * - vblock_A.$CLTAG + * - vblock_B.$CLTAG + * The $CLTAG should come from VPD value 'customlabel_tag'. For legacy devices, + * the VPD name may be 'whitelabel_tag', or 'customization_id'. + * The 'customization_id' has a different format: LOEM[-VARIANT] and we can only + * take LOEM as $CLTAG, for example A-B => $CLTAG=A. * * A package for Unified Build is more complicated. There will be a models/ * folder, and each model (by $(mosys platform model) ) should appear as a sub * folder, with a 'setvars.sh' file inside. The 'setvars.sh' is a shell script * describing what files should be used and the signature ID ($SIGID) to use. * - * Similar to write label in non-Unified-Build, the keys and vblock files will + * Similar to custom label in non-Unified-Build, the keys and vblock files will * be in 'keyset/' folder: * - rootkey.$SIGID * - vblock_A.$SIGID * - vblock_B.$SIGID * If $SIGID starts with 'sig-id-in-*' then we have to replace it by VPD value - * 'whitelabel_tag' as '$MODEL-$WLTAG'. + * 'customlabel_tag' as '$MODEL-$CLTAG'. */ static const char * const SETVARS_IMAGE_MAIN = "IMAGE_MAIN", @@ -79,7 +80,8 @@ static const char * const SETVARS_IMAGE_MAIN = "IMAGE_MAIN", * const DIR_KEYSET = "keyset", * const DIR_MODELS = "models", * const DEFAULT_MODEL_NAME = "default", - * const VPD_WHITELABEL_TAG = "whitelabel_tag", + * const VPD_CUSTOMLABEL_TAG = "customlabel_tag", + * const VPD_CUSTOMLABEL_TAG_LEGACY = "whitelabel_tag", * const VPD_CUSTOMIZATION_ID = "customization_id", * const ENV_VAR_MODEL_DIR = "${MODEL_DIR}", * const PATH_STARTSWITH_KEYSET = "keyset/", @@ -606,7 +608,7 @@ static int model_config_parse_setvars_file( else if (strcmp(k, SETVARS_SIGNATURE_ID) == 0) { cfg->signature_id = strdup(v); if (str_startswith(v, SIG_ID_IN_VPD_PREFIX)) - cfg->is_white_label = 1; + cfg->is_custom_label = 1; } else found_valid = 0; free(expand_path); @@ -909,53 +911,56 @@ const struct model_config *manifest_find_model(const struct manifest *manifest, } /* - * Determines the signature ID to use for white label. + * Determines the signature ID to use for custom label. * Returns the signature ID for looking up rootkey and vblock files. * Caller must free the returned string. */ static char *resolve_signature_id(struct model_config *model, const char *image) { int is_unibuild = model->signature_id ? 1 : 0; - char *wl_tag = vpd_get_value(image, VPD_WHITELABEL_TAG); + char *tag = vpd_get_value(image, VPD_CUSTOMLABEL_TAG); char *sig_id = NULL; - /* Unified build: $model.$wl_tag, or $model (b/126800200). */ + if (tag == NULL) + tag = vpd_get_value(image, VPD_CUSTOMLABEL_TAG_LEGACY); + + /* Unified build: $model.$tag, or $model (b/126800200). */ if (is_unibuild) { - if (!wl_tag) { - WARN("No VPD '%s' set for white label - use model name " - "'%s' as default.\n", VPD_WHITELABEL_TAG, - model->name); + if (!tag) { + WARN("No VPD '%s' set for custom label. " + "Use model name '%s' as default.\n", + VPD_CUSTOMLABEL_TAG, model->name); return strdup(model->name); } - ASPRINTF(&sig_id, "%s-%s", model->name, wl_tag); - free(wl_tag); + ASPRINTF(&sig_id, "%s-%s", model->name, tag); + free(tag); return sig_id; } - /* Non-Unibuild: Upper($wl_tag), or Upper(${cid%%-*}). */ - if (!wl_tag) { + /* Non-Unibuild: Upper($tag), or Upper(${cid%%-*}). */ + if (!tag) { char *cid = vpd_get_value(image, VPD_CUSTOMIZATION_ID); if (cid) { /* customization_id in format LOEM[-VARIANT]. */ char *dash = strchr(cid, '-'); if (dash) *dash = '\0'; - wl_tag = cid; + tag = cid; } } - if (wl_tag) - str_convert(wl_tag, toupper); - return wl_tag; + if (tag) + str_convert(tag, toupper); + return tag; } /* - * Applies white label information to an existing model configuration. + * Applies custom label information to an existing model configuration. * Collects signature ID information from either parameter signature_id or * image file (via VPD) and updates model.patches for key files. * Returns 0 on success, otherwise failure. */ -int model_apply_white_label( +int model_apply_custom_label( struct model_config *model, struct archive *archive, const char *signature_id, @@ -970,19 +975,19 @@ int model_apply_white_label( } if (signature_id) { - VB2_DEBUG("Find white label patches by signature ID: '%s'.\n", + VB2_DEBUG("Find custom label patches by signature ID: '%s'.\n", signature_id); find_patches_for_model(model, archive, signature_id); } else { signature_id = ""; - WARN("No VPD '%s' set for white label - use default keys.\n", - VPD_WHITELABEL_TAG); + WARN("No VPD '%s' set for custom label - use default keys.\n", + VPD_CUSTOMLABEL_TAG); } if (!model->patches.rootkey) { ERROR("No keys found for signature_id: '%s'\n", signature_id); r = 1; } else { - INFO("Applied for white label: %s\n", signature_id); + INFO("Applied for custom label: %s\n", signature_id); } free(sig_id); return r; @@ -1035,7 +1040,7 @@ struct manifest *new_manifest_from_archive(struct archive *archive) if (!model.name) model.name = strdup(DEFAULT_MODEL_NAME); if (manifest.has_keyset) - model.is_white_label = 1; + model.is_custom_label = 1; manifest_add_model(&manifest, &model); manifest.default_model = manifest.num - 1; } diff --git a/futility/updater_quirks.c b/futility/updater_quirks.c index c8140c1d..7a135b82 100644 --- a/futility/updater_quirks.c +++ b/futility/updater_quirks.c @@ -56,18 +56,23 @@ static const struct quirks_record quirks_records[] = { { .match = "Google_Scarlet.", .quirks = "min_platform_version=1" }, { .match = "Google_Trogdor.", .quirks = "min_platform_version=2" }, - /* Legacy white label units. */ - { .match = "Google_Enguarde.", .quirks = "allow_empty_wltag" }, - { .match = "Google_Expresso.", .quirks = "allow_empty_wltag" }, - { .match = "Google_Hana.", .quirks = "allow_empty_wltag" }, - { .match = "Google_Veyron_Jaq.", .quirks = "allow_empty_wltag" }, - { .match = "Google_Veyron_Jerry.", .quirks = "allow_empty_wltag" }, - { .match = "Google_Veyron_Mighty.", .quirks = "allow_empty_wltag" }, - { .match = "Google_Reks.", .quirks = "allow_empty_wltag" }, - { .match = "Google_Relm.", .quirks = "allow_empty_wltag" }, - { .match = "Google_Wizpig.", .quirks = "allow_empty_wltag" }, - - { .match = "Google_Phaser.", .quirks = "override_signature_id" }, + /* Legacy custom label units. */ + { .match = "Google_Hana.", .quirks = "allow_empty_customlabel_tag" }, + { .match = "Google_Reks.", .quirks = "allow_empty_customlabel_tag" }, + { .match = "Google_Relm.", .quirks = "allow_empty_customlabel_tag" }, + { .match = "Google_Wizpig.", .quirks = "allow_empty_customlabel_tag" }, + { .match = "Google_Enguarde.", + .quirks = "allow_empty_customlabel_tag" }, + { .match = "Google_Expresso.", + .quirks = "allow_empty_customlabel_tag" }, + { .match = "Google_Veyron_Jaq.", + .quirks = "allow_empty_customlabel_tag" }, + { .match = "Google_Veyron_Jerry.", + .quirks = "allow_empty_customlabel_tag" }, + { .match = "Google_Veyron_Mighty.", + .quirks = "allow_empty_customlabel_tag" }, + + { .match = "Google_Phaser.", .quirks = "override_signature_id" }, }; /* Preserves meta data and reload image contents from given file path. */ @@ -479,9 +484,9 @@ void updater_register_quirks(struct updater_config *cfg) "dedicated FMAP section."; quirks->apply = quirk_eve_smm_store; - quirks = &cfg->quirks[QUIRK_ALLOW_EMPTY_WLTAG]; - quirks->name = "allow_empty_wltag"; - quirks->help = "chromium/906962; allow devices without white label " + quirks = &cfg->quirks[QUIRK_ALLOW_EMPTY_CUSTOMLABEL_TAG]; + quirks->name = "allow_empty_customlabel_tag"; + quirks->help = "chromium/906962; allow devices without custom label " "tags set to use default keys."; quirks->apply = NULL; /* Simple config. */ diff --git a/tests/futility/models/whitetip/setvars.sh b/tests/futility/models/customtip/setvars.sh index 4b9cb406..a4bb55a9 100755 --- a/tests/futility/models/whitetip/setvars.sh +++ b/tests/futility/models/customtip/setvars.sh @@ -7,14 +7,14 @@ # particular model. The pack_firmware.py script uses this to create a working # setvars-model.sh script. -# Version information for model whitetip +# Version information for model customtip TARGET_RO_FWID="Google_Coral.10068.45.0" TARGET_FWID="Google_Coral.10068.45.0" TARGET_ECID="coral_v1.1.7272-0b44fba22" TARGET_PDID="" TARGET_PLATFORM="Google_Coral" -# Image and key files for model whitetip +# Image and key files for model customtip IMAGE_MAIN="images/bios_coral.bin" IMAGE_EC="" IMAGE_PD="" diff --git a/tests/futility/test_update.sh b/tests/futility/test_update.sh index 25c55432..8b247429 100755 --- a/tests/futility/test_update.sh +++ b/tests/futility/test_update.sh @@ -371,10 +371,10 @@ test_update "Full update (--quirks preserve_me)" \ --quirks preserve_me \ -i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1 -# Test archive and manifest. +# Test archive and manifest. CL_TAG is for customlabel_tag. A="${TMP}.archive" mkdir -p "${A}/bin" -echo 'echo "${WL_TAG}"' >"${A}/bin/vpd" +echo 'echo "${CL_TAG}"' >"${A}/bin/vpd" chmod +x "${A}/bin/vpd" cp -f "${LINK_BIOS}" "${A}/bios.bin" @@ -400,38 +400,39 @@ cmp "${LINK_BIOS}" "${TMP}.output/image.bin" mkdir -p "${A}/keyset" cp -f "${LINK_BIOS}" "${A}/image.bin" -cp -f "${TMP}.to/rootkey" "${A}/keyset/rootkey.WL" -cp -f "${TMP}.to/VBLOCK_A" "${A}/keyset/vblock_A.WL" -cp -f "${TMP}.to/VBLOCK_B" "${A}/keyset/vblock_B.WL" +cp -f "${TMP}.to/rootkey" "${A}/keyset/rootkey.CL" +cp -f "${TMP}.to/VBLOCK_A" "${A}/keyset/vblock_A.CL" +cp -f "${TMP}.to/VBLOCK_B" "${A}/keyset/vblock_B.CL" ${FUTILITY} gbb -s --rootkey="${TMP}.from/rootkey" "${A}/image.bin" ${FUTILITY} load_fmap "${A}/image.bin" VBLOCK_A:"${TMP}.from/VBLOCK_A" ${FUTILITY} load_fmap "${A}/image.bin" VBLOCK_B:"${TMP}.from/VBLOCK_B" -test_update "Full update (--archive, whitelabel, no VPD)" \ - "${A}/image.bin" "!Need VPD set for white" \ +test_update "Full update (--archive, custom label, no VPD)" \ + "${A}/image.bin" "!Need VPD set for custom" \ -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 -test_update "Full update (--archive, whitelabel, no VPD - factory mode)" \ +test_update "Full update (--archive, custom label, no VPD - factory mode)" \ "${LINK_BIOS}" "${A}/image.bin" \ -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --mode=factory -test_update "Full update (--archive, whitelabel, no VPD - quirk mode)" \ +test_update "Full update (--archive, custom label, no VPD - quirk mode)" \ "${LINK_BIOS}" "${A}/image.bin" \ - -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --quirks=allow_empty_wltag + -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 \ + --quirks=allow_empty_customlabel_tag -test_update "Full update (--archive, WL, single package)" \ +test_update "Full update (--archive, custom label, single package)" \ "${A}/image.bin" "${LINK_BIOS}" \ - -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --signature_id=WL + -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --signature_id=CL -WL_TAG="WL" PATH="${A}/bin:${PATH}" \ - test_update "Full update (--archive, WL, fake vpd)" \ +CL_TAG="CL" PATH="${A}/bin:${PATH}" \ + test_update "Full update (--archive, custom label, fake vpd)" \ "${A}/image.bin" "${LINK_BIOS}" \ -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 echo "TEST: Output (-a, --mode=output)" mkdir -p "${TMP}.outa" cp -f "${A}/image.bin" "${TMP}.emu" -WL_TAG="WL" PATH="${A}/bin:${PATH}" \ +CL_TAG="CL" PATH="${A}/bin:${PATH}" \ ${FUTILITY} update -a "${A}" --mode=output --emu="${TMP}.emu" \ --output_dir="${TMP}.outa" cmp "${LINK_BIOS}" "${TMP}.outa/image.bin" @@ -442,9 +443,9 @@ mkdir -p "${A}/images" mv "${A}/image.bin" "${A}/images/bios_coral.bin" cp -f "${PEPPY_BIOS}" "${A}/images/bios_peppy.bin" cp -f "${LINK_BIOS}" "${A}/images/bios_link.bin" -cp -f "${TMP}.to/rootkey" "${A}/keyset/rootkey.whitetip-wl" -cp -f "${TMP}.to/VBLOCK_A" "${A}/keyset/vblock_A.whitetip-wl" -cp -f "${TMP}.to/VBLOCK_B" "${A}/keyset/vblock_B.whitetip-wl" +cp -f "${TMP}.to/rootkey" "${A}/keyset/rootkey.customtip-cl" +cp -f "${TMP}.to/VBLOCK_A" "${A}/keyset/vblock_A.customtip-cl" +cp -f "${TMP}.to/VBLOCK_B" "${A}/keyset/vblock_B.customtip-cl" cp -f "${PEPPY_BIOS}" "${FROM_IMAGE}.ap" cp -f "${LINK_BIOS}" "${FROM_IMAGE}.al" patch_file ${FROM_IMAGE}.ap FW_MAIN_A 0 "corrupted" @@ -458,28 +459,28 @@ test_update "Full update (--archive, model=peppy)" \ test_update "Full update (--archive, model=unknown)" \ "${FROM_IMAGE}.ap" "!Unsupported model: 'unknown'" \ -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --model=unknown -test_update "Full update (--archive, model=whitetip, signature_id=WL)" \ +test_update "Full update (--archive, model=customtip, signature_id=CL)" \ "${FROM_IMAGE}.al" "${LINK_BIOS}" \ - -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --model=whitetip \ - --signature_id=whitetip-wl + -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --model=customtip \ + --signature_id=customtip-cl -WL_TAG="wl" PATH="${A}/bin:${PATH}" \ - test_update "Full update (-a, model=WL, fake VPD)" \ +CL_TAG="cl" PATH="${A}/bin:${PATH}" \ + test_update "Full update (-a, model=customtip, fake VPD)" \ "${FROM_IMAGE}.al" "${LINK_BIOS}" \ - -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --model=whitetip - -# WL-Unibuild without default keys -test_update "Full update (--a, model=WL, no VPD, no default keys)" \ - "${FROM_IMAGE}.al" "!Need VPD set for white" \ - -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --model=whitetip - -# WL-Unibuild with default keys as model name -cp -f "${TMP}.to/rootkey" "${A}/keyset/rootkey.whitetip" -cp -f "${TMP}.to/VBLOCK_A" "${A}/keyset/vblock_A.whitetip" -cp -f "${TMP}.to/VBLOCK_B" "${A}/keyset/vblock_B.whitetip" -test_update "Full update (-a, model=WL, no VPD, default keys)" \ + -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --model=customtip + +# Custom label + Unibuild without default keys +test_update "Full update (--a, model=customtip, no VPD, no default keys)" \ + "${FROM_IMAGE}.al" "!Need VPD set for custom" \ + -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --model=customtip + +# Custom label + Unibuild with default keys as model name +cp -f "${TMP}.to/rootkey" "${A}/keyset/rootkey.customtip" +cp -f "${TMP}.to/VBLOCK_A" "${A}/keyset/vblock_A.customtip" +cp -f "${TMP}.to/VBLOCK_B" "${A}/keyset/vblock_B.customtip" +test_update "Full update (-a, model=customtip, no VPD, default keys)" \ "${FROM_IMAGE}.al" "${LINK_BIOS}" \ - -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --model=whitetip + -a "${A}" --wp=0 --sys_props 0,0x10001,1,3 --model=customtip # Test special programmer if type flashrom >/dev/null 2>&1; then |