[coreboot-gerrit] New patch to review for coreboot: vboot2: consolidate vboot2 buffer initialization

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Mon Jun 29 22:25:50 CEST 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10701

-gerrit

commit 97525387a983de83ad1454d6ca50227971fee793
Author: Patrick Georgi <pgeorgi at chromium.org>
Date:   Mon Jun 29 22:24:34 2015 +0200

    vboot2: consolidate vboot2 buffer initialization
    
    Instead of calling the init function to clear out vboot2 data structures in
    multiple places, move the function and call close to verstage_main().
    
    Change-Id: If42e18a8e4581f22f7a7aced70ccbe3188bb0cd5
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
---
 src/vendorcode/google/chromeos/vboot2/vboot_loader.c | 18 ------------------
 src/vendorcode/google/chromeos/vboot2/verstage.c     | 20 +++++++++++++++++++-
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/vendorcode/google/chromeos/vboot2/vboot_loader.c b/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
index d6e760a..3c0d67e 100644
--- a/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
+++ b/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
@@ -63,22 +63,6 @@ static int verstage_should_load(void)
 	return 0;
 }
 
-static void init_vb2_working_data(void)
-{
-	struct vb2_working_data *wd;
-	size_t work_size;
-
-	work_size = vb2_working_data_size();
-	wd = vboot_get_working_data();
-	memset(wd, 0, work_size);
-	/*
-	 * vboot prefers 16-byte alignment. This takes away 16 bytes
-	 * from the VBOOT2_WORK region, but the vboot devs said that's okay.
-	 */
-	wd->buffer_offset = ALIGN_UP(sizeof(*wd), 16);
-	wd->buffer_size = work_size - wd->buffer_offset;
-}
-
 static int vboot_active(struct asset *asset)
 {
 	struct vb2_working_data *wd;
@@ -87,10 +71,8 @@ static int vboot_active(struct asset *asset)
 	run_verification = verification_should_run();
 
 	if (run_verification) {
-		init_vb2_working_data();
 		verstage_main();
 	} else if (verstage_should_load()) {
-		init_vb2_working_data();
 		struct prog verstage =
 			PROG_INIT(ASSET_VERSTAGE,
 				CONFIG_CBFS_PREFIX "/verstage");
diff --git a/src/vendorcode/google/chromeos/vboot2/verstage.c b/src/vendorcode/google/chromeos/vboot2/verstage.c
index bc7846a..783d1b6 100644
--- a/src/vendorcode/google/chromeos/vboot2/verstage.c
+++ b/src/vendorcode/google/chromeos/vboot2/verstage.c
@@ -209,6 +209,22 @@ static uint32_t extend_pcrs(struct vb2_context *ctx)
 	       tpm_extend_pcr(ctx, 1, HWID_DIGEST_PCR);
 }
 
+static void init_vb2_working_data(void)
+{
+	struct vb2_working_data *wd;
+	size_t work_size;
+
+	work_size = vb2_working_data_size();
+	wd = vboot_get_working_data();
+	memset(wd, 0, work_size);
+	/*
+	 * vboot prefers 16-byte alignment. This takes away 16 bytes
+	 * from the VBOOT2_WORK region, but the vboot devs said that's okay.
+	 */
+	wd->buffer_offset = ALIGN_UP(sizeof(*wd), 16);
+	wd->buffer_size = work_size - wd->buffer_offset;
+}
+
 /**
  * Verify and select the firmware in the RW image
  *
@@ -219,8 +235,10 @@ void verstage_main(void)
 {
 	struct vb2_context ctx;
 	struct region_device fw_main;
-	struct vb2_working_data *wd = vboot_get_working_data();
+	struct vb2_working_data *wd;
 	int rv;
+	init_vb2_working_data();
+	wd = vboot_get_working_data();
 	timestamp_add_now(TS_START_VBOOT);
 
 	/* Set up context and work buffer */



More information about the coreboot-gerrit mailing list