summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2018-01-03 13:42:40 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-01-09 14:14:17 -0800
commit79c1c6194bc45728a5043443d80506fa1d35c83b (patch)
tree8584ed93f483ff43171395cbc1e3acab1bc2b6d9
parent7d92bd8a6ba2640cc6588607af9886c9ecef4127 (diff)
downloadvboot-79c1c6194bc45728a5043443d80506fa1d35c83b.tar.gz
firmware: Include vb1 shared data in vb2 struct
Currently, firmware verification uses entirely vb2 structs, including vb2_shared_data. This goes through an ugly translation to the old vb1 VbSharedData to pass it to depthcharge. The vboot kernel verification maintains an equally ugly translation back to the vb2 struct internally. Eventually, we want to get rid of all that and use vb2 all the way down to what crossystem picks up from the OS. But before we can do that, we need to finish translating kernel verification code to use the new vb2 structs. This is a step on that path, using vb2_shared_data equivalents where present and hiding the old vb1 shared data struct as a member of vb2_shared_data so at least the vboot functions don't need to pass around cparams to get at it. This will be followed by more CLs which convert more vboot internals to use vb2 structs directly, and eventually coreboot/depthcharge CLs which pass the vb2 structs from firmware verification directly to kernel verification. No change in functionality. BUG=chromium:611535 BRANCH=none TEST=make -j runtests; build bob firmware and boot it Change-Id: I5df8ce81ba3c3ac3f2cb4229db5461757cd89d8d Reviewed-on: https://chromium-review.googlesource.com/852856 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
-rw-r--r--firmware/2lib/include/2struct.h6
-rw-r--r--firmware/lib/ec_sync_all.c6
-rw-r--r--firmware/lib/include/ec_sync.h3
-rw-r--r--firmware/lib/vboot_api_kernel.c58
-rw-r--r--firmware/lib/vboot_display.c3
-rw-r--r--firmware/lib/vboot_kernel.c3
-rw-r--r--firmware/lib/vboot_ui.c11
-rw-r--r--firmware/lib/vboot_ui_menu.c7
-rw-r--r--tests/ec_sync_tests.c4
-rw-r--r--tests/vboot_api_devmode_tests.c4
-rw-r--r--tests/vboot_api_kernel2_tests.c4
-rw-r--r--tests/vboot_api_kernel4_tests.c9
-rw-r--r--tests/vboot_api_kernel5_tests.c9
-rw-r--r--tests/vboot_detach_menu_tests.c4
-rw-r--r--tests/vboot_display_tests.c5
-rw-r--r--tests/vboot_kernel_tests.c4
-rw-r--r--tests/verify_kernel.c3
-rw-r--r--utility/load_kernel_test.c3
18 files changed, 92 insertions, 54 deletions
diff --git a/firmware/2lib/include/2struct.h b/firmware/2lib/include/2struct.h
index 9ae1f540..589e7c9b 100644
--- a/firmware/2lib/include/2struct.h
+++ b/firmware/2lib/include/2struct.h
@@ -195,6 +195,12 @@ struct vb2_shared_data {
*/
/*
+ * Vboot1 shared data header. This data should eventually get folded
+ * directly into the kernel portion of this struct.
+ */
+ struct VbSharedDataHeader *vbsd;
+
+ /*
* Offset and size of packed kernel key in work buffer. Size is 0 if
* subkey is not stored in the work buffer. Note that kernel key may
* be inside the firmware preamble.
diff --git a/firmware/lib/ec_sync_all.c b/firmware/lib/ec_sync_all.c
index 9d236290..68e0a9af 100644
--- a/firmware/lib/ec_sync_all.c
+++ b/firmware/lib/ec_sync_all.c
@@ -17,10 +17,10 @@
#include "vboot_display.h"
#include "vboot_kernel.h"
-VbError_t ec_sync_all(struct vb2_context *ctx, struct VbCommonParams *cparams)
+VbError_t ec_sync_all(struct vb2_context *ctx)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
VbAuxFwUpdateSeverity_t fw_update;
VbError_t rv;
diff --git a/firmware/lib/include/ec_sync.h b/firmware/lib/include/ec_sync.h
index f95b500f..573c94cb 100644
--- a/firmware/lib/include/ec_sync.h
+++ b/firmware/lib/include/ec_sync.h
@@ -80,9 +80,8 @@ VbError_t ec_sync_phase3(struct vb2_context *ctx);
* This is a high-level function which calls the functions above.
*
* @param ctx Vboot context
- * @param cparams Vboot common params
* @return VBERROR_SUCCESS, or non-zero if error.
*/
-VbError_t ec_sync_all(struct vb2_context *ctx, struct VbCommonParams *cparams);
+VbError_t ec_sync_all(struct vb2_context *ctx);
#endif /* VBOOT_REFERENCE_EC_SYNC_H_ */
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index b07e5334..5bda94f9 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -168,8 +168,8 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
VbError_t VbBootNormal(struct vb2_context *ctx, VbCommonParams *cparams)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
uint32_t max_rollforward = vb2_nv_get(ctx,
VB2_NV_KERNEL_MAX_ROLLFORWARD);
@@ -315,10 +315,19 @@ static VbError_t vb2_kernel_setup(VbCommonParams *cparams,
sd->recovery_reason = shared->recovery_reason;
/*
+ * Save a pointer to the old vboot1 shared data, since we haven't
+ * finished porting the library to use the new vb2 context and shared
+ * data.
+ *
+ * TODO: replace this with fields directly in vb2 shared data.
+ */
+ sd->vbsd = shared;
+
+ /*
* If we're in recovery mode just to do memory retraining, all we
* need to do is reboot.
*/
- if (shared->recovery_reason == VB2_RECOVERY_TRAIN_AND_REBOOT) {
+ if (sd->recovery_reason == VB2_RECOVERY_TRAIN_AND_REBOOT) {
VB2_DEBUG("Reboot after retraining in recovery.\n");
return VBERROR_REBOOT_REQUIRED;
}
@@ -346,9 +355,8 @@ static VbError_t vb2_kernel_setup(VbCommonParams *cparams,
/* Read kernel version from the TPM. Ignore errors in recovery mode. */
if (RollbackKernelRead(&shared->kernel_version_tpm)) {
VB2_DEBUG("Unable to get kernel versions from TPM\n");
- if (!shared->recovery_reason) {
- VbSetRecoveryRequest(&ctx,
- VB2_RECOVERY_RW_TPM_R_ERROR);
+ if (!(ctx.flags & VB2_CONTEXT_RECOVERY_MODE)) {
+ VbSetRecoveryRequest(&ctx, VB2_RECOVERY_RW_TPM_R_ERROR);
return VBERROR_TPM_READ_KERNEL;
}
}
@@ -360,9 +368,8 @@ static VbError_t vb2_kernel_setup(VbCommonParams *cparams,
memset(&fwmp, 0, sizeof(fwmp));
} else if (RollbackFwmpRead(&fwmp)) {
VB2_DEBUG("Unable to get FWMP from TPM\n");
- if (!shared->recovery_reason) {
- VbSetRecoveryRequest(&ctx,
- VB2_RECOVERY_RW_TPM_R_ERROR);
+ if (!(ctx.flags & VB2_CONTEXT_RECOVERY_MODE)) {
+ VbSetRecoveryRequest(&ctx, VB2_RECOVERY_RW_TPM_R_ERROR);
return VBERROR_TPM_READ_FWMP;
}
}
@@ -370,11 +377,9 @@ static VbError_t vb2_kernel_setup(VbCommonParams *cparams,
return VBERROR_SUCCESS;
}
-static VbError_t vb2_kernel_phase4(VbCommonParams *cparams,
- VbSelectAndLoadKernelParams *kparams)
+static VbError_t vb2_kernel_phase4(VbSelectAndLoadKernelParams *kparams)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
+ struct vb2_shared_data *sd = vb2_get_sd(&ctx);
/* Save disk parameters */
kparams->disk_handle = lkp.disk_handle;
@@ -388,8 +393,8 @@ static VbError_t vb2_kernel_phase4(VbCommonParams *cparams,
sizeof(kparams->partition_guid));
/* Lock the kernel versions if not in recovery mode */
- if (!shared->recovery_reason &&
- RollbackKernelLock(shared->recovery_reason)) {
+ if (!(ctx.flags & VB2_CONTEXT_RECOVERY_MODE) &&
+ RollbackKernelLock(sd->recovery_reason)) {
VB2_DEBUG("Error locking kernel versions.\n");
VbSetRecoveryRequest(&ctx, VB2_RECOVERY_RW_TPM_L_ERROR);
return VBERROR_TPM_LOCK_KERNEL;
@@ -400,8 +405,13 @@ static VbError_t vb2_kernel_phase4(VbCommonParams *cparams,
static void vb2_kernel_cleanup(struct vb2_context *ctx, VbCommonParams *cparams)
{
+ /*
+ * This must directly access cparams for now because we could have had
+ * an error setting up the vboot2 context. In that case
+ * vb2_shared_data is not available.
+ */
VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
+ (VbSharedDataHeader *)cparams->shared_data_blob;
/*
* Clean up vboot context.
@@ -422,9 +432,6 @@ static void vb2_kernel_cleanup(struct vb2_context *ctx, VbCommonParams *cparams)
VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
VbSelectAndLoadKernelParams *kparams)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
-
VbError_t retval = vb2_kernel_setup(cparams, kparams);
if (retval)
goto VbSelectAndLoadKernel_exit;
@@ -433,21 +440,21 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
* Do EC software sync unless we're in recovery mode. This has UI but
* it's just a single non-interactive WAIT screen.
*/
- if (shared->recovery_reason == VB2_RECOVERY_NOT_REQUESTED) {
- retval = ec_sync_all(&ctx, cparams);
+ if (!(ctx.flags & VB2_CONTEXT_RECOVERY_MODE)) {
+ retval = ec_sync_all(&ctx);
if (retval)
goto VbSelectAndLoadKernel_exit;
}
/* Select boot path */
- if (shared->recovery_reason) {
+ if (ctx.flags & VB2_CONTEXT_RECOVERY_MODE) {
/* Recovery boot. This has UI. */
if (kparams->inflags & VB_SALK_INFLAGS_ENABLE_DETACHABLE_UI)
retval = VbBootRecoveryMenu(&ctx, cparams);
else
retval = VbBootRecovery(&ctx, cparams);
VbExEcEnteringMode(0, VB_EC_RECOVERY);
- } else if (shared->flags & VBSD_BOOT_DEV_SWITCH_ON) {
+ } else if (ctx.flags & VB2_CONTEXT_DEVELOPER_MODE) {
/* Developer boot. This has UI. */
if (kparams->inflags & VB_SALK_INFLAGS_ENABLE_DETACHABLE_UI)
retval = VbBootDeveloperMenu(&ctx, cparams);
@@ -463,7 +470,7 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
VbSelectAndLoadKernel_exit:
if (VBERROR_SUCCESS == retval)
- retval = vb2_kernel_phase4(cparams, kparams);
+ retval = vb2_kernel_phase4(kparams);
vb2_kernel_cleanup(&ctx, cparams);
@@ -480,8 +487,6 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
VbPublicKey* kernel_subkey = NULL;
uint8_t *kbuf;
VbKeyBlockHeader *key_block;
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
VbKernelPreambleHeader *preamble;
uint64_t body_offset;
int hash_only = 0;
@@ -494,6 +499,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
goto fail;
struct vb2_shared_data *sd = vb2_get_sd(&ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
if ((boot_image == NULL) || (image_size == 0)) {
retval = VBERROR_INVALID_PARAMETER;
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index 3d12244d..d3e3a6a2 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -276,9 +276,8 @@ const char *RecoveryReasonString(uint8_t code)
VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
char buf[DEBUG_INFO_SIZE] = "";
char sha1sum[VB2_SHA1_DIGEST_SIZE * 2 + 1];
char hwid[256];
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index c5030ef8..d298e68d 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -431,7 +431,8 @@ int vb2_load_partition(struct vb2_context *ctx,
VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params,
VbCommonParams *cparams)
{
- VbSharedDataHeader *shared = cparams->shared_data_blob;
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
VbSharedDataKernelCall *shcall = NULL;
struct vb2_packed_key *recovery_key = NULL;
int found_partitions = 0;
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index 1776e4f6..36c7cdf1 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -94,8 +94,8 @@ uint32_t VbTryUsb(struct vb2_context *ctx, VbCommonParams *cparams)
int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
uint32_t confirm_flags)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
uint32_t key;
uint32_t key_flags;
uint32_t btn;
@@ -162,9 +162,8 @@ static const char dev_disable_msg[] =
VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
uint32_t disable_dev_boot = 0;
uint32_t use_usb = 0;
@@ -399,8 +398,8 @@ VbError_t VbBootDeveloper(struct vb2_context *ctx, VbCommonParams *cparams)
static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
uint32_t retval;
uint32_t key;
int i;
diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c
index aad03a2d..a8247a2c 100644
--- a/firmware/lib/vboot_ui_menu.c
+++ b/firmware/lib/vboot_ui_menu.c
@@ -589,9 +589,8 @@ void vb2_update_selection(uint32_t key) {
*/
VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
uint32_t use_usb = 0;
uint32_t use_legacy = 0;
@@ -897,8 +896,8 @@ VbError_t VbBootDeveloperMenu(struct vb2_context *ctx, VbCommonParams *cparams)
*/
static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
{
- VbSharedDataHeader *shared =
- (VbSharedDataHeader *)cparams->shared_data_blob;
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ VbSharedDataHeader *shared = sd->vbsd;
uint32_t retval;
uint32_t key;
uint32_t key_flags;
diff --git a/tests/ec_sync_tests.c b/tests/ec_sync_tests.c
index 8a2ecd82..332290ae 100644
--- a/tests/ec_sync_tests.c
+++ b/tests/ec_sync_tests.c
@@ -83,7 +83,9 @@ static void ResetMocks(void)
ctx.flags = VB2_CONTEXT_EC_SYNC_SUPPORTED;
vb2_init_context(&ctx);
vb2_nv_init(&ctx);
+
sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
memset(&shared_data, 0, sizeof(shared_data));
VbSharedDataInit(shared, sizeof(shared_data));
@@ -235,7 +237,7 @@ VbError_t VbExUpdateAuxFw()
static void test_ssync(VbError_t retval, int recovery_reason, const char *desc)
{
- TEST_EQ(ec_sync_all(&ctx, &cparams), retval, desc);
+ TEST_EQ(ec_sync_all(&ctx), retval, desc);
TEST_EQ(vb2_nv_get(&ctx, VB2_NV_RECOVERY_REQUEST),
recovery_reason, " recovery reason");
}
diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c
index 0a336d90..330a89ac 100644
--- a/tests/vboot_api_devmode_tests.c
+++ b/tests/vboot_api_devmode_tests.c
@@ -118,8 +118,6 @@ extern int audio_open_count;
static void ResetMocks(void)
{
memset(&cparams, 0, sizeof(cparams));
- cparams.shared_data_size = sizeof(shared_data);
- cparams.shared_data_blob = shared_data;
cparams.gbb_data = &gbb;
cparams.gbb = &gbb;
@@ -128,7 +126,9 @@ static void ResetMocks(void)
ctx.workbuf_size = sizeof(workbuf);
vb2_init_context(&ctx);
vb2_nv_init(&ctx);
+
sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
memset(&shared_data, 0, sizeof(shared_data));
VbSharedDataInit(shared, sizeof(shared_data));
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index 64fca37f..04e64667 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -59,8 +59,6 @@ extern struct RollbackSpaceFwmp *VbApiKernelGetFwmp(void);
static void ResetMocks(void)
{
memset(&cparams, 0, sizeof(cparams));
- cparams.shared_data_size = sizeof(shared_data);
- cparams.shared_data_blob = shared_data;
cparams.gbb_data = &gbb;
cparams.gbb = &gbb;
@@ -81,7 +79,9 @@ static void ResetMocks(void)
ctx.workbuf_size = sizeof(workbuf);
vb2_init_context(&ctx);
vb2_nv_init(&ctx);
+
sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
shutdown_request_calls_left = -1;
audio_looping_calls_left = 30;
diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c
index e239192c..07bbfcec 100644
--- a/tests/vboot_api_kernel4_tests.c
+++ b/tests/vboot_api_kernel4_tests.c
@@ -11,6 +11,7 @@
#include "2sysincludes.h"
#include "2api.h"
+#include "2misc.h"
#include "2nvstorage.h"
#include "ec_sync.h"
#include "gbb_header.h"
@@ -24,7 +25,9 @@
#include "vboot_struct.h"
/* Mock data */
+static uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE];
static struct vb2_context ctx;
+static struct vb2_shared_data *sd;
static VbCommonParams cparams;
static VbSelectAndLoadKernelParams kparams;
static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE];
@@ -54,9 +57,15 @@ static void ResetMocks(void)
gbb.flags = 0;
memset(&ctx, 0, sizeof(ctx));
+ ctx.workbuf = workbuf;
+ ctx.workbuf_size = sizeof(workbuf);
+ vb2_init_context(&ctx);
vb2_nv_init(&ctx);
vb2_nv_set(&ctx, VB2_NV_KERNEL_MAX_ROLLFORWARD, 0xffffffff);
+ sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
+
memset(&shared_data, 0, sizeof(shared_data));
VbSharedDataInit(shared, sizeof(shared_data));
diff --git a/tests/vboot_api_kernel5_tests.c b/tests/vboot_api_kernel5_tests.c
index 2d7c2e76..fc54eb7a 100644
--- a/tests/vboot_api_kernel5_tests.c
+++ b/tests/vboot_api_kernel5_tests.c
@@ -13,6 +13,7 @@
#include "2sysincludes.h"
#include "2api.h"
#include "2common.h"
+#include "2misc.h"
#include "2nvstorage.h"
#include "2rsa.h"
#include "gbb_header.h"
@@ -26,7 +27,9 @@
#include "vboot_struct.h"
/* Mock data */
+static uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE];
static struct vb2_context ctx;
+static struct vb2_shared_data *sd;
static VbCommonParams cparams;
static VbSelectAndLoadKernelParams kparams;
static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE];
@@ -63,8 +66,14 @@ static void ResetMocks(void)
gbb.flags = 0;
memset(&ctx, 0, sizeof(ctx));
+ ctx.workbuf = workbuf;
+ ctx.workbuf_size = sizeof(workbuf);
+ vb2_init_context(&ctx);
vb2_nv_init(&ctx);
+ sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
+
memset(&shared_data, 0, sizeof(shared_data));
VbSharedDataInit(shared, sizeof(shared_data));
diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c
index 3857c68d..0e3cc3b0 100644
--- a/tests/vboot_detach_menu_tests.c
+++ b/tests/vboot_detach_menu_tests.c
@@ -61,8 +61,6 @@ extern struct RollbackSpaceFwmp *VbApiKernelGetFwmp(void);
static void ResetMocks(void)
{
memset(&cparams, 0, sizeof(cparams));
- cparams.shared_data_size = sizeof(shared_data);
- cparams.shared_data_blob = shared_data;
cparams.gbb_data = &gbb;
cparams.gbb = &gbb;
@@ -83,7 +81,9 @@ static void ResetMocks(void)
ctx.workbuf_size = sizeof(workbuf);
vb2_init_context(&ctx);
vb2_nv_init(&ctx);
+
sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
shutdown_request_calls_left = -1;
audio_looping_calls_left = 30;
diff --git a/tests/vboot_display_tests.c b/tests/vboot_display_tests.c
index e5e0d00f..7ddc28e9 100644
--- a/tests/vboot_display_tests.c
+++ b/tests/vboot_display_tests.c
@@ -53,8 +53,6 @@ static void ResetMocks(void)
mock_localization_count = 3;
memset(&cparams, 0, sizeof(cparams));
- cparams.shared_data_size = sizeof(shared_data);
- cparams.shared_data_blob = shared_data;
cparams.gbb_data = gbb;
cparams.gbb_size = sizeof(gbb_data);
@@ -78,6 +76,9 @@ static void ResetMocks(void)
vb2_init_context(&ctx);
vb2_nv_init(&ctx);
+ struct vb2_shared_data *sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
+
memset(&shared_data, 0, sizeof(shared_data));
VbSharedDataInit(shared, sizeof(shared_data));
diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c
index d581b373..a5919780 100644
--- a/tests/vboot_kernel_tests.c
+++ b/tests/vboot_kernel_tests.c
@@ -149,7 +149,6 @@ static void ResetMocks(void)
cparams.gbb = gbb;
cparams.gbb_data = gbb;
cparams.gbb_size = sizeof(gbb_data);
- cparams.shared_data_blob = shared;
memset(&lkp, 0, sizeof(lkp));
lkp.bytes_per_lba = 512;
@@ -184,6 +183,9 @@ static void ResetMocks(void)
ctx.workbuf_size = sizeof(workbuf);
vb2_nv_init(&ctx);
+ struct vb2_shared_data *sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
+
// TODO: more workbuf fields - flags, secdata, secdatak
}
diff --git a/tests/verify_kernel.c b/tests/verify_kernel.c
index 58c01ad9..01c4deee 100644
--- a/tests/verify_kernel.c
+++ b/tests/verify_kernel.c
@@ -132,6 +132,9 @@ int main(int argc, char *argv[])
return 1;
}
+ struct vb2_shared_data *sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
+
/*
* LoadKernel() cares only about VBNV_DEV_BOOT_SIGNED_ONLY, and only in
* dev mode. So just use defaults for nv storage.
diff --git a/utility/load_kernel_test.c b/utility/load_kernel_test.c
index 517a13ff..481e78ce 100644
--- a/utility/load_kernel_test.c
+++ b/utility/load_kernel_test.c
@@ -247,6 +247,9 @@ int main(int argc, char* argv[]) {
return 1;
}
+ struct vb2_shared_data *sd = vb2_get_sd(&ctx);
+ sd->vbsd = shared;
+
/* Call LoadKernel() */
rv = LoadKernel(&ctx, &lkp, &cparams);
printf("LoadKernel() returned %d\n", rv);