diff options
author | Nikolai Artemiev <nartemiev@google.com> | 2023-03-02 11:45:29 +1100 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-09 06:08:41 +0000 |
commit | 2bf1f59707de0ec20e4613ae36882e347b46b061 (patch) | |
tree | e23e637d8d27c5c4ddf589df5067b250dfa7a770 /futility | |
parent | d0c79c0a28fc6ea315269e183f8cd65c389a2369 (diff) | |
download | vboot-2bf1f59707de0ec20e4613ae36882e347b46b061.tar.gz |
vboot_reference: Change flashrom_get_wp signature
Expose more information about WP state from the flashrom_drv WP status
function.
The more detailed WP information is required to properly validate the
system WP configuration.
BUG=b:268574030
TEST=futility update
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Change-Id: If79b7d8cc68a0583cbf1f7049ac7a2dec088fdd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4301750
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'futility')
-rw-r--r-- | futility/cmd_gbb_utility.c | 2 | ||||
-rw-r--r-- | futility/updater.c | 4 | ||||
-rw-r--r-- | futility/updater_dut.c | 10 | ||||
-rw-r--r-- | futility/updater_utils.c | 13 |
4 files changed, 13 insertions, 16 deletions
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c index db0c04a1..79c14130 100644 --- a/futility/cmd_gbb_utility.c +++ b/futility/cmd_gbb_utility.c @@ -440,7 +440,7 @@ static int write_to_flash(struct updater_config *cfg, uint8_t *outbuf, off_t filesize) { #ifdef USE_FLASHROM - if (is_write_protection_enabled(cfg) == WP_ENABLED) { + if (is_write_protection_enabled(cfg)) { ERROR("You must disable write protection before setting flags.\n"); return -1; } diff --git a/futility/updater.c b/futility/updater.c index 362d5dfc..7f1e215f 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -348,9 +348,7 @@ static int write_optional_firmware(struct updater_config *cfg, * EC & PD may have different WP settings and we want to write * only if it is OK. */ - if (check_programmer_wp && - dut_get_property(DUT_PROP_WP_HW, cfg) == WP_ENABLED && - flashrom_get_wp(image->programmer, -1) == WP_ENABLED) { + if (check_programmer_wp && is_write_protection_enabled(cfg)) { ERROR("Target %s is write protected, skip updating.\n", image->programmer); return 0; diff --git a/futility/updater_dut.c b/futility/updater_dut.c index 6cb03727..634fd447 100644 --- a/futility/updater_dut.c +++ b/futility/updater_dut.c @@ -107,7 +107,7 @@ static int dut_get_tpm_fwver(struct updater_config *cfg) static int dut_get_wp_hw(struct updater_config *cfg) { /* wpsw refers to write protection 'switch', not 'software'. */ - return dut_get_property_int("wpsw_cur", cfg) ? WP_ENABLED : WP_DISABLED; + return dut_get_property_int("wpsw_cur", cfg); } static int dut_get_platform_version(struct updater_config *cfg) @@ -125,7 +125,13 @@ static int dut_get_platform_version(struct updater_config *cfg) static int dut_get_wp_sw(struct updater_config *cfg) { assert(cfg->image.programmer); - return flashrom_get_wp(cfg->image.programmer, -1); + bool mode; + + if (flashrom_get_wp(cfg->image.programmer, &mode, NULL, NULL, -1)) { + /* Read WP status error */ + return -1; + } + return mode; } /* Helper functions to use or configure the DUT properties. */ diff --git a/futility/updater_utils.c b/futility/updater_utils.c index b04e56ca..03b0378d 100644 --- a/futility/updater_utils.c +++ b/futility/updater_utils.c @@ -362,16 +362,9 @@ const struct vb2_gbb_header *find_gbb(const struct firmware_image *image) */ int is_write_protection_enabled(struct updater_config *cfg) { - /* Default to enabled. */ - int wp = dut_get_property(DUT_PROP_WP_HW, cfg); - if (wp == WP_DISABLED) - return wp; - /* For error or enabled, check WP SW. */ - wp = dut_get_property(DUT_PROP_WP_SW, cfg); - /* Consider all errors as enabled. */ - if (wp != WP_DISABLED) - return WP_ENABLED; - return wp; + /* Assume HW/SW WP are enabled if -1 error code is returned */ + return dut_get_property(DUT_PROP_WP_HW, cfg) && + dut_get_property(DUT_PROP_WP_SW, cfg); } /* |