static void vboot_wrapper(void *arg) { VbError_t res; struct vboot_context *context; context = arg; gcontext = context; VbExDebug("Calling VbInit()\n"); res = VbInit(context->cparams, &context->handoff->init_params); VbExDebug("VbInit() returned 0x%08x\n", res); if (res != VBERROR_SUCCESS) { if(res == VBERROR_TPM_REBOOT_REQUIRED) { VbExDebug("TPM Reboot Required. Proceeding reboot.\n"); gcontext->reset(); } return; } VbExDebug("Calling VbSelectFirmware()\n"); res = VbSelectFirmware(context->cparams, context->fparams); VbExDebug("VbSelectFirmware() returned 0x%08x\n", res); if (res != VBERROR_SUCCESS) return; }
static void VbRegionReadTest(void) { /* Should read GBB */ ResetMocks(); TEST_TRUE(1, "Normal call"); TEST_EQ(VbSelectFirmware(&cparams, &fparams), VBERROR_SUCCESS, " Success"); TEST_EQ(mock_seen_region, 1 << VB_REGION_GBB, " GBB region"); TEST_PTR_EQ(cparams.gbb, NULL, " GBB free"); ResetMocks(); TEST_EQ(VbSelectAndLoadKernel(&cparams, &kparams), VBERROR_NO_DISK_FOUND, "Kernel"); TEST_PTR_EQ(cparams.gbb, NULL, " GBB free"); TEST_PTR_EQ(cparams.bmp, NULL, " BMP free"); ResetMocks(); shared->flags |= VBSD_BOOT_DEV_SWITCH_ON; TEST_EQ(VbSelectAndLoadKernel(&cparams, &kparams), VBERROR_NO_DISK_FOUND, "Kernel"); }
static void vboot_wrapper(void *arg) { int i; VbError_t res; const struct components *components; struct vboot_context *context; context = arg; gcontext = context; VbExDebug("Calling VbInit()\n"); res = VbInit(context->cparams, &context->handoff->init_params); VbExDebug("VbInit() returned 0x%08x\n", res); if (res != VBERROR_SUCCESS) return; VbExDebug("Calling VbSelectFirmware()\n"); res = VbSelectFirmware(context->cparams, context->fparams); VbExDebug("VbSelectFirmware() returned 0x%08x\n", res); if (res != VBERROR_SUCCESS) return; /* Fix up the handoff structure. */ context->handoff->selected_firmware = context->fparams->selected_firmware; /* Parse out the components for downstream consumption. */ if (context->handoff->selected_firmware == VB_SELECT_FIRMWARE_A) components = (void *)context->fw_a; else if (context->handoff->selected_firmware == VB_SELECT_FIRMWARE_B) components = (void *)context->fw_b; else return; for (i = 0; i < MAX_PARSED_FW_COMPONENTS; i++) { parse_component(components, i, &context->handoff->components[i]); } }
static uint32_t twostop_make_selection(struct twostop_fmap *fmap, firmware_storage_t *file, VbCommonParams *cparams, void **fw_blob_ptr, uint32_t *fw_size_ptr) { uint32_t selection = TWOSTOP_SELECT_ERROR; #if !defined(CONFIG_SANDBOX) VbError_t err; #endif uint32_t vlength; VbSelectFirmwareParams fparams; hasher_state_t s; memset(&fparams, '\0', sizeof(fparams)); vlength = fmap->readwrite_a.vblock.length; assert(vlength == fmap->readwrite_b.vblock.length); fparams.verification_size_A = fparams.verification_size_B = vlength; #ifndef CONFIG_HARDWARE_MAPPED_SPI fparams.verification_block_A = cros_memalign_cache(vlength); if (!fparams.verification_block_A) { VBDEBUG("failed to allocate vblock A\n"); goto out; } fparams.verification_block_B = cros_memalign_cache(vlength); if (!fparams.verification_block_B) { VBDEBUG("failed to allocate vblock B\n"); goto out; } #endif if (file->read(file, fmap->readwrite_a.vblock.offset, vlength, BT_EXTRA fparams.verification_block_A)) { VBDEBUG("fail to read vblock A\n"); goto out; } if (file->read(file, fmap->readwrite_b.vblock.offset, vlength, BT_EXTRA fparams.verification_block_B)) { VBDEBUG("fail to read vblock B\n"); goto out; } s.fw[0].vblock = fparams.verification_block_A; s.fw[1].vblock = fparams.verification_block_B; s.fw[0].offset = fmap->readwrite_a.boot.offset; s.fw[1].offset = fmap->readwrite_b.boot.offset; s.fw[0].size = fmap->readwrite_a.boot.length; s.fw[1].size = fmap->readwrite_b.boot.length; #ifndef CONFIG_HARDWARE_MAPPED_SPI s.fw[0].cache = cros_memalign_cache(s.fw[0].size); if (!s.fw[0].cache) { VBDEBUG("failed to allocate cache A\n"); goto out; } s.fw[1].cache = cros_memalign_cache(s.fw[1].size); if (!s.fw[1].cache) { VBDEBUG("failed to allocate cache B\n"); goto out; } #endif s.file = file; cparams->caller_context = &s; #if defined(CONFIG_SANDBOX) fparams.verification_block_A = NULL; fparams.verification_size_A = 0; fparams.verification_block_B = NULL; fparams.verification_size_B = 0; fparams.selected_firmware = VB_SELECT_FIRMWARE_A; #else if ((err = VbSelectFirmware(cparams, &fparams))) { VBDEBUG("VbSelectFirmware: %d\n", err); /* * If vboot wants EC to reboot to RO, make request now, * because there isn't a clear path to pass this request * through to do_vboot_twostop(). */ if (err == VBERROR_EC_REBOOT_TO_RO_REQUIRED) request_ec_reboot_to_ro(); goto out; } #endif VBDEBUG("selected_firmware: %d\n", fparams.selected_firmware); selection = fparams.selected_firmware; out: FREE_IF_NEEDED(fparams.verification_block_A); FREE_IF_NEEDED(fparams.verification_block_B); if (selection == VB_SELECT_FIRMWARE_A) { *fw_blob_ptr = s.fw[0].cache; *fw_size_ptr = s.fw[0].size; FREE_IF_NEEDED(s.fw[1].cache); } else if (selection == VB_SELECT_FIRMWARE_B) { *fw_blob_ptr = s.fw[1].cache; *fw_size_ptr = s.fw[1].size; FREE_IF_NEEDED(s.fw[0].cache); } return selection; }