summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2023-05-11 15:58:05 +1000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-12 13:19:15 +0000
commit4634d58ac99d495ecba149386a20c6be68e95157 (patch)
tree6c6bfa081facf31d37457f1ca1c020d10ce15adf
parentf029229daac8a4571be184641cb135ff9c59b6b0 (diff)
downloadvboot-4634d58ac99d495ecba149386a20c6be68e95157.tar.gz
futility/cmd_flash_util.c: Print fw expected wp sr conf values
AP RO verification in the case of non-factory flows wishes to determine the WP configuration values needed to calculate the SR configuration data as defined by the firmware image. Since we already do this to configure WP correctly on the DUT using FW derived values parsed from the WP_RO region within the FMAP we can simply print the offset and length. BUG=b:281888335 TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: Iafa0cc4193453cc67952aa4ff1f1554ac1861882 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4520486 Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r--futility/cmd_flash_util.c67
1 files changed, 37 insertions, 30 deletions
diff --git a/futility/cmd_flash_util.c b/futility/cmd_flash_util.c
index 858e260f..9fd7f510 100644
--- a/futility/cmd_flash_util.c
+++ b/futility/cmd_flash_util.c
@@ -15,6 +15,38 @@
#ifdef USE_FLASHROM
+static int get_ro_range(struct updater_config *cfg,
+ uint32_t *start, uint32_t *len)
+{
+ int ret = 0;
+
+ /* Read fmap */
+ const char *const regions[] = {FMAP_RO_FMAP, NULL};
+ if (flashrom_read_image(&cfg->image_current, regions,
+ cfg->verbosity + 1))
+ return -1;
+
+ FmapAreaHeader *wp_ro = NULL;
+ uint8_t *r = fmap_find_by_name(cfg->image_current.data,
+ cfg->image_current.size,
+ NULL, FMAP_RO, &wp_ro);
+ if (!r || !wp_ro) {
+ ERROR("Could not find WP_RO in the FMAP\n");
+ ret = -1;
+ goto err;
+ }
+
+ *start = wp_ro->area_offset;
+ *len = wp_ro->area_size;
+
+err:
+ free(cfg->image_current.data);
+ cfg->image_current.data = NULL;
+ cfg->image_current.size = 0;
+
+ return ret;
+}
+
static int print_flash_size(struct updater_config *cfg)
{
uint32_t flash_size;
@@ -51,39 +83,14 @@ static int print_flash_info(struct updater_config *cfg)
const uint64_t vidpid = (uint64_t) vid << 32 | pid;
printf("Flash vid-pid: 0x%" PRIx64 "\n", vidpid);
printf("Flash size: %#010x\n", flash_size);
- return 0;
-}
-static int get_ro_range(struct updater_config *cfg,
- uint32_t *start, uint32_t *len)
-{
- int ret = 0;
-
- /* Read fmap */
- const char *const regions[] = {FMAP_RO_FMAP, NULL};
- if (flashrom_read_image(&cfg->image_current, regions,
- cfg->verbosity + 1))
+ /* Get WP_RO region start and length from image */
+ uint32_t ro_start, ro_len;
+ if (get_ro_range(cfg, &ro_start, &ro_len))
return -1;
+ printf("Expected WP SR configuration by FW image: (start = %#010x, length = %#010x)\n", ro_start, ro_len);
- FmapAreaHeader *wp_ro = NULL;
- uint8_t *r = fmap_find_by_name(cfg->image_current.data,
- cfg->image_current.size,
- NULL, FMAP_RO, &wp_ro);
- if (!r || !wp_ro) {
- ERROR("Could not find WP_RO in the FMAP\n");
- ret = -1;
- goto err;
- }
-
- *start = wp_ro->area_offset;
- *len = wp_ro->area_size;
-
-err:
- free(cfg->image_current.data);
- cfg->image_current.data = NULL;
- cfg->image_current.size = 0;
-
- return ret;
+ return 0;
}
static int print_wp_status(struct updater_config *cfg, bool ignore_hw)