vboot: prepare for x86 verstage

In order to support x86 verstage proper the work buffer
needs to live in cache-as-ram. However, after cache-as-ram
is torn down one still needs the verification results to
know which slot was selected. Though the platforms with
a dedicated SRAM can just use the work buffer in SRAM, the
x86 cache-as-ram platforms need a place to stash the
results. For that situation cbmem is employed. This works
because when cbmem is initialized cache-as-ram is still
enabled. The VBOOT_DYNAMIC_WORK_BUFFER case assumes
verified boot doesn't start until after cbmem is up. That
doesn't change, but it's a goal to get rid of that option
entirely once all other x86 platforms are moved over to
pre-romstage vboot.

BUG=chrome-os-partner:44827
BRANCH=None
TEST=Built and booted glados with pre-romstage verification
     as well as VBOOT_DYNAMIC_WORK_BUFFER case.

Change-Id: I7eacd0edb2b6ca52b59b74075d17c00b50676d4c
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/11821
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
diff --git a/src/vendorcode/google/chromeos/vboot2/vboot_loader.c b/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
index bb7bc4c..d2e7758 100644
--- a/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
+++ b/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
@@ -98,10 +98,18 @@
 			return 0;
 	}
 
-	/* Fill in vboot handoff structure before moving to ramstage so all
-	 * downstream users have access to vboot results. */
-	if (ENV_ROMSTAGE)
+	/*
+	 * Fill in vboot cbmem objects before moving to ramstage so all
+	 * downstream users have access to vboot results. This path only
+	 * applies to platforms employing VBOOT_DYNAMIC_WORK_BUFFER because
+	 * cbmem comes online prior to vboot verification taking place. For
+	 * other platforms the vboot cbmem objects are initialized when
+	 * cbmem comes online.
+	 */
+	if (ENV_ROMSTAGE && IS_ENABLED(CONFIG_VBOOT_DYNAMIC_WORK_BUFFER)) {
+		vb2_store_selected_region();
 		vboot_fill_handoff();
+	}
 
 	return vboot_is_slot_selected();
 }