mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-28 20:23:39 +00:00
firmware: replace VBDEBUG(()) macro with VB2_DEBUG()
The original VBDEBUG macro used doubly-nested parens to work with MSVC, which didn't support varargs in macros. We now only use more modern compilers, so replace it with the VB2_DEBUG macro and get rid of the ugly and fragile double parens. BUG=chromium:611535 BRANCH=none TEST=make runtests; build_packages --board=reef chromeos-firmware Change-Id: Ifc0cb0733b14daaa1fde095fab7da4215a538c77 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425133 Reviewed-by: Shelley Chen <shchen@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
df4eb2bb7b
commit
21015898b3
@@ -3,8 +3,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysincludes.h"
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
|
|
||||||
|
#include "sysincludes.h"
|
||||||
#include "cgptlib.h"
|
#include "cgptlib.h"
|
||||||
#include "cgptlib_internal.h"
|
#include "cgptlib_internal.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
@@ -22,7 +24,7 @@ int GptInit(GptData *gpt)
|
|||||||
|
|
||||||
retval = GptSanityCheck(gpt);
|
retval = GptSanityCheck(gpt);
|
||||||
if (GPT_SUCCESS != retval) {
|
if (GPT_SUCCESS != retval) {
|
||||||
VBDEBUG(("GptInit() failed sanity check\n"));
|
VB2_DEBUG("GptInit() failed sanity check\n");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,18 +52,18 @@ int GptNextKernelEntry(GptData *gpt, uint64_t *start_sector, uint64_t *size)
|
|||||||
e = entries + i;
|
e = entries + i;
|
||||||
if (!IsKernelEntry(e))
|
if (!IsKernelEntry(e))
|
||||||
continue;
|
continue;
|
||||||
VBDEBUG(("GptNextKernelEntry looking at same prio "
|
VB2_DEBUG("GptNextKernelEntry looking at same prio "
|
||||||
"partition %d\n", i+1));
|
"partition %d\n", i+1);
|
||||||
VBDEBUG(("GptNextKernelEntry s%d t%d p%d\n",
|
VB2_DEBUG("GptNextKernelEntry s%d t%d p%d\n",
|
||||||
GetEntrySuccessful(e), GetEntryTries(e),
|
GetEntrySuccessful(e), GetEntryTries(e),
|
||||||
GetEntryPriority(e)));
|
GetEntryPriority(e));
|
||||||
if (!(GetEntrySuccessful(e) || GetEntryTries(e)))
|
if (!(GetEntrySuccessful(e) || GetEntryTries(e)))
|
||||||
continue;
|
continue;
|
||||||
if (GetEntryPriority(e) == gpt->current_priority) {
|
if (GetEntryPriority(e) == gpt->current_priority) {
|
||||||
gpt->current_kernel = i;
|
gpt->current_kernel = i;
|
||||||
*start_sector = e->starting_lba;
|
*start_sector = e->starting_lba;
|
||||||
*size = e->ending_lba - e->starting_lba + 1;
|
*size = e->ending_lba - e->starting_lba + 1;
|
||||||
VBDEBUG(("GptNextKernelEntry likes it\n"));
|
VB2_DEBUG("GptNextKernelEntry likes it\n");
|
||||||
return GPT_SUCCESS;
|
return GPT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,11 +77,11 @@ int GptNextKernelEntry(GptData *gpt, uint64_t *start_sector, uint64_t *size)
|
|||||||
int current_prio = GetEntryPriority(e);
|
int current_prio = GetEntryPriority(e);
|
||||||
if (!IsKernelEntry(e))
|
if (!IsKernelEntry(e))
|
||||||
continue;
|
continue;
|
||||||
VBDEBUG(("GptNextKernelEntry looking at new prio "
|
VB2_DEBUG("GptNextKernelEntry looking at new prio "
|
||||||
"partition %d\n", i+1));
|
"partition %d\n", i+1);
|
||||||
VBDEBUG(("GptNextKernelEntry s%d t%d p%d\n",
|
VB2_DEBUG("GptNextKernelEntry s%d t%d p%d\n",
|
||||||
GetEntrySuccessful(e), GetEntryTries(e),
|
GetEntrySuccessful(e), GetEntryTries(e),
|
||||||
GetEntryPriority(e)));
|
GetEntryPriority(e));
|
||||||
if (!(GetEntrySuccessful(e) || GetEntryTries(e)))
|
if (!(GetEntrySuccessful(e) || GetEntryTries(e)))
|
||||||
continue;
|
continue;
|
||||||
if (current_prio >= gpt->current_priority) {
|
if (current_prio >= gpt->current_priority) {
|
||||||
@@ -101,11 +103,11 @@ int GptNextKernelEntry(GptData *gpt, uint64_t *start_sector, uint64_t *size)
|
|||||||
gpt->current_priority = new_prio;
|
gpt->current_priority = new_prio;
|
||||||
|
|
||||||
if (CGPT_KERNEL_ENTRY_NOT_FOUND == new_kernel) {
|
if (CGPT_KERNEL_ENTRY_NOT_FOUND == new_kernel) {
|
||||||
VBDEBUG(("GptNextKernelEntry no more kernels\n"));
|
VB2_DEBUG("GptNextKernelEntry no more kernels\n");
|
||||||
return GPT_ERROR_NO_VALID_KERNEL;
|
return GPT_ERROR_NO_VALID_KERNEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("GptNextKernelEntry likes partition %d\n", new_kernel + 1));
|
VB2_DEBUG("GptNextKernelEntry likes partition %d\n", new_kernel + 1);
|
||||||
e = entries + new_kernel;
|
e = entries + new_kernel;
|
||||||
*start_sector = e->starting_lba;
|
*start_sector = e->starting_lba;
|
||||||
*size = e->ending_lba - e->starting_lba + 1;
|
*size = e->ending_lba - e->starting_lba + 1;
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysincludes.h"
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
|
|
||||||
|
#include "sysincludes.h"
|
||||||
#include "cgptlib.h"
|
#include "cgptlib.h"
|
||||||
#include "cgptlib_internal.h"
|
#include "cgptlib_internal.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
@@ -46,7 +48,7 @@ int AllocAndReadGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
|
|||||||
|
|
||||||
/* Read primary header from the drive, skipping the protective MBR */
|
/* Read primary header from the drive, skipping the protective MBR */
|
||||||
if (0 != VbExDiskRead(disk_handle, 1, 1, gptdata->primary_header)) {
|
if (0 != VbExDiskRead(disk_handle, 1, 1, gptdata->primary_header)) {
|
||||||
VBDEBUG(("Read error in primary GPT header\n"));
|
VB2_DEBUG("Read error in primary GPT header\n");
|
||||||
memset(gptdata->primary_header, 0, gptdata->sector_bytes);
|
memset(gptdata->primary_header, 0, gptdata->sector_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,21 +68,21 @@ int AllocAndReadGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
|
|||||||
primary_header->entries_lba,
|
primary_header->entries_lba,
|
||||||
entries_sectors,
|
entries_sectors,
|
||||||
gptdata->primary_entries)) {
|
gptdata->primary_entries)) {
|
||||||
VBDEBUG(("Read error in primary GPT entries\n"));
|
VB2_DEBUG("Read error in primary GPT entries\n");
|
||||||
primary_valid = 0;
|
primary_valid = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
VBDEBUG(("Primary GPT header is %s\n",
|
VB2_DEBUG("Primary GPT header is %s\n",
|
||||||
memcmp(primary_header->signature,
|
memcmp(primary_header->signature,
|
||||||
GPT_HEADER_SIGNATURE_IGNORED,
|
GPT_HEADER_SIGNATURE_IGNORED,
|
||||||
GPT_HEADER_SIGNATURE_SIZE)
|
GPT_HEADER_SIGNATURE_SIZE)
|
||||||
? "invalid" : "being ignored"));
|
? "invalid" : "being ignored");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read secondary header from the end of the drive */
|
/* Read secondary header from the end of the drive */
|
||||||
if (0 != VbExDiskRead(disk_handle, gptdata->gpt_drive_sectors - 1, 1,
|
if (0 != VbExDiskRead(disk_handle, gptdata->gpt_drive_sectors - 1, 1,
|
||||||
gptdata->secondary_header)) {
|
gptdata->secondary_header)) {
|
||||||
VBDEBUG(("Read error in secondary GPT header\n"));
|
VB2_DEBUG("Read error in secondary GPT header\n");
|
||||||
memset(gptdata->secondary_header, 0, gptdata->sector_bytes);
|
memset(gptdata->secondary_header, 0, gptdata->sector_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,15 +102,15 @@ int AllocAndReadGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
|
|||||||
secondary_header->entries_lba,
|
secondary_header->entries_lba,
|
||||||
entries_sectors,
|
entries_sectors,
|
||||||
gptdata->secondary_entries)) {
|
gptdata->secondary_entries)) {
|
||||||
VBDEBUG(("Read error in secondary GPT entries\n"));
|
VB2_DEBUG("Read error in secondary GPT entries\n");
|
||||||
secondary_valid = 0;
|
secondary_valid = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
VBDEBUG(("Secondary GPT header is %s\n",
|
VB2_DEBUG("Secondary GPT header is %s\n",
|
||||||
memcmp(secondary_header->signature,
|
memcmp(secondary_header->signature,
|
||||||
GPT_HEADER_SIGNATURE_IGNORED,
|
GPT_HEADER_SIGNATURE_IGNORED,
|
||||||
GPT_HEADER_SIGNATURE_SIZE)
|
GPT_HEADER_SIGNATURE_SIZE)
|
||||||
? "invalid" : "being ignored"));
|
? "invalid" : "being ignored");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return 0 if least one GPT header was valid */
|
/* Return 0 if least one GPT header was valid */
|
||||||
@@ -147,17 +149,17 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
|
|||||||
entries_lba = h->entries_lba;
|
entries_lba = h->entries_lba;
|
||||||
|
|
||||||
if (gptdata->ignored & MASK_PRIMARY) {
|
if (gptdata->ignored & MASK_PRIMARY) {
|
||||||
VBDEBUG(("Not updating primary GPT: "
|
VB2_DEBUG("Not updating primary GPT: "
|
||||||
"marked to be ignored.\n"));
|
"marked to be ignored.\n");
|
||||||
skip_primary = 1;
|
skip_primary = 1;
|
||||||
} else if (gptdata->modified & GPT_MODIFIED_HEADER1) {
|
} else if (gptdata->modified & GPT_MODIFIED_HEADER1) {
|
||||||
if (!memcmp(h->signature, GPT_HEADER_SIGNATURE2,
|
if (!memcmp(h->signature, GPT_HEADER_SIGNATURE2,
|
||||||
GPT_HEADER_SIGNATURE_SIZE)) {
|
GPT_HEADER_SIGNATURE_SIZE)) {
|
||||||
VBDEBUG(("Not updating primary GPT: "
|
VB2_DEBUG("Not updating primary GPT: "
|
||||||
"legacy mode is enabled.\n"));
|
"legacy mode is enabled.\n");
|
||||||
skip_primary = 1;
|
skip_primary = 1;
|
||||||
} else {
|
} else {
|
||||||
VBDEBUG(("Updating GPT header 1\n"));
|
VB2_DEBUG("Updating GPT header 1\n");
|
||||||
if (0 != VbExDiskWrite(disk_handle, 1, 1,
|
if (0 != VbExDiskWrite(disk_handle, 1, 1,
|
||||||
gptdata->primary_header))
|
gptdata->primary_header))
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -167,7 +169,7 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
|
|||||||
|
|
||||||
if (gptdata->primary_entries && !skip_primary) {
|
if (gptdata->primary_entries && !skip_primary) {
|
||||||
if (gptdata->modified & GPT_MODIFIED_ENTRIES1) {
|
if (gptdata->modified & GPT_MODIFIED_ENTRIES1) {
|
||||||
VBDEBUG(("Updating GPT entries 1\n"));
|
VB2_DEBUG("Updating GPT entries 1\n");
|
||||||
if (0 != VbExDiskWrite(disk_handle, entries_lba,
|
if (0 != VbExDiskWrite(disk_handle, entries_lba,
|
||||||
entries_sectors,
|
entries_sectors,
|
||||||
gptdata->primary_entries))
|
gptdata->primary_entries))
|
||||||
@@ -181,7 +183,7 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
|
|||||||
GptHeader *h = (GptHeader *)(gptdata->secondary_header);
|
GptHeader *h = (GptHeader *)(gptdata->secondary_header);
|
||||||
entries_lba = h->entries_lba;
|
entries_lba = h->entries_lba;
|
||||||
if (gptdata->modified & GPT_MODIFIED_HEADER2) {
|
if (gptdata->modified & GPT_MODIFIED_HEADER2) {
|
||||||
VBDEBUG(("Updating GPT header 2\n"));
|
VB2_DEBUG("Updating GPT header 2\n");
|
||||||
if (0 != VbExDiskWrite(disk_handle,
|
if (0 != VbExDiskWrite(disk_handle,
|
||||||
gptdata->gpt_drive_sectors - 1, 1,
|
gptdata->gpt_drive_sectors - 1, 1,
|
||||||
gptdata->secondary_header))
|
gptdata->secondary_header))
|
||||||
@@ -191,7 +193,7 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
|
|||||||
|
|
||||||
if (gptdata->secondary_entries && !(gptdata->ignored & MASK_SECONDARY)){
|
if (gptdata->secondary_entries && !(gptdata->ignored & MASK_SECONDARY)){
|
||||||
if (gptdata->modified & GPT_MODIFIED_ENTRIES2) {
|
if (gptdata->modified & GPT_MODIFIED_ENTRIES2) {
|
||||||
VBDEBUG(("Updating GPT entries 2\n"));
|
VB2_DEBUG("Updating GPT entries 2\n");
|
||||||
if (0 != VbExDiskWrite(disk_handle,
|
if (0 != VbExDiskWrite(disk_handle,
|
||||||
entries_lba, entries_sectors,
|
entries_lba, entries_sectors,
|
||||||
gptdata->secondary_entries))
|
gptdata->secondary_entries))
|
||||||
|
|||||||
@@ -14,13 +14,6 @@
|
|||||||
#include "sysincludes.h"
|
#include "sysincludes.h"
|
||||||
#include "vboot_api.h"
|
#include "vboot_api.h"
|
||||||
|
|
||||||
/* Debug and error output */
|
|
||||||
#ifdef VBOOT_DEBUG
|
|
||||||
#define VBDEBUG(params) VbExDebug params
|
|
||||||
#else
|
|
||||||
#define VBDEBUG(params)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VBOOT_DEBUG
|
#ifdef VBOOT_DEBUG
|
||||||
#define VbAssert(expr) do { if (!(expr)) { \
|
#define VbAssert(expr) do { if (!(expr)) { \
|
||||||
VbExError("assert fail: %s at %s:%d\n", \
|
VbExError("assert fail: %s at %s:%d\n", \
|
||||||
|
|||||||
@@ -6,8 +6,10 @@
|
|||||||
* (Firmware portion)
|
* (Firmware portion)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysincludes.h"
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
|
|
||||||
|
#include "sysincludes.h"
|
||||||
#include "bmpblk_header.h"
|
#include "bmpblk_header.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
#include "gbb_access.h"
|
#include "gbb_access.h"
|
||||||
@@ -50,8 +52,8 @@ VbError_t VbGbbReadBmpHeader(VbCommonParams *cparams, BmpBlockHeader *hdr_ret)
|
|||||||
(hdr->major_version > BMPBLOCK_MAJOR_VERSION) ||
|
(hdr->major_version > BMPBLOCK_MAJOR_VERSION) ||
|
||||||
((hdr->major_version == BMPBLOCK_MAJOR_VERSION) &&
|
((hdr->major_version == BMPBLOCK_MAJOR_VERSION) &&
|
||||||
(hdr->minor_version > BMPBLOCK_MINOR_VERSION))) {
|
(hdr->minor_version > BMPBLOCK_MINOR_VERSION))) {
|
||||||
VBDEBUG(("VbGbbReadBmpHeader(): "
|
VB2_DEBUG("VbGbbReadBmpHeader(): "
|
||||||
"invalid/too new bitmap header\n"));
|
"invalid/too new bitmap header\n");
|
||||||
free(hdr);
|
free(hdr);
|
||||||
return VBERROR_INVALID_BMPFV;
|
return VBERROR_INVALID_BMPFV;
|
||||||
}
|
}
|
||||||
@@ -78,12 +80,12 @@ VbError_t VbRegionReadHWID(VbCommonParams *cparams, char *hwid,
|
|||||||
gbb = cparams->gbb;
|
gbb = cparams->gbb;
|
||||||
|
|
||||||
if (0 == gbb->hwid_size) {
|
if (0 == gbb->hwid_size) {
|
||||||
VBDEBUG(("VbHWID(): invalid hwid size\n"));
|
VB2_DEBUG("VbHWID(): invalid hwid size\n");
|
||||||
return VBERROR_SUCCESS; /* oddly enough! */
|
return VBERROR_SUCCESS; /* oddly enough! */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gbb->hwid_size > max_size) {
|
if (gbb->hwid_size > max_size) {
|
||||||
VBDEBUG(("VbDisplayDebugInfo(): invalid hwid offset/size\n"));
|
VB2_DEBUG("VbDisplayDebugInfo(): invalid hwid offset/size\n");
|
||||||
return VBERROR_INVALID_PARAMETER;
|
return VBERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
ret = VbRegionReadGbb(cparams, gbb->hwid_offset, gbb->hwid_size, hwid);
|
ret = VbRegionReadGbb(cparams, gbb->hwid_offset, gbb->hwid_size, hwid);
|
||||||
|
|||||||
@@ -6,9 +6,11 @@
|
|||||||
* stored in the TPM NVRAM.
|
* stored in the TPM NVRAM.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysincludes.h"
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
#include "2crc8.h"
|
#include "2crc8.h"
|
||||||
|
|
||||||
|
#include "sysincludes.h"
|
||||||
#include "rollback_index.h"
|
#include "rollback_index.h"
|
||||||
#include "tlcl.h"
|
#include "tlcl.h"
|
||||||
#include "tss_constants.h"
|
#include "tss_constants.h"
|
||||||
@@ -41,8 +43,8 @@ uint32_t WriteSpaceKernel(RollbackSpaceKernel *rsk);
|
|||||||
#define RETURN_ON_FAILURE(tpm_command) do { \
|
#define RETURN_ON_FAILURE(tpm_command) do { \
|
||||||
uint32_t result_; \
|
uint32_t result_; \
|
||||||
if ((result_ = (tpm_command)) != TPM_SUCCESS) { \
|
if ((result_ = (tpm_command)) != TPM_SUCCESS) { \
|
||||||
VBDEBUG(("Rollback: %08x returned by " #tpm_command \
|
VB2_DEBUG("Rollback: %08x returned by " #tpm_command \
|
||||||
"\n", (int)result_)); \
|
"\n", (int)result_); \
|
||||||
return result_; \
|
return result_; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -50,7 +52,7 @@ uint32_t WriteSpaceKernel(RollbackSpaceKernel *rsk);
|
|||||||
|
|
||||||
uint32_t TPMClearAndReenable(void)
|
uint32_t TPMClearAndReenable(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Clear and re-enable\n"));
|
VB2_DEBUG("TPM: Clear and re-enable\n");
|
||||||
RETURN_ON_FAILURE(TlclForceClear());
|
RETURN_ON_FAILURE(TlclForceClear());
|
||||||
RETURN_ON_FAILURE(TlclSetEnable());
|
RETURN_ON_FAILURE(TlclSetEnable());
|
||||||
RETURN_ON_FAILURE(TlclSetDeactivated(0));
|
RETURN_ON_FAILURE(TlclSetDeactivated(0));
|
||||||
@@ -103,10 +105,10 @@ uint32_t ReadSpaceFirmware(RollbackSpaceFirmware *rsf)
|
|||||||
offsetof(RollbackSpaceFirmware, crc8)))
|
offsetof(RollbackSpaceFirmware, crc8)))
|
||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
|
|
||||||
VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
|
VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
|
VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
|
||||||
return TPM_E_CORRUPTED_STATE;
|
return TPM_E_CORRUPTED_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,11 +135,11 @@ uint32_t WriteSpaceFirmware(RollbackSpaceFirmware *rsf)
|
|||||||
if (r == TPM_SUCCESS)
|
if (r == TPM_SUCCESS)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
|
VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
|
||||||
/* Try writing it again. Maybe it was garbled on the way out. */
|
/* Try writing it again. Maybe it was garbled on the way out. */
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
|
VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
|
||||||
return TPM_E_CORRUPTED_STATE;
|
return TPM_E_CORRUPTED_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,11 +147,11 @@ uint32_t SetVirtualDevMode(int val)
|
|||||||
{
|
{
|
||||||
RollbackSpaceFirmware rsf;
|
RollbackSpaceFirmware rsf;
|
||||||
|
|
||||||
VBDEBUG(("TPM: Entering %s()\n", __func__));
|
VB2_DEBUG("TPM: Entering %s()\n", __func__);
|
||||||
if (TPM_SUCCESS != ReadSpaceFirmware(&rsf))
|
if (TPM_SUCCESS != ReadSpaceFirmware(&rsf))
|
||||||
return VBERROR_TPM_FIRMWARE_SETUP;
|
return VBERROR_TPM_FIRMWARE_SETUP;
|
||||||
|
|
||||||
VBDEBUG(("TPM: flags were 0x%02x\n", rsf.flags));
|
VB2_DEBUG("TPM: flags were 0x%02x\n", rsf.flags);
|
||||||
if (val)
|
if (val)
|
||||||
rsf.flags |= FLAG_VIRTUAL_DEV_MODE_ON;
|
rsf.flags |= FLAG_VIRTUAL_DEV_MODE_ON;
|
||||||
else
|
else
|
||||||
@@ -158,12 +160,12 @@ uint32_t SetVirtualDevMode(int val)
|
|||||||
* NOTE: This doesn't update the FLAG_LAST_BOOT_DEVELOPER bit. That
|
* NOTE: This doesn't update the FLAG_LAST_BOOT_DEVELOPER bit. That
|
||||||
* will be done on the next boot.
|
* will be done on the next boot.
|
||||||
*/
|
*/
|
||||||
VBDEBUG(("TPM: flags are now 0x%02x\n", rsf.flags));
|
VB2_DEBUG("TPM: flags are now 0x%02x\n", rsf.flags);
|
||||||
|
|
||||||
if (TPM_SUCCESS != WriteSpaceFirmware(&rsf))
|
if (TPM_SUCCESS != WriteSpaceFirmware(&rsf))
|
||||||
return VBERROR_TPM_SET_BOOT_MODE_STATE;
|
return VBERROR_TPM_SET_BOOT_MODE_STATE;
|
||||||
|
|
||||||
VBDEBUG(("TPM: Leaving %s()\n", __func__));
|
VB2_DEBUG("TPM: Leaving %s()\n", __func__);
|
||||||
return VBERROR_SUCCESS;
|
return VBERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,10 +201,10 @@ uint32_t ReadSpaceKernel(RollbackSpaceKernel *rsk)
|
|||||||
vb2_crc8(rsk, offsetof(RollbackSpaceKernel, crc8)))
|
vb2_crc8(rsk, offsetof(RollbackSpaceKernel, crc8)))
|
||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
|
|
||||||
VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
|
VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
|
VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
|
||||||
return TPM_E_CORRUPTED_STATE;
|
return TPM_E_CORRUPTED_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,11 +231,11 @@ uint32_t WriteSpaceKernel(RollbackSpaceKernel *rsk)
|
|||||||
if (r == TPM_SUCCESS)
|
if (r == TPM_SUCCESS)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
|
VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
|
||||||
/* Try writing it again. Maybe it was garbled on the way out. */
|
/* Try writing it again. Maybe it was garbled on the way out. */
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
|
VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
|
||||||
return TPM_E_CORRUPTED_STATE;
|
return TPM_E_CORRUPTED_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +295,7 @@ uint32_t RollbackKernelRead(uint32_t* version)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
memcpy(version, &rsk.kernel_versions, sizeof(*version));
|
memcpy(version, &rsk.kernel_versions, sizeof(*version));
|
||||||
VBDEBUG(("TPM: RollbackKernelRead %x\n", (int)*version));
|
VB2_DEBUG("TPM: RollbackKernelRead %x\n", (int)*version);
|
||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,8 +305,8 @@ uint32_t RollbackKernelWrite(uint32_t version)
|
|||||||
uint32_t old_version;
|
uint32_t old_version;
|
||||||
RETURN_ON_FAILURE(ReadSpaceKernel(&rsk));
|
RETURN_ON_FAILURE(ReadSpaceKernel(&rsk));
|
||||||
memcpy(&old_version, &rsk.kernel_versions, sizeof(old_version));
|
memcpy(&old_version, &rsk.kernel_versions, sizeof(old_version));
|
||||||
VBDEBUG(("TPM: RollbackKernelWrite %x --> %x\n",
|
VB2_DEBUG("TPM: RollbackKernelWrite %x --> %x\n",
|
||||||
(int)old_version, (int)version));
|
(int)old_version, (int)version);
|
||||||
memcpy(&rsk.kernel_versions, &version, sizeof(version));
|
memcpy(&rsk.kernel_versions, &version, sizeof(version));
|
||||||
return WriteSpaceKernel(&rsk);
|
return WriteSpaceKernel(&rsk);
|
||||||
}
|
}
|
||||||
@@ -345,11 +347,11 @@ uint32_t RollbackFwmpRead(struct RollbackSpaceFwmp *fwmp)
|
|||||||
r = TlclRead(FWMP_NV_INDEX, u.buf, sizeof(u.bf));
|
r = TlclRead(FWMP_NV_INDEX, u.buf, sizeof(u.bf));
|
||||||
if (r == TPM_E_BADINDEX) {
|
if (r == TPM_E_BADINDEX) {
|
||||||
/* Missing space is not an error; use defaults */
|
/* Missing space is not an error; use defaults */
|
||||||
VBDEBUG(("TPM: %s() - no FWMP space\n", __func__));
|
VB2_DEBUG("TPM: %s() - no FWMP space\n", __func__);
|
||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
} else if (r != TPM_SUCCESS) {
|
} else if (r != TPM_SUCCESS) {
|
||||||
VBDEBUG(("TPM: %s() - read returned 0x%x\n",
|
VB2_DEBUG("TPM: %s() - read returned 0x%x\n",
|
||||||
__func__, r));
|
__func__, r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,7 +375,7 @@ uint32_t RollbackFwmpRead(struct RollbackSpaceFwmp *fwmp)
|
|||||||
|
|
||||||
/* Verify CRC */
|
/* Verify CRC */
|
||||||
if (u.bf.crc != vb2_crc8(u.buf + 2, u.bf.struct_size - 2)) {
|
if (u.bf.crc != vb2_crc8(u.buf + 2, u.bf.struct_size - 2)) {
|
||||||
VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
|
VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,7 +397,7 @@ uint32_t RollbackFwmpRead(struct RollbackSpaceFwmp *fwmp)
|
|||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
|
VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
|
||||||
return TPM_E_CORRUPTED_STATE;
|
return TPM_E_CORRUPTED_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
|
|
||||||
#include "tpm2_marshaling.h"
|
#include "tpm2_marshaling.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
@@ -110,9 +113,9 @@ static void unmarshal_TPM2B_MAX_NV_BUFFER(void **buffer,
|
|||||||
{
|
{
|
||||||
nv_buffer->t.size = unmarshal_u16(buffer, size);
|
nv_buffer->t.size = unmarshal_u16(buffer, size);
|
||||||
if (nv_buffer->t.size > *size) {
|
if (nv_buffer->t.size > *size) {
|
||||||
VBDEBUG(("%s:%d - "
|
VB2_DEBUG("%s:%d - "
|
||||||
"size mismatch: expected %d, remaining %d\n",
|
"size mismatch: expected %d, remaining %d\n",
|
||||||
__func__, __LINE__, nv_buffer->t.size, *size));
|
__func__, __LINE__, nv_buffer->t.size, *size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,9 +133,9 @@ static void unmarshal_authorization_section(void **buffer, int *size,
|
|||||||
* just confirm that this is the case and report any discrepancy.
|
* just confirm that this is the case and report any discrepancy.
|
||||||
*/
|
*/
|
||||||
if (*size != 5)
|
if (*size != 5)
|
||||||
VBDEBUG(("%s:%d - unexpected authorisation section size %d "
|
VB2_DEBUG("%s:%d - unexpected authorisation section size %d "
|
||||||
"for %s\n",
|
"for %s\n",
|
||||||
__func__, __LINE__, *size, cmd_name));
|
__func__, __LINE__, *size, cmd_name);
|
||||||
|
|
||||||
*buffer = ((uint8_t *)(*buffer)) + *size;
|
*buffer = ((uint8_t *)(*buffer)) + *size;
|
||||||
*size = 0;
|
*size = 0;
|
||||||
@@ -147,9 +150,9 @@ static void unmarshal_nv_read(void **buffer, int *size,
|
|||||||
|
|
||||||
if (nvr->params_size !=
|
if (nvr->params_size !=
|
||||||
(nvr->buffer.t.size + sizeof(nvr->buffer.t.size))) {
|
(nvr->buffer.t.size + sizeof(nvr->buffer.t.size))) {
|
||||||
VBDEBUG(("%s:%d - parameter/buffer %d/%d size mismatch",
|
VB2_DEBUG("%s:%d - parameter/buffer %d/%d size mismatch",
|
||||||
__func__, __LINE__, nvr->params_size,
|
__func__, __LINE__, nvr->params_size,
|
||||||
nvr->buffer.t.size));
|
nvr->buffer.t.size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,9 +168,9 @@ static void unmarshal_TPM2B(void **buffer,
|
|||||||
{
|
{
|
||||||
tpm2b->size = unmarshal_u16(buffer, size);
|
tpm2b->size = unmarshal_u16(buffer, size);
|
||||||
if (tpm2b->size > *size) {
|
if (tpm2b->size > *size) {
|
||||||
VBDEBUG(("%s:%d - "
|
VB2_DEBUG("%s:%d - "
|
||||||
"size mismatch: expected %d, remaining %d\n",
|
"size mismatch: expected %d, remaining %d\n",
|
||||||
__func__, __LINE__, tpm2b->size, *size));
|
__func__, __LINE__, tpm2b->size, *size);
|
||||||
*size = -1;
|
*size = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -184,9 +187,9 @@ static void unmarshal_TPMS_NV_PUBLIC(void **buffer,
|
|||||||
{
|
{
|
||||||
int tpm2b_size = unmarshal_u16(buffer, size);
|
int tpm2b_size = unmarshal_u16(buffer, size);
|
||||||
if (tpm2b_size > *size) {
|
if (tpm2b_size > *size) {
|
||||||
VBDEBUG(("%s:%d - "
|
VB2_DEBUG("%s:%d - "
|
||||||
"size mismatch: expected %d, remaining %d\n",
|
"size mismatch: expected %d, remaining %d\n",
|
||||||
__func__, __LINE__, tpm2b_size, *size));
|
__func__, __LINE__, tpm2b_size, *size);
|
||||||
*size = -1;
|
*size = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -199,9 +202,9 @@ static void unmarshal_TPMS_NV_PUBLIC(void **buffer,
|
|||||||
pub->dataSize = unmarshal_u16(buffer, &tpm2b_size);
|
pub->dataSize = unmarshal_u16(buffer, &tpm2b_size);
|
||||||
|
|
||||||
if (tpm2b_size != 0) {
|
if (tpm2b_size != 0) {
|
||||||
VBDEBUG(("%s:%d - "
|
VB2_DEBUG("%s:%d - "
|
||||||
"TPMS_NV_PUBLIC size doesn't match the size field\n",
|
"TPMS_NV_PUBLIC size doesn't match the size field\n",
|
||||||
__func__, __LINE__));
|
__func__, __LINE__);
|
||||||
*size = -1;
|
*size = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -214,9 +217,9 @@ static void unmarshal_nv_read_public(void **buffer, int *size,
|
|||||||
unmarshal_TPM2B(buffer, size, &nv_pub->nvName);
|
unmarshal_TPM2B(buffer, size, &nv_pub->nvName);
|
||||||
|
|
||||||
if (*size > 0) {
|
if (*size > 0) {
|
||||||
VBDEBUG(("%s:%d - "
|
VB2_DEBUG("%s:%d - "
|
||||||
"extra %d bytes after nvName\n",
|
"extra %d bytes after nvName\n",
|
||||||
__func__, __LINE__, *size));
|
__func__, __LINE__, *size);
|
||||||
*size = -1;
|
*size = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -229,9 +232,9 @@ static void unmarshal_TPML_TAGGED_TPM_PROPERTY(void **buffer, int *size,
|
|||||||
|
|
||||||
if (prop->count != 1) {
|
if (prop->count != 1) {
|
||||||
*size = -1;
|
*size = -1;
|
||||||
VBDEBUG(("%s:%d:Request to unmarshal unsupported "
|
VB2_DEBUG("%s:%d:Request to unmarshal unsupported "
|
||||||
"number of properties: %u\n",
|
"number of properties: %u\n",
|
||||||
__FILE__, __LINE__, prop->count));
|
__FILE__, __LINE__, prop->count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,9 +257,9 @@ static void unmarshal_TPMS_CAPABILITY_DATA(void **buffer, int *size,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
*size = -1;
|
*size = -1;
|
||||||
VBDEBUG(("%s:%d:Request to unmarshal unsupported "
|
VB2_DEBUG("%s:%d:Request to unmarshal unsupported "
|
||||||
"capability %#x\n",
|
"capability %#x\n",
|
||||||
__FILE__, __LINE__, cap_data->capability));
|
__FILE__, __LINE__, cap_data->capability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,8 +354,8 @@ static void marshal_reserve_size_field(void **buffer,
|
|||||||
int *buffer_space)
|
int *buffer_space)
|
||||||
{
|
{
|
||||||
if (field_size != sizeof(uint32_t) && field_size != sizeof(uint16_t)) {
|
if (field_size != sizeof(uint32_t) && field_size != sizeof(uint16_t)) {
|
||||||
VBDEBUG(("%s:%d:Unsupported size field size: %d\n",
|
VB2_DEBUG("%s:%d:Unsupported size field size: %d\n",
|
||||||
__FILE__, __LINE__, field_size));
|
__FILE__, __LINE__, field_size);
|
||||||
*buffer_space = -1;
|
*buffer_space = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -706,8 +709,8 @@ int tpm_marshal_command(TPM_CC command, void *tpm_command_body,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
body_size = -1;
|
body_size = -1;
|
||||||
VBDEBUG(("%s:%d:Request to marshal unsupported command %#x\n",
|
VB2_DEBUG("%s:%d:Request to marshal unsupported command %#x\n",
|
||||||
__FILE__, __LINE__, command));
|
__FILE__, __LINE__, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body_size > 0) {
|
if (body_size > 0) {
|
||||||
@@ -740,8 +743,9 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command,
|
|||||||
|
|
||||||
if (!cr_size) {
|
if (!cr_size) {
|
||||||
if (tpm2_resp.hdr.tpm_size != sizeof(tpm2_resp.hdr))
|
if (tpm2_resp.hdr.tpm_size != sizeof(tpm2_resp.hdr))
|
||||||
VBDEBUG(("%s: size mismatch in response to command %#x\n",
|
VB2_DEBUG("%s: "
|
||||||
__func__, command));
|
"size mismatch in response to command %#x\n",
|
||||||
|
__func__, command);
|
||||||
return &tpm2_resp;
|
return &tpm2_resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -778,28 +782,28 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
VBDEBUG(("%s:%d:"
|
VB2_DEBUG("%s:%d:"
|
||||||
"Request to unmarshal unexpected command %#x,"
|
"Request to unmarshal unexpected command %#x,"
|
||||||
" code %#x",
|
" code %#x",
|
||||||
__func__, __LINE__, command,
|
__func__, __LINE__, command,
|
||||||
tpm2_resp.hdr.tpm_code));
|
tpm2_resp.hdr.tpm_code);
|
||||||
|
|
||||||
for (i = 0; i < cr_size; i++) {
|
for (i = 0; i < cr_size; i++) {
|
||||||
if (!(i % 16))
|
if (!(i % 16))
|
||||||
VBDEBUG(("\n"));
|
VB2_DEBUG("\n");
|
||||||
VBDEBUG(("%2.2x ",
|
VB2_DEBUG("%2.2x ",
|
||||||
((uint8_t *)response_body)[i]));
|
((uint8_t *)response_body)[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VBDEBUG(("\n"));
|
VB2_DEBUG("\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cr_size) {
|
if (cr_size) {
|
||||||
VBDEBUG(("%s:%d got %d bytes back in response to %#x,"
|
VB2_DEBUG("%s:%d got %d bytes back in response to %#x,"
|
||||||
" failed to parse (%d)\n",
|
" failed to parse (%d)\n",
|
||||||
__func__, __LINE__, tpm2_resp.hdr.tpm_size,
|
__func__, __LINE__, tpm2_resp.hdr.tpm_size,
|
||||||
command, cr_size));
|
command, cr_size);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
* in the firmware
|
* in the firmware
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
|
|
||||||
#include "rollback_index.h"
|
#include "rollback_index.h"
|
||||||
#include "tpm2_marshaling.h"
|
#include "tpm2_marshaling.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
@@ -23,22 +26,21 @@ static struct tpm2_response *tpm_process_command(TPM_CC command,
|
|||||||
out_size = tpm_marshal_command(command, command_body,
|
out_size = tpm_marshal_command(command, command_body,
|
||||||
cr_buffer, sizeof(cr_buffer));
|
cr_buffer, sizeof(cr_buffer));
|
||||||
if (out_size < 0) {
|
if (out_size < 0) {
|
||||||
VBDEBUG(("command %#x, cr size %d\n",
|
VB2_DEBUG("command %#x, cr size %d\n", command, out_size);
|
||||||
command, out_size));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_size = sizeof(cr_buffer);
|
in_size = sizeof(cr_buffer);
|
||||||
if (VbExTpmSendReceive(cr_buffer, out_size,
|
if (VbExTpmSendReceive(cr_buffer, out_size,
|
||||||
cr_buffer, &in_size) != TPM_SUCCESS) {
|
cr_buffer, &in_size) != TPM_SUCCESS) {
|
||||||
VBDEBUG(("tpm transaction failed for %#x\n", command));
|
VB2_DEBUG("tpm transaction failed for %#x\n", command);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = tpm_unmarshal_response(command, cr_buffer, in_size);
|
response = tpm_unmarshal_response(command, cr_buffer, in_size);
|
||||||
|
|
||||||
VBDEBUG(("%s: command %#x, return code %#x\n", __func__, command,
|
VB2_DEBUG("%s: command %#x, return code %#x\n", __func__, command,
|
||||||
response ? response->hdr.tpm_code : -1));
|
response ? response->hdr.tpm_code : -1);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -208,13 +210,13 @@ uint32_t TlclForceClear(void)
|
|||||||
|
|
||||||
uint32_t TlclSetDeactivated(uint8_t flag)
|
uint32_t TlclSetDeactivated(uint8_t flag)
|
||||||
{
|
{
|
||||||
VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
|
VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
|
||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclSetEnable(void)
|
uint32_t TlclSetEnable(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
|
VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
|
||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,13 +236,13 @@ uint32_t TlclGetFlags(uint8_t* disable,
|
|||||||
|
|
||||||
int TlclIsOwned(void)
|
int TlclIsOwned(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
|
VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclExtend(int pcr_num, const uint8_t *in_digest, uint8_t *out_digest)
|
uint32_t TlclExtend(int pcr_num, const uint8_t *in_digest, uint8_t *out_digest)
|
||||||
{
|
{
|
||||||
VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
|
VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
|
||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,7 +476,7 @@ uint32_t TlclWrite(uint32_t index, const void *data, uint32_t length)
|
|||||||
|
|
||||||
uint32_t TlclPCRRead(uint32_t index, void *data, uint32_t length)
|
uint32_t TlclPCRRead(uint32_t index, void *data, uint32_t length)
|
||||||
{
|
{
|
||||||
VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
|
VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
|
||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,6 +519,6 @@ uint32_t TlclReadLock(uint32_t index)
|
|||||||
uint32_t TlclGetRandom(uint8_t *data, uint32_t length, uint32_t *size)
|
uint32_t TlclGetRandom(uint8_t *data, uint32_t length, uint32_t *size)
|
||||||
{
|
{
|
||||||
*size = 0;
|
*size = 0;
|
||||||
VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
|
VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
|
||||||
return TPM_E_IOERROR;
|
return TPM_E_IOERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@
|
|||||||
* time.
|
* time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysincludes.h"
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
|
|
||||||
|
#include "sysincludes.h"
|
||||||
#include "tlcl.h"
|
#include "tlcl.h"
|
||||||
#include "tlcl_internal.h"
|
#include "tlcl_internal.h"
|
||||||
#include "tlcl_structures.h"
|
#include "tlcl_structures.h"
|
||||||
@@ -73,18 +75,18 @@ static uint32_t TlclSendReceiveNoRetry(const uint8_t* request,
|
|||||||
uint32_t result;
|
uint32_t result;
|
||||||
|
|
||||||
#ifdef EXTRA_LOGGING
|
#ifdef EXTRA_LOGGING
|
||||||
VBDEBUG(("TPM: command: %x%x %x%x%x%x %x%x%x%x\n",
|
VB2_DEBUG("TPM: command: %x%x %x%x%x%x %x%x%x%x\n",
|
||||||
request[0], request[1],
|
request[0], request[1],
|
||||||
request[2], request[3], request[4], request[5],
|
request[2], request[3], request[4], request[5],
|
||||||
request[6], request[7], request[8], request[9]));
|
request[6], request[7], request[8], request[9]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result = VbExTpmSendReceive(request, TpmCommandSize(request),
|
result = VbExTpmSendReceive(request, TpmCommandSize(request),
|
||||||
response, &response_length);
|
response, &response_length);
|
||||||
if (0 != result) {
|
if (0 != result) {
|
||||||
/* Communication with TPM failed, so response is garbage */
|
/* Communication with TPM failed, so response is garbage */
|
||||||
VBDEBUG(("TPM: command 0x%x send/receive failed: 0x%x\n",
|
VB2_DEBUG("TPM: command 0x%x send/receive failed: 0x%x\n",
|
||||||
TpmCommandCode(request), result));
|
TpmCommandCode(request), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/* Otherwise, use the result code from the response */
|
/* Otherwise, use the result code from the response */
|
||||||
@@ -95,14 +97,14 @@ static uint32_t TlclSendReceiveNoRetry(const uint8_t* request,
|
|||||||
* crosbug.com/17017 */
|
* crosbug.com/17017 */
|
||||||
|
|
||||||
#ifdef EXTRA_LOGGING
|
#ifdef EXTRA_LOGGING
|
||||||
VBDEBUG(("TPM: response: %x%x %x%x%x%x %x%x%x%x\n",
|
VB2_DEBUG("TPM: response: %x%x %x%x%x%x %x%x%x%x\n",
|
||||||
response[0], response[1],
|
response[0], response[1],
|
||||||
response[2], response[3], response[4], response[5],
|
response[2], response[3], response[4], response[5],
|
||||||
response[6], response[7], response[8], response[9]));
|
response[6], response[7], response[8], response[9]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VBDEBUG(("TPM: command 0x%x returned 0x%x\n",
|
VB2_DEBUG("TPM: command 0x%x returned 0x%x\n",
|
||||||
TpmCommandCode(request), result));
|
TpmCommandCode(request), result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -165,32 +167,32 @@ uint32_t TlclLibClose(void)
|
|||||||
|
|
||||||
uint32_t TlclStartup(void)
|
uint32_t TlclStartup(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Startup\n"));
|
VB2_DEBUG("TPM: Startup\n");
|
||||||
return Send(tpm_startup_cmd.buffer);
|
return Send(tpm_startup_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclSaveState(void)
|
uint32_t TlclSaveState(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: SaveState\n"));
|
VB2_DEBUG("TPM: SaveState\n");
|
||||||
return Send(tpm_savestate_cmd.buffer);
|
return Send(tpm_savestate_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclResume(void)
|
uint32_t TlclResume(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Resume\n"));
|
VB2_DEBUG("TPM: Resume\n");
|
||||||
return Send(tpm_resume_cmd.buffer);
|
return Send(tpm_resume_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclSelfTestFull(void)
|
uint32_t TlclSelfTestFull(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Self test full\n"));
|
VB2_DEBUG("TPM: Self test full\n");
|
||||||
return Send(tpm_selftestfull_cmd.buffer);
|
return Send(tpm_selftestfull_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclContinueSelfTest(void)
|
uint32_t TlclContinueSelfTest(void)
|
||||||
{
|
{
|
||||||
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
|
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
|
||||||
VBDEBUG(("TPM: Continue self test\n"));
|
VB2_DEBUG("TPM: Continue self test\n");
|
||||||
/* Call the No Retry version of SendReceive to avoid recursion. */
|
/* Call the No Retry version of SendReceive to avoid recursion. */
|
||||||
return TlclSendReceiveNoRetry(tpm_continueselftest_cmd.buffer,
|
return TlclSendReceiveNoRetry(tpm_continueselftest_cmd.buffer,
|
||||||
response, sizeof(response));
|
response, sizeof(response));
|
||||||
@@ -199,7 +201,7 @@ uint32_t TlclContinueSelfTest(void)
|
|||||||
uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size)
|
uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size)
|
||||||
{
|
{
|
||||||
struct s_tpm_nv_definespace_cmd cmd;
|
struct s_tpm_nv_definespace_cmd cmd;
|
||||||
VBDEBUG(("TPM: TlclDefineSpace(0x%x, 0x%x, %d)\n", index, perm, size));
|
VB2_DEBUG("TPM: TlclDefineSpace(0x%x, 0x%x, %d)\n", index, perm, size);
|
||||||
memcpy(&cmd, &tpm_nv_definespace_cmd, sizeof(cmd));
|
memcpy(&cmd, &tpm_nv_definespace_cmd, sizeof(cmd));
|
||||||
ToTpmUint32(cmd.buffer + tpm_nv_definespace_cmd.index, index);
|
ToTpmUint32(cmd.buffer + tpm_nv_definespace_cmd.index, index);
|
||||||
ToTpmUint32(cmd.buffer + tpm_nv_definespace_cmd.perm, perm);
|
ToTpmUint32(cmd.buffer + tpm_nv_definespace_cmd.perm, perm);
|
||||||
@@ -214,7 +216,7 @@ uint32_t TlclWrite(uint32_t index, const void* data, uint32_t length)
|
|||||||
const int total_length =
|
const int total_length =
|
||||||
kTpmRequestHeaderLength + kWriteInfoLength + length;
|
kTpmRequestHeaderLength + kWriteInfoLength + length;
|
||||||
|
|
||||||
VBDEBUG(("TPM: TlclWrite(0x%x, %d)\n", index, length));
|
VB2_DEBUG("TPM: TlclWrite(0x%x, %d)\n", index, length);
|
||||||
memcpy(&cmd, &tpm_nv_write_cmd, sizeof(cmd));
|
memcpy(&cmd, &tpm_nv_write_cmd, sizeof(cmd));
|
||||||
VbAssert(total_length <= TPM_LARGE_ENOUGH_COMMAND_SIZE);
|
VbAssert(total_length <= TPM_LARGE_ENOUGH_COMMAND_SIZE);
|
||||||
SetTpmCommandSize(cmd.buffer, total_length);
|
SetTpmCommandSize(cmd.buffer, total_length);
|
||||||
@@ -233,7 +235,7 @@ uint32_t TlclRead(uint32_t index, void* data, uint32_t length)
|
|||||||
uint32_t result_length;
|
uint32_t result_length;
|
||||||
uint32_t result;
|
uint32_t result;
|
||||||
|
|
||||||
VBDEBUG(("TPM: TlclRead(0x%x, %d)\n", index, length));
|
VB2_DEBUG("TPM: TlclRead(0x%x, %d)\n", index, length);
|
||||||
memcpy(&cmd, &tpm_nv_read_cmd, sizeof(cmd));
|
memcpy(&cmd, &tpm_nv_read_cmd, sizeof(cmd));
|
||||||
ToTpmUint32(cmd.buffer + tpm_nv_read_cmd.index, index);
|
ToTpmUint32(cmd.buffer + tpm_nv_read_cmd.index, index);
|
||||||
ToTpmUint32(cmd.buffer + tpm_nv_read_cmd.length, length);
|
ToTpmUint32(cmd.buffer + tpm_nv_read_cmd.length, length);
|
||||||
@@ -257,7 +259,7 @@ uint32_t TlclPCRRead(uint32_t index, void* data, uint32_t length)
|
|||||||
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
|
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
|
||||||
uint32_t result;
|
uint32_t result;
|
||||||
|
|
||||||
VBDEBUG(("TPM: TlclPCRRead(0x%x, %d)\n", index, length));
|
VB2_DEBUG("TPM: TlclPCRRead(0x%x, %d)\n", index, length);
|
||||||
if (length < kPcrDigestLength) {
|
if (length < kPcrDigestLength) {
|
||||||
return TPM_E_IOERROR;
|
return TPM_E_IOERROR;
|
||||||
}
|
}
|
||||||
@@ -275,31 +277,31 @@ uint32_t TlclPCRRead(uint32_t index, void* data, uint32_t length)
|
|||||||
|
|
||||||
uint32_t TlclWriteLock(uint32_t index)
|
uint32_t TlclWriteLock(uint32_t index)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Write lock 0x%x\n", index));
|
VB2_DEBUG("TPM: Write lock 0x%x\n", index);
|
||||||
return TlclWrite(index, NULL, 0);
|
return TlclWrite(index, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclReadLock(uint32_t index)
|
uint32_t TlclReadLock(uint32_t index)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Read lock 0x%x\n", index));
|
VB2_DEBUG("TPM: Read lock 0x%x\n", index);
|
||||||
return TlclRead(index, NULL, 0);
|
return TlclRead(index, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclAssertPhysicalPresence(void)
|
uint32_t TlclAssertPhysicalPresence(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Asserting physical presence\n"));
|
VB2_DEBUG("TPM: Asserting physical presence\n");
|
||||||
return Send(tpm_ppassert_cmd.buffer);
|
return Send(tpm_ppassert_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclPhysicalPresenceCMDEnable(void)
|
uint32_t TlclPhysicalPresenceCMDEnable(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Enable the physical presence command\n"));
|
VB2_DEBUG("TPM: Enable the physical presence command\n");
|
||||||
return Send(tpm_ppenable_cmd.buffer);
|
return Send(tpm_ppenable_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclFinalizePhysicalPresence(void)
|
uint32_t TlclFinalizePhysicalPresence(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Enable PP cmd, disable HW pp, and set lifetime lock\n"));
|
VB2_DEBUG("TPM: Enable PP cmd, disable HW pp, and set lifetime lock\n");
|
||||||
return Send(tpm_finalizepp_cmd.buffer);
|
return Send(tpm_finalizepp_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,13 +314,13 @@ uint32_t TlclAssertPhysicalPresenceResult(void)
|
|||||||
|
|
||||||
uint32_t TlclLockPhysicalPresence(void)
|
uint32_t TlclLockPhysicalPresence(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Lock physical presence\n"));
|
VB2_DEBUG("TPM: Lock physical presence\n");
|
||||||
return Send(tpm_pplock_cmd.buffer);
|
return Send(tpm_pplock_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclSetNvLocked(void)
|
uint32_t TlclSetNvLocked(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Set NV locked\n"));
|
VB2_DEBUG("TPM: Set NV locked\n");
|
||||||
return TlclDefineSpace(TPM_NV_INDEX_LOCK, 0, 0);
|
return TlclDefineSpace(TPM_NV_INDEX_LOCK, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,26 +335,26 @@ int TlclIsOwned(void)
|
|||||||
|
|
||||||
uint32_t TlclForceClear(void)
|
uint32_t TlclForceClear(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Force clear\n"));
|
VB2_DEBUG("TPM: Force clear\n");
|
||||||
return Send(tpm_forceclear_cmd.buffer);
|
return Send(tpm_forceclear_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclSetEnable(void)
|
uint32_t TlclSetEnable(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Enabling TPM\n"));
|
VB2_DEBUG("TPM: Enabling TPM\n");
|
||||||
return Send(tpm_physicalenable_cmd.buffer);
|
return Send(tpm_physicalenable_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclClearEnable(void)
|
uint32_t TlclClearEnable(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("TPM: Disabling TPM\n"));
|
VB2_DEBUG("TPM: Disabling TPM\n");
|
||||||
return Send(tpm_physicaldisable_cmd.buffer);
|
return Send(tpm_physicaldisable_cmd.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TlclSetDeactivated(uint8_t flag)
|
uint32_t TlclSetDeactivated(uint8_t flag)
|
||||||
{
|
{
|
||||||
struct s_tpm_physicalsetdeactivated_cmd cmd;
|
struct s_tpm_physicalsetdeactivated_cmd cmd;
|
||||||
VBDEBUG(("TPM: SetDeactivated(%d)\n", flag));
|
VB2_DEBUG("TPM: SetDeactivated(%d)\n", flag);
|
||||||
memcpy(&cmd, &tpm_physicalsetdeactivated_cmd, sizeof(cmd));
|
memcpy(&cmd, &tpm_physicalsetdeactivated_cmd, sizeof(cmd));
|
||||||
*(cmd.buffer + cmd.deactivated) = flag;
|
*(cmd.buffer + cmd.deactivated) = flag;
|
||||||
return Send(cmd.buffer);
|
return Send(cmd.buffer);
|
||||||
@@ -408,9 +410,9 @@ uint32_t TlclGetFlags(uint8_t* disable,
|
|||||||
*deactivated = pflags.deactivated;
|
*deactivated = pflags.deactivated;
|
||||||
if (nvlocked)
|
if (nvlocked)
|
||||||
*nvlocked = pflags.nvLocked;
|
*nvlocked = pflags.nvLocked;
|
||||||
VBDEBUG(("TPM: Got flags disable=%d, deactivated=%d, "
|
VB2_DEBUG("TPM: Got flags disable=%d, deactivated=%d, "
|
||||||
"nvlocked=%d\n",
|
"nvlocked=%d\n",
|
||||||
pflags.disable, pflags.deactivated, pflags.nvLocked));
|
pflags.disable, pflags.deactivated, pflags.nvLocked);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -418,7 +420,7 @@ uint32_t TlclGetFlags(uint8_t* disable,
|
|||||||
uint32_t TlclSetGlobalLock(void)
|
uint32_t TlclSetGlobalLock(void)
|
||||||
{
|
{
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
VBDEBUG(("TPM: Set global lock\n"));
|
VB2_DEBUG("TPM: Set global lock\n");
|
||||||
return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0);
|
return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,7 +487,7 @@ uint32_t TlclGetRandom(uint8_t* data, uint32_t length, uint32_t *size)
|
|||||||
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
|
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
|
||||||
uint32_t result;
|
uint32_t result;
|
||||||
|
|
||||||
VBDEBUG(("TPM: TlclGetRandom(%d)\n", length));
|
VB2_DEBUG("TPM: TlclGetRandom(%d)\n", length);
|
||||||
memcpy(&cmd, &tpm_get_random_cmd, sizeof(cmd));
|
memcpy(&cmd, &tpm_get_random_cmd, sizeof(cmd));
|
||||||
ToTpmUint32(cmd.buffer + tpm_get_random_cmd.bytesRequested, length);
|
ToTpmUint32(cmd.buffer + tpm_get_random_cmd.bytesRequested, length);
|
||||||
/* There must be room in the response buffer for the bytes. */
|
/* There must be room in the response buffer for the bytes. */
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ struct LoadKernelParams *VbApiKernelGetParams(void)
|
|||||||
static void VbSetRecoveryRequest(struct vb2_context *ctx,
|
static void VbSetRecoveryRequest(struct vb2_context *ctx,
|
||||||
uint32_t recovery_request)
|
uint32_t recovery_request)
|
||||||
{
|
{
|
||||||
VBDEBUG(("VbSetRecoveryRequest(%d)\n", (int)recovery_request));
|
VB2_DEBUG("VbSetRecoveryRequest(%d)\n", (int)recovery_request);
|
||||||
vb2_nv_set(ctx, VB2_NV_RECOVERY_REQUEST, recovery_request);
|
vb2_nv_set(ctx, VB2_NV_RECOVERY_REQUEST, recovery_request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,8 +108,8 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
|
|||||||
uint32_t disk_count = 0;
|
uint32_t disk_count = 0;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
VBDEBUG(("VbTryLoadKernel() start, get_info_flags=0x%x\n",
|
VB2_DEBUG("VbTryLoadKernel() start, get_info_flags=0x%x\n",
|
||||||
(unsigned)get_info_flags));
|
(unsigned)get_info_flags);
|
||||||
|
|
||||||
lkp.fwmp = &fwmp;
|
lkp.fwmp = &fwmp;
|
||||||
lkp.nv_context = &vnc;
|
lkp.nv_context = &vnc;
|
||||||
@@ -120,7 +120,7 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
|
|||||||
get_info_flags))
|
get_info_flags))
|
||||||
disk_count = 0;
|
disk_count = 0;
|
||||||
|
|
||||||
VBDEBUG(("VbTryLoadKernel() found %d disks\n", (int)disk_count));
|
VB2_DEBUG("VbTryLoadKernel() found %d disks\n", (int)disk_count);
|
||||||
if (0 == disk_count) {
|
if (0 == disk_count) {
|
||||||
VbSetRecoveryRequest(ctx, VBNV_RECOVERY_RW_NO_DISK);
|
VbSetRecoveryRequest(ctx, VBNV_RECOVERY_RW_NO_DISK);
|
||||||
return VBERROR_NO_DISK_FOUND;
|
return VBERROR_NO_DISK_FOUND;
|
||||||
@@ -128,7 +128,7 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
|
|||||||
|
|
||||||
/* Loop over disks */
|
/* Loop over disks */
|
||||||
for (i = 0; i < disk_count; i++) {
|
for (i = 0; i < disk_count; i++) {
|
||||||
VBDEBUG(("VbTryLoadKernel() trying disk %d\n", (int)i));
|
VB2_DEBUG("VbTryLoadKernel() trying disk %d\n", (int)i);
|
||||||
/*
|
/*
|
||||||
* Sanity-check what we can. FWIW, VbTryLoadKernel() is always
|
* Sanity-check what we can. FWIW, VbTryLoadKernel() is always
|
||||||
* called with only a single bit set in get_info_flags.
|
* called with only a single bit set in get_info_flags.
|
||||||
@@ -141,11 +141,11 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
|
|||||||
16 > disk_info[i].lba_count ||
|
16 > disk_info[i].lba_count ||
|
||||||
get_info_flags != (disk_info[i].flags &
|
get_info_flags != (disk_info[i].flags &
|
||||||
~VB_DISK_FLAG_EXTERNAL_GPT)) {
|
~VB_DISK_FLAG_EXTERNAL_GPT)) {
|
||||||
VBDEBUG((" skipping: bytes_per_lba=%" PRIu64
|
VB2_DEBUG(" skipping: bytes_per_lba=%" PRIu64
|
||||||
" lba_count=%" PRIu64 " flags=0x%x\n",
|
" lba_count=%" PRIu64 " flags=0x%x\n",
|
||||||
disk_info[i].bytes_per_lba,
|
disk_info[i].bytes_per_lba,
|
||||||
disk_info[i].lba_count,
|
disk_info[i].lba_count,
|
||||||
disk_info[i].flags));
|
disk_info[i].flags);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
lkp.disk_handle = disk_info[i].handle;
|
lkp.disk_handle = disk_info[i].handle;
|
||||||
@@ -156,7 +156,7 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
|
|||||||
lkp.boot_flags |= disk_info[i].flags & VB_DISK_FLAG_EXTERNAL_GPT
|
lkp.boot_flags |= disk_info[i].flags & VB_DISK_FLAG_EXTERNAL_GPT
|
||||||
? BOOT_FLAG_EXTERNAL_GPT : 0;
|
? BOOT_FLAG_EXTERNAL_GPT : 0;
|
||||||
retval = LoadKernel(ctx, &lkp, cparams);
|
retval = LoadKernel(ctx, &lkp, cparams);
|
||||||
VBDEBUG(("VbTryLoadKernel() LoadKernel() = %d\n", retval));
|
VB2_DEBUG("VbTryLoadKernel() LoadKernel() = %d\n", retval);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stop now if we found a kernel.
|
* Stop now if we found a kernel.
|
||||||
@@ -488,7 +488,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
|
|||||||
cparams->gbb = malloc(sizeof(*cparams->gbb));
|
cparams->gbb = malloc(sizeof(*cparams->gbb));
|
||||||
retval = VbGbbReadHeader_static(cparams, cparams->gbb);
|
retval = VbGbbReadHeader_static(cparams, cparams->gbb);
|
||||||
if (VBERROR_SUCCESS != retval) {
|
if (VBERROR_SUCCESS != retval) {
|
||||||
VBDEBUG(("Gbb read header failed.\n"));
|
VB2_DEBUG("Gbb read header failed.\n");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,13 +512,13 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dev_switch && allow_fastboot_full_cap) {
|
if (dev_switch && allow_fastboot_full_cap) {
|
||||||
VBDEBUG(("Only performing integrity-check.\n"));
|
VB2_DEBUG("Only performing integrity-check.\n");
|
||||||
hash_only = 1;
|
hash_only = 1;
|
||||||
} else {
|
} else {
|
||||||
/* Get recovery key. */
|
/* Get recovery key. */
|
||||||
retval = VbGbbReadRecoveryKey(cparams, &kernel_subkey);
|
retval = VbGbbReadRecoveryKey(cparams, &kernel_subkey);
|
||||||
if (VBERROR_SUCCESS != retval) {
|
if (VBERROR_SUCCESS != retval) {
|
||||||
VBDEBUG(("Gbb Read Recovery key failed.\n"));
|
VB2_DEBUG("Gbb Read Recovery key failed.\n");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -544,7 +544,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
|
|||||||
if (VB2_SUCCESS !=
|
if (VB2_SUCCESS !=
|
||||||
vb2_unpack_key(&kernel_subkey2,
|
vb2_unpack_key(&kernel_subkey2,
|
||||||
(struct vb2_packed_key *)kernel_subkey)) {
|
(struct vb2_packed_key *)kernel_subkey)) {
|
||||||
VBDEBUG(("Unable to unpack kernel subkey\n"));
|
VB2_DEBUG("Unable to unpack kernel subkey\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
rv = vb2_verify_keyblock(keyblock2, image_size,
|
rv = vb2_verify_keyblock(keyblock2, image_size,
|
||||||
@@ -552,7 +552,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (VB2_SUCCESS != rv) {
|
if (VB2_SUCCESS != rv) {
|
||||||
VBDEBUG(("Verifying key block signature/hash failed.\n"));
|
VB2_DEBUG("Verifying key block signature/hash failed.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,13 +560,13 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
|
|||||||
if (!(key_block->key_block_flags &
|
if (!(key_block->key_block_flags &
|
||||||
(dev_switch ? KEY_BLOCK_FLAG_DEVELOPER_1 :
|
(dev_switch ? KEY_BLOCK_FLAG_DEVELOPER_1 :
|
||||||
KEY_BLOCK_FLAG_DEVELOPER_0))) {
|
KEY_BLOCK_FLAG_DEVELOPER_0))) {
|
||||||
VBDEBUG(("Key block developer flag mismatch.\n"));
|
VB2_DEBUG("Key block developer flag mismatch.\n");
|
||||||
if (hash_only == 0)
|
if (hash_only == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(key_block->key_block_flags & KEY_BLOCK_FLAG_RECOVERY_1)) {
|
if (!(key_block->key_block_flags & KEY_BLOCK_FLAG_RECOVERY_1)) {
|
||||||
VBDEBUG(("Key block recovery flag mismatch.\n"));
|
VB2_DEBUG("Key block recovery flag mismatch.\n");
|
||||||
if (hash_only == 0)
|
if (hash_only == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -574,7 +574,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
|
|||||||
/* Get key for preamble/data verification from the key block. */
|
/* Get key for preamble/data verification from the key block. */
|
||||||
struct vb2_public_key data_key2;
|
struct vb2_public_key data_key2;
|
||||||
if (VB2_SUCCESS != vb2_unpack_key(&data_key2, &keyblock2->data_key)) {
|
if (VB2_SUCCESS != vb2_unpack_key(&data_key2, &keyblock2->data_key)) {
|
||||||
VBDEBUG(("Unable to unpack kernel data key\n"));
|
VB2_DEBUG("Unable to unpack kernel data key\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,11 +589,11 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
|
|||||||
image_size - key_block->key_block_size,
|
image_size - key_block->key_block_size,
|
||||||
&data_key2,
|
&data_key2,
|
||||||
&wb)) {
|
&wb)) {
|
||||||
VBDEBUG(("Preamble verification failed.\n"));
|
VB2_DEBUG("Preamble verification failed.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("Kernel preamble is good.\n"));
|
VB2_DEBUG("Kernel preamble is good.\n");
|
||||||
|
|
||||||
/* Verify kernel data */
|
/* Verify kernel data */
|
||||||
body_offset = key_block->key_block_size + preamble->preamble_size;
|
body_offset = key_block->key_block_size + preamble->preamble_size;
|
||||||
@@ -602,11 +602,11 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
|
|||||||
image_size - body_offset,
|
image_size - body_offset,
|
||||||
(struct vb2_signature *)&preamble->body_signature,
|
(struct vb2_signature *)&preamble->body_signature,
|
||||||
&data_key2, &wb)) {
|
&data_key2, &wb)) {
|
||||||
VBDEBUG(("Kernel data verification failed.\n"));
|
VB2_DEBUG("Kernel data verification failed.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("Kernel is good.\n"));
|
VB2_DEBUG("Kernel is good.\n");
|
||||||
|
|
||||||
/* Fill in output parameters. */
|
/* Fill in output parameters. */
|
||||||
kparams->kernel_buffer = kbuf + body_offset;
|
kparams->kernel_buffer = kbuf + body_offset;
|
||||||
@@ -629,12 +629,12 @@ fail:
|
|||||||
|
|
||||||
VbError_t VbUnlockDevice(void)
|
VbError_t VbUnlockDevice(void)
|
||||||
{
|
{
|
||||||
VBDEBUG(("%s() Enabling dev-mode...\n", __func__));
|
VB2_DEBUG("%s() Enabling dev-mode...\n", __func__);
|
||||||
if (TPM_SUCCESS != SetVirtualDevMode(1))
|
if (TPM_SUCCESS != SetVirtualDevMode(1))
|
||||||
return VBERROR_TPM_SET_BOOT_MODE_STATE;
|
return VBERROR_TPM_SET_BOOT_MODE_STATE;
|
||||||
|
|
||||||
VBDEBUG(("%s() Mode change will take effect on next reboot.\n",
|
VB2_DEBUG("%s() Mode change will take effect on next reboot.\n",
|
||||||
__func__));
|
__func__);
|
||||||
return VBERROR_SUCCESS;
|
return VBERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,14 +642,14 @@ VbError_t VbLockDevice(void)
|
|||||||
{
|
{
|
||||||
VbNvLoad();
|
VbNvLoad();
|
||||||
|
|
||||||
VBDEBUG(("%s() - Storing request to leave dev-mode.\n",
|
VB2_DEBUG("%s() - Storing request to leave dev-mode.\n",
|
||||||
__func__));
|
__func__);
|
||||||
VbNvSet(&vnc, VBNV_DISABLE_DEV_REQUEST, 1);
|
VbNvSet(&vnc, VBNV_DISABLE_DEV_REQUEST, 1);
|
||||||
|
|
||||||
VbNvCommit();
|
VbNvCommit();
|
||||||
|
|
||||||
VBDEBUG(("%s() Mode change will take effect on next reboot.\n",
|
VB2_DEBUG("%s() Mode change will take effect on next reboot.\n",
|
||||||
__func__));
|
__func__);
|
||||||
|
|
||||||
return VBERROR_SUCCESS;
|
return VBERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
* Delay/beep functions used in dev-mode kernel selection.
|
* Delay/beep functions used in dev-mode kernel selection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysincludes.h"
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
|
|
||||||
|
#include "sysincludes.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
#include "gbb_header.h"
|
#include "gbb_header.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
@@ -69,8 +71,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
|
|||||||
uint32_t this_msecs, on_msecs, total_msecs;
|
uint32_t this_msecs, on_msecs, total_msecs;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
|
|
||||||
VBDEBUG(("VbGetDevMusicNotes: use_short is %d, hdr is %p, "
|
VB2_DEBUG("VbGetDevMusicNotes: use_short is %d, hdr is %p, "
|
||||||
"maxsize is %d\n", use_short, hdr, maxsize));
|
"maxsize is %d\n", use_short, hdr, maxsize);
|
||||||
|
|
||||||
if (use_short) {
|
if (use_short) {
|
||||||
builtin = short_notes_;
|
builtin = short_notes_;
|
||||||
@@ -89,7 +91,7 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
|
|||||||
goto nope;
|
goto nope;
|
||||||
|
|
||||||
if (0 != memcmp(hdr->sig, "$SND", sizeof(hdr->sig))) {
|
if (0 != memcmp(hdr->sig, "$SND", sizeof(hdr->sig))) {
|
||||||
VBDEBUG(("VbGetDevMusicNotes: bad sig\n"));
|
VB2_DEBUG("VbGetDevMusicNotes: bad sig\n");
|
||||||
goto nope;
|
goto nope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,8 +101,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
|
|||||||
*/
|
*/
|
||||||
maxnotes = 1 + (maxsize - sizeof(VbDevMusic)) / sizeof(VbDevMusicNote);
|
maxnotes = 1 + (maxsize - sizeof(VbDevMusic)) / sizeof(VbDevMusicNote);
|
||||||
if (hdr->count == 0 || hdr->count > maxnotes) {
|
if (hdr->count == 0 || hdr->count > maxnotes) {
|
||||||
VBDEBUG(("VbGetDevMusicNotes: count=%d maxnotes=%d\n",
|
VB2_DEBUG("VbGetDevMusicNotes: count=%d maxnotes=%d\n",
|
||||||
hdr->count, maxnotes));
|
hdr->count, maxnotes);
|
||||||
goto nope;
|
goto nope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +114,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
|
|||||||
if ((sizeof(VbDevMusicNote) > UINT_MAX / hdr->count) ||
|
if ((sizeof(VbDevMusicNote) > UINT_MAX / hdr->count) ||
|
||||||
(sizeof(hdr->count) >
|
(sizeof(hdr->count) >
|
||||||
UINT_MAX - hdr->count * sizeof(VbDevMusicNote))) {
|
UINT_MAX - hdr->count * sizeof(VbDevMusicNote))) {
|
||||||
VBDEBUG(("VbGetDevMusicNotes: count=%d, just isn't right\n",
|
VB2_DEBUG("VbGetDevMusicNotes: count=%d, just isn't right\n",
|
||||||
hdr->count));
|
hdr->count);
|
||||||
goto nope;
|
goto nope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,12 +125,12 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
|
|||||||
mysum = Crc32(&(hdr->count), mylen);
|
mysum = Crc32(&(hdr->count), mylen);
|
||||||
|
|
||||||
if (mysum != hdr->checksum) {
|
if (mysum != hdr->checksum) {
|
||||||
VBDEBUG(("VbGetDevMusicNotes: mysum=%08x, want=%08x\n",
|
VB2_DEBUG("VbGetDevMusicNotes: mysum=%08x, want=%08x\n",
|
||||||
mysum, hdr->checksum));
|
mysum, hdr->checksum);
|
||||||
goto nope;
|
goto nope;
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("VbGetDevMusicNotes: custom notes struct at %p\n", hdr));
|
VB2_DEBUG("VbGetDevMusicNotes: custom notes struct at %p\n", hdr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Measure the audible sound up to the first 22 seconds, being careful
|
* Measure the audible sound up to the first 22 seconds, being careful
|
||||||
@@ -149,8 +151,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We require at least one second of noise in the first 22 seconds */
|
/* We require at least one second of noise in the first 22 seconds */
|
||||||
VBDEBUG(("VbGetDevMusicNotes: with %d msecs of sound to begin\n",
|
VB2_DEBUG("VbGetDevMusicNotes: with %d msecs of sound to begin\n",
|
||||||
on_msecs));
|
on_msecs);
|
||||||
if (on_msecs < REQUIRED_NOISE_TIME)
|
if (on_msecs < REQUIRED_NOISE_TIME)
|
||||||
goto nope;
|
goto nope;
|
||||||
|
|
||||||
@@ -158,14 +160,14 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
|
|||||||
* We'll also require that the total time be less than 5 minutes. No
|
* We'll also require that the total time be less than 5 minutes. No
|
||||||
* real reason, it just gives us less to worry about.
|
* real reason, it just gives us less to worry about.
|
||||||
*/
|
*/
|
||||||
VBDEBUG(("VbGetDevMusicNotes: lasting %d msecs\n", total_msecs));
|
VB2_DEBUG("VbGetDevMusicNotes: lasting %d msecs\n", total_msecs);
|
||||||
if (total_msecs > MAX_CUSTOM_DELAY) {
|
if (total_msecs > MAX_CUSTOM_DELAY) {
|
||||||
goto nope;
|
goto nope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* One more check, just to be paranoid. */
|
/* One more check, just to be paranoid. */
|
||||||
if (hdr->count > (UINT_MAX / sizeof(VbDevMusicNote) - 1)) {
|
if (hdr->count > (UINT_MAX / sizeof(VbDevMusicNote) - 1)) {
|
||||||
VBDEBUG(("VbGetDevMusicNotes: they're all out to get me!\n"));
|
VB2_DEBUG("VbGetDevMusicNotes: they're all out to get me!\n");
|
||||||
goto nope;
|
goto nope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,8 +186,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
|
|||||||
notebuf[hdr->count].msec = this_msecs;
|
notebuf[hdr->count].msec = this_msecs;
|
||||||
notebuf[hdr->count].frequency = 0;
|
notebuf[hdr->count].frequency = 0;
|
||||||
count++;
|
count++;
|
||||||
VBDEBUG(("VbGetDevMusicNotes: adding %d msecs of silence\n",
|
VB2_DEBUG("VbGetDevMusicNotes: adding %d msecs of silence\n",
|
||||||
this_msecs));
|
this_msecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Done */
|
/* Done */
|
||||||
@@ -196,7 +198,7 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
|
|||||||
|
|
||||||
nope:
|
nope:
|
||||||
/* No custom notes, use the default. The count is already set. */
|
/* No custom notes, use the default. The count is already set. */
|
||||||
VBDEBUG(("VbGetDevMusicNotes: using %d default notes\n", count));
|
VB2_DEBUG("VbGetDevMusicNotes: using %d default notes\n", count);
|
||||||
audio->music_notes = builtin;
|
audio->music_notes = builtin;
|
||||||
audio->note_count = count;
|
audio->note_count = count;
|
||||||
audio->free_notes_when_done = 0;
|
audio->free_notes_when_done = 0;
|
||||||
@@ -220,8 +222,8 @@ VbAudioContext *VbAudioOpen(VbCommonParams *cparams)
|
|||||||
VbExSleepMs(10);
|
VbExSleepMs(10);
|
||||||
b = VbExGetTimer();
|
b = VbExGetTimer();
|
||||||
ticks_per_msec = (b - a) / 10ULL ;
|
ticks_per_msec = (b - a) / 10ULL ;
|
||||||
VBDEBUG(("VbAudioOpen() - ticks_per_msec is %" PRIu64 "\n",
|
VB2_DEBUG("VbAudioOpen() - ticks_per_msec is %" PRIu64 "\n",
|
||||||
ticks_per_msec));
|
ticks_per_msec);
|
||||||
|
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
memset(audio, 0, sizeof(*audio));
|
memset(audio, 0, sizeof(*audio));
|
||||||
@@ -230,7 +232,7 @@ VbAudioContext *VbAudioOpen(VbCommonParams *cparams)
|
|||||||
|
|
||||||
/* See if we have full background sound capability or not. */
|
/* See if we have full background sound capability or not. */
|
||||||
if (VBERROR_SUCCESS != VbExBeep(0,0)) {
|
if (VBERROR_SUCCESS != VbExBeep(0,0)) {
|
||||||
VBDEBUG(("VbAudioOpen() - VbExBeep() is limited\n"));
|
VB2_DEBUG("VbAudioOpen() - VbExBeep() is limited\n");
|
||||||
audio->background_beep = 0;
|
audio->background_beep = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,12 +242,12 @@ VbAudioContext *VbAudioOpen(VbCommonParams *cparams)
|
|||||||
*/
|
*/
|
||||||
if (gbb->major_version == GBB_MAJOR_VER && gbb->minor_version >= 1
|
if (gbb->major_version == GBB_MAJOR_VER && gbb->minor_version >= 1
|
||||||
&& (gbb->flags & GBB_FLAG_DEV_SCREEN_SHORT_DELAY)) {
|
&& (gbb->flags & GBB_FLAG_DEV_SCREEN_SHORT_DELAY)) {
|
||||||
VBDEBUG(("VbAudioOpen() - using short dev screen delay\n"));
|
VB2_DEBUG("VbAudioOpen() - using short dev screen delay\n");
|
||||||
use_short = 1;
|
use_short = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VbGetDevMusicNotes(audio, use_short);
|
VbGetDevMusicNotes(audio, use_short);
|
||||||
VBDEBUG(("VbAudioOpen() - note count %d\n", audio->note_count));
|
VB2_DEBUG("VbAudioOpen() - note count %d\n", audio->note_count);
|
||||||
|
|
||||||
return audio;
|
return audio;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,12 +168,12 @@ int VerifyVmlinuzInsideKBlob(uint64_t kblob, uint64_t kblob_size,
|
|||||||
uint64_t VbSharedDataReserve(VbSharedDataHeader *header, uint64_t size)
|
uint64_t VbSharedDataReserve(VbSharedDataHeader *header, uint64_t size)
|
||||||
{
|
{
|
||||||
if (!header || size > header->data_size - header->data_used) {
|
if (!header || size > header->data_size - header->data_used) {
|
||||||
VBDEBUG(("VbSharedData buffer out of space.\n"));
|
VB2_DEBUG("VbSharedData buffer out of space.\n");
|
||||||
return 0; /* Not initialized, or not enough space left. */
|
return 0; /* Not initialized, or not enough space left. */
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t offs = header->data_used;
|
uint64_t offs = header->data_used;
|
||||||
VBDEBUG(("VbSharedDataReserve %d bytes at %d\n", (int)size, (int)offs));
|
VB2_DEBUG("VbSharedDataReserve %d bytes at %d\n", (int)size, (int)offs);
|
||||||
|
|
||||||
header->data_used += size;
|
header->data_used += size;
|
||||||
return offs;
|
return offs;
|
||||||
@@ -190,9 +190,9 @@ int VbSharedDataSetKernelKey(VbSharedDataHeader *header, const VbPublicKey *src)
|
|||||||
|
|
||||||
kdest = &header->kernel_subkey;
|
kdest = &header->kernel_subkey;
|
||||||
|
|
||||||
VBDEBUG(("Saving kernel subkey to shared data: size %d, algo %d\n",
|
VB2_DEBUG("Saving kernel subkey to shared data: size %d, algo %d\n",
|
||||||
vb2_rsa_sig_size(vb2_crypto_to_signature(src->algorithm)),
|
vb2_rsa_sig_size(vb2_crypto_to_signature(src->algorithm)),
|
||||||
(int)src->algorithm));
|
(int)src->algorithm);
|
||||||
|
|
||||||
/* Attempt to allocate space for key, if it hasn't been allocated yet */
|
/* Attempt to allocate space for key, if it hasn't been allocated yet */
|
||||||
if (!header->kernel_subkey_data_offset) {
|
if (!header->kernel_subkey_data_offset) {
|
||||||
|
|||||||
@@ -6,23 +6,25 @@
|
|||||||
* (Firmware portion)
|
* (Firmware portion)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysincludes.h"
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
|
|
||||||
|
#include "sysincludes.h"
|
||||||
#include "vboot_api.h"
|
#include "vboot_api.h"
|
||||||
#include "vboot_common.h"
|
#include "vboot_common.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
int VbSharedDataInit(VbSharedDataHeader *header, uint64_t size)
|
int VbSharedDataInit(VbSharedDataHeader *header, uint64_t size)
|
||||||
{
|
{
|
||||||
VBDEBUG(("VbSharedDataInit, %d bytes, header %d bytes\n", (int)size,
|
VB2_DEBUG("VbSharedDataInit, %d bytes, header %d bytes\n", (int)size,
|
||||||
(int)sizeof(VbSharedDataHeader)));
|
(int)sizeof(VbSharedDataHeader));
|
||||||
|
|
||||||
if (size < sizeof(VbSharedDataHeader)) {
|
if (size < sizeof(VbSharedDataHeader)) {
|
||||||
VBDEBUG(("Not enough data for header.\n"));
|
VB2_DEBUG("Not enough data for header.\n");
|
||||||
return VBOOT_SHARED_DATA_INVALID;
|
return VBOOT_SHARED_DATA_INVALID;
|
||||||
}
|
}
|
||||||
if (size < VB_SHARED_DATA_MIN_SIZE) {
|
if (size < VB_SHARED_DATA_MIN_SIZE) {
|
||||||
VBDEBUG(("Shared data buffer too small.\n"));
|
VB2_DEBUG("Shared data buffer too small.\n");
|
||||||
return VBOOT_SHARED_DATA_INVALID;
|
return VBOOT_SHARED_DATA_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ void VbRenderTextAtPos(const char *text, int right_to_left,
|
|||||||
uint32_t cur_x = x, cur_y = y;
|
uint32_t cur_x = x, cur_y = y;
|
||||||
|
|
||||||
if (!text || !font) {
|
if (!text || !font) {
|
||||||
VBDEBUG((" VbRenderTextAtPos: invalid args\n"));
|
VB2_DEBUG(" VbRenderTextAtPos: invalid args\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,8 +140,8 @@ void VbRenderTextAtPos(const char *text, int right_to_left,
|
|||||||
|
|
||||||
if (VBERROR_SUCCESS != VbExDisplayImage(cur_x, cur_y, buffer,
|
if (VBERROR_SUCCESS != VbExDisplayImage(cur_x, cur_y, buffer,
|
||||||
buffersize)) {
|
buffersize)) {
|
||||||
VBDEBUG((" VbRenderTextAtPos: "
|
VB2_DEBUG(" VbRenderTextAtPos: "
|
||||||
"can't display ascii 0x%x\n", text[i]));
|
"can't display ascii 0x%x\n", text[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!right_to_left)
|
if (!right_to_left)
|
||||||
@@ -207,16 +207,16 @@ VbError_t VbDisplayScreenFromGBB(struct vb2_context *ctx,
|
|||||||
case VB_SCREEN_DEVELOPER_EGG:
|
case VB_SCREEN_DEVELOPER_EGG:
|
||||||
default:
|
default:
|
||||||
/* Screens which aren't in the GBB */
|
/* Screens which aren't in the GBB */
|
||||||
VBDEBUG(("VbDisplayScreenFromGBB(): screen %d not in the GBB\n",
|
VB2_DEBUG("VbDisplayScreenFromGBB(): screen %d not in GBB\n",
|
||||||
(int)screen));
|
(int)screen);
|
||||||
retval = VBERROR_INVALID_SCREEN_INDEX;
|
retval = VBERROR_INVALID_SCREEN_INDEX;
|
||||||
goto VbDisplayScreenFromGBB_exit;
|
goto VbDisplayScreenFromGBB_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screen_index >= hdr.number_of_screenlayouts) {
|
if (screen_index >= hdr.number_of_screenlayouts) {
|
||||||
VBDEBUG(("VbDisplayScreenFromGBB(): "
|
VB2_DEBUG("VbDisplayScreenFromGBB(): "
|
||||||
"screen %d index %d not in the GBB\n",
|
"screen %d index %d not in the GBB\n",
|
||||||
(int)screen, (int)screen_index));
|
(int)screen, (int)screen_index);
|
||||||
retval = VBERROR_INVALID_SCREEN_INDEX;
|
retval = VBERROR_INVALID_SCREEN_INDEX;
|
||||||
goto VbDisplayScreenFromGBB_exit;
|
goto VbDisplayScreenFromGBB_exit;
|
||||||
}
|
}
|
||||||
@@ -255,10 +255,10 @@ VbError_t VbDisplayScreenFromGBB(struct vb2_context *ctx,
|
|||||||
image_info.width,
|
image_info.width,
|
||||||
image_info.height);
|
image_info.height);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
VBDEBUG(("VbExDisplaySetDimension"
|
VB2_DEBUG("VbExDisplaySetDimension"
|
||||||
"(%d,%d): failed (%#x).\n",
|
"(%d,%d): failed (%#x).\n",
|
||||||
image_info.width,
|
image_info.width,
|
||||||
image_info.height, ret));
|
image_info.height, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,9 +294,9 @@ VbError_t VbDisplayScreenFromGBB(struct vb2_context *ctx,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
VBDEBUG(("VbDisplayScreenFromGBB(): "
|
VB2_DEBUG("VbDisplayScreenFromGBB(): "
|
||||||
"unsupported ImageFormat %d\n",
|
"unsupported ImageFormat %d\n",
|
||||||
image_info.format));
|
image_info.format);
|
||||||
retval = VBERROR_INVALID_GBB;
|
retval = VBERROR_INVALID_GBB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ VbError_t VbDisplayScreenFromGBB(struct vb2_context *ctx,
|
|||||||
VbRegionCheckVersion(cparams);
|
VbRegionCheckVersion(cparams);
|
||||||
|
|
||||||
VbDisplayScreenFromGBB_exit:
|
VbDisplayScreenFromGBB_exit:
|
||||||
VBDEBUG(("leaving VbDisplayScreenFromGBB() with %d\n",retval));
|
VB2_DEBUG("leaving VbDisplayScreenFromGBB() with %d\n",retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,8 +716,8 @@ VbError_t VbCheckDisplayKey(struct vb2_context *ctx, VbCommonParams *cparams,
|
|||||||
loc = (loc < count - 1 ? loc + 1 : 0);
|
loc = (loc < count - 1 ? loc + 1 : 0);
|
||||||
else
|
else
|
||||||
loc = (loc > 0 ? loc - 1 : count - 1);
|
loc = (loc > 0 ? loc - 1 : count - 1);
|
||||||
VBDEBUG(("VbCheckDisplayKey() - change localization to %d\n",
|
VB2_DEBUG("VbCheckDisplayKey() - change localization to %d\n",
|
||||||
(int)loc));
|
(int)loc);
|
||||||
vb2_nv_set(ctx, VB2_NV_LOCALIZATION_INDEX, loc);
|
vb2_nv_set(ctx, VB2_NV_LOCALIZATION_INDEX, loc);
|
||||||
vb2_nv_set(ctx, VB2_NV_BACKUP_NVRAM_REQUEST, 1);
|
vb2_nv_set(ctx, VB2_NV_BACKUP_NVRAM_REQUEST, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
static void VbAllowUsbBoot(struct vb2_context *ctx)
|
static void VbAllowUsbBoot(struct vb2_context *ctx)
|
||||||
{
|
{
|
||||||
VBDEBUG(("%s\n", __func__));
|
VB2_DEBUG("%s\n", __func__);
|
||||||
vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
|
vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@ static int VbWantShutdown(uint32_t gbb_flags)
|
|||||||
static void VbTryLegacy(int allowed)
|
static void VbTryLegacy(int allowed)
|
||||||
{
|
{
|
||||||
if (!allowed)
|
if (!allowed)
|
||||||
VBDEBUG(("VbBootDeveloper() - Legacy boot is disabled\n"));
|
VB2_DEBUG("VbBootDeveloper() - Legacy boot is disabled\n");
|
||||||
else if (0 != RollbackKernelLock(0))
|
else if (0 != RollbackKernelLock(0))
|
||||||
VBDEBUG(("Error locking kernel versions on legacy boot.\n"));
|
VB2_DEBUG("Error locking kernel versions on legacy boot.\n");
|
||||||
else
|
else
|
||||||
VbExLegacy(); /* will not return if successful */
|
VbExLegacy(); /* will not return if successful */
|
||||||
|
|
||||||
@@ -69,9 +69,9 @@ uint32_t VbTryUsb(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
{
|
{
|
||||||
uint32_t retval = VbTryLoadKernel(ctx, cparams, VB_DISK_FLAG_REMOVABLE);
|
uint32_t retval = VbTryLoadKernel(ctx, cparams, VB_DISK_FLAG_REMOVABLE);
|
||||||
if (VBERROR_SUCCESS == retval) {
|
if (VBERROR_SUCCESS == retval) {
|
||||||
VBDEBUG(("VbBootDeveloper() - booting USB\n"));
|
VB2_DEBUG("VbBootDeveloper() - booting USB\n");
|
||||||
} else {
|
} else {
|
||||||
VBDEBUG(("VbBootDeveloper() - no kernel found on USB\n"));
|
VB2_DEBUG("VbBootDeveloper() - no kernel found on USB\n");
|
||||||
VbExBeep(250, 200);
|
VbExBeep(250, 200);
|
||||||
VbExSleepMs(120);
|
VbExSleepMs(120);
|
||||||
/*
|
/*
|
||||||
@@ -98,7 +98,7 @@ int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
|
|||||||
uint32_t button;
|
uint32_t button;
|
||||||
int rec_button_was_pressed = 0;
|
int rec_button_was_pressed = 0;
|
||||||
|
|
||||||
VBDEBUG(("Entering %s(0x%x)\n", __func__, confirm_flags));
|
VB2_DEBUG("Entering %s(0x%x)\n", __func__, confirm_flags);
|
||||||
|
|
||||||
/* Await further instructions */
|
/* Await further instructions */
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -118,17 +118,17 @@ int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG(("%s() - Yes (1)\n", __func__));
|
VB2_DEBUG("%s() - Yes (1)\n", __func__);
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
VBDEBUG(("%s() - Space (%d)\n", __func__,
|
VB2_DEBUG("%s() - Space (%d)\n", __func__,
|
||||||
confirm_flags & VB_CONFIRM_SPACE_MEANS_NO));
|
confirm_flags & VB_CONFIRM_SPACE_MEANS_NO);
|
||||||
if (confirm_flags & VB_CONFIRM_SPACE_MEANS_NO)
|
if (confirm_flags & VB_CONFIRM_SPACE_MEANS_NO)
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case 0x1b:
|
case 0x1b:
|
||||||
VBDEBUG(("%s() - No (0)\n", __func__));
|
VB2_DEBUG("%s() - No (0)\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -137,12 +137,12 @@ int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
|
|||||||
*/
|
*/
|
||||||
if (!(shared->flags & VBSD_BOOT_REC_SWITCH_VIRTUAL)) {
|
if (!(shared->flags & VBSD_BOOT_REC_SWITCH_VIRTUAL)) {
|
||||||
if (button) {
|
if (button) {
|
||||||
VBDEBUG(("%s() - Rec button pressed\n",
|
VB2_DEBUG("%s() - Rec button pressed\n",
|
||||||
__func__));
|
__func__);
|
||||||
rec_button_was_pressed = 1;
|
rec_button_was_pressed = 1;
|
||||||
} else if (rec_button_was_pressed) {
|
} else if (rec_button_was_pressed) {
|
||||||
VBDEBUG(("%s() - Rec button (1)\n",
|
VB2_DEBUG("%s() - Rec button (1)\n",
|
||||||
__func__));
|
__func__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
|
|
||||||
VbAudioContext *audio = 0;
|
VbAudioContext *audio = 0;
|
||||||
|
|
||||||
VBDEBUG(("Entering %s()\n", __func__));
|
VB2_DEBUG("Entering %s()\n", __func__);
|
||||||
|
|
||||||
/* Check if USB booting is allowed */
|
/* Check if USB booting is allowed */
|
||||||
uint32_t allow_usb = vb2_nv_get(ctx, VB2_NV_DEV_BOOT_USB);
|
uint32_t allow_usb = vb2_nv_get(ctx, VB2_NV_DEV_BOOT_USB);
|
||||||
@@ -205,9 +205,9 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
allow_legacy = 1;
|
allow_legacy = 1;
|
||||||
if (fwmp_flags & FWMP_DEV_DISABLE_BOOT) {
|
if (fwmp_flags & FWMP_DEV_DISABLE_BOOT) {
|
||||||
if (gbb->flags & GBB_FLAG_FORCE_DEV_SWITCH_ON) {
|
if (gbb->flags & GBB_FLAG_FORCE_DEV_SWITCH_ON) {
|
||||||
VBDEBUG(("%s() - FWMP_DEV_DISABLE_BOOT rejected by "
|
VB2_DEBUG("%s() - FWMP_DEV_DISABLE_BOOT rejected by "
|
||||||
"FORCE_DEV_SWITCH_ON\n",
|
"FORCE_DEV_SWITCH_ON\n",
|
||||||
__func__));
|
__func__);
|
||||||
} else {
|
} else {
|
||||||
disable_dev_boot = 1;
|
disable_dev_boot = 1;
|
||||||
}
|
}
|
||||||
@@ -215,14 +215,14 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
|
|
||||||
/* If dev mode is disabled, only allow TONORM */
|
/* If dev mode is disabled, only allow TONORM */
|
||||||
while (disable_dev_boot) {
|
while (disable_dev_boot) {
|
||||||
VBDEBUG(("%s() - dev_disable_boot is set.\n", __func__));
|
VB2_DEBUG("%s() - dev_disable_boot is set.\n", __func__);
|
||||||
VbDisplayScreen(ctx, cparams, VB_SCREEN_DEVELOPER_TO_NORM, 0);
|
VbDisplayScreen(ctx, cparams, VB_SCREEN_DEVELOPER_TO_NORM, 0);
|
||||||
VbExDisplayDebugInfo(dev_disable_msg);
|
VbExDisplayDebugInfo(dev_disable_msg);
|
||||||
|
|
||||||
/* Ignore space in VbUserConfirms()... */
|
/* Ignore space in VbUserConfirms()... */
|
||||||
switch (VbUserConfirms(ctx, cparams, 0)) {
|
switch (VbUserConfirms(ctx, cparams, 0)) {
|
||||||
case 1:
|
case 1:
|
||||||
VBDEBUG(("%s() - leaving dev-mode.\n", __func__));
|
VB2_DEBUG("%s() - leaving dev-mode.\n", __func__);
|
||||||
vb2_nv_set(ctx, VB2_NV_DISABLE_DEV_REQUEST, 1);
|
vb2_nv_set(ctx, VB2_NV_DISABLE_DEV_REQUEST, 1);
|
||||||
VbDisplayScreen(ctx, cparams,
|
VbDisplayScreen(ctx, cparams,
|
||||||
VB_SCREEN_TO_NORM_CONFIRMED,
|
VB_SCREEN_TO_NORM_CONFIRMED,
|
||||||
@@ -230,11 +230,11 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
VbExSleepMs(5000);
|
VbExSleepMs(5000);
|
||||||
return VBERROR_REBOOT_REQUIRED;
|
return VBERROR_REBOOT_REQUIRED;
|
||||||
case -1:
|
case -1:
|
||||||
VBDEBUG(("%s() - shutdown requested\n", __func__));
|
VB2_DEBUG("%s() - shutdown requested\n", __func__);
|
||||||
return VBERROR_SHUTDOWN_REQUESTED;
|
return VBERROR_SHUTDOWN_REQUESTED;
|
||||||
default:
|
default:
|
||||||
/* Ignore user attempt to cancel */
|
/* Ignore user attempt to cancel */
|
||||||
VBDEBUG(("%s() - ignore cancel TONORM\n", __func__));
|
VB2_DEBUG("%s() - ignore cancel TONORM\n", __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
uint32_t key;
|
uint32_t key;
|
||||||
|
|
||||||
if (VbWantShutdown(gbb->flags)) {
|
if (VbWantShutdown(gbb->flags)) {
|
||||||
VBDEBUG(("VbBootDeveloper() - shutdown requested!\n"));
|
VB2_DEBUG("VbBootDeveloper() - shutdown requested!\n");
|
||||||
VbAudioClose(audio);
|
VbAudioClose(audio);
|
||||||
return VBERROR_SHUTDOWN_REQUESTED;
|
return VBERROR_SHUTDOWN_REQUESTED;
|
||||||
}
|
}
|
||||||
@@ -265,8 +265,8 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
/* See if we should disable virtual dev-mode switch. */
|
/* See if we should disable virtual dev-mode switch. */
|
||||||
VBDEBUG(("%s shared->flags=0x%x\n",
|
VB2_DEBUG("%s shared->flags=0x%x\n",
|
||||||
__func__, shared->flags));
|
__func__, shared->flags);
|
||||||
if (shared->flags & VBSD_HONOR_VIRT_DEV_SWITCH &&
|
if (shared->flags & VBSD_HONOR_VIRT_DEV_SWITCH &&
|
||||||
shared->flags & VBSD_BOOT_DEV_SWITCH_ON) {
|
shared->flags & VBSD_BOOT_DEV_SWITCH_ON) {
|
||||||
/* Stop the countdown while we go ask... */
|
/* Stop the countdown while we go ask... */
|
||||||
@@ -276,9 +276,9 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
* TONORM won't work (only for
|
* TONORM won't work (only for
|
||||||
* non-shipping devices).
|
* non-shipping devices).
|
||||||
*/
|
*/
|
||||||
VBDEBUG(("%s() - TONORM rejected by "
|
VB2_DEBUG("%s() - TONORM rejected by "
|
||||||
"FORCE_DEV_SWITCH_ON\n",
|
"FORCE_DEV_SWITCH_ON\n",
|
||||||
__func__));
|
__func__);
|
||||||
VbExDisplayDebugInfo(
|
VbExDisplayDebugInfo(
|
||||||
"WARNING: TONORM prohibited by "
|
"WARNING: TONORM prohibited by "
|
||||||
"GBB FORCE_DEV_SWITCH_ON.\n\n");
|
"GBB FORCE_DEV_SWITCH_ON.\n\n");
|
||||||
@@ -291,8 +291,8 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
/* Ignore space in VbUserConfirms()... */
|
/* Ignore space in VbUserConfirms()... */
|
||||||
switch (VbUserConfirms(ctx, cparams, 0)) {
|
switch (VbUserConfirms(ctx, cparams, 0)) {
|
||||||
case 1:
|
case 1:
|
||||||
VBDEBUG(("%s() - leaving dev-mode.\n",
|
VB2_DEBUG("%s() - leaving dev-mode.\n",
|
||||||
__func__));
|
__func__);
|
||||||
vb2_nv_set(ctx, VB2_NV_DISABLE_DEV_REQUEST,
|
vb2_nv_set(ctx, VB2_NV_DISABLE_DEV_REQUEST,
|
||||||
1);
|
1);
|
||||||
VbDisplayScreen(ctx,
|
VbDisplayScreen(ctx,
|
||||||
@@ -302,13 +302,13 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
VbExSleepMs(5000);
|
VbExSleepMs(5000);
|
||||||
return VBERROR_REBOOT_REQUIRED;
|
return VBERROR_REBOOT_REQUIRED;
|
||||||
case -1:
|
case -1:
|
||||||
VBDEBUG(("%s() - shutdown requested\n",
|
VB2_DEBUG("%s() - shutdown requested\n",
|
||||||
__func__));
|
__func__);
|
||||||
return VBERROR_SHUTDOWN_REQUESTED;
|
return VBERROR_SHUTDOWN_REQUESTED;
|
||||||
default:
|
default:
|
||||||
/* Stay in dev-mode */
|
/* Stay in dev-mode */
|
||||||
VBDEBUG(("%s() - stay in dev-mode\n",
|
VB2_DEBUG("%s() - stay in dev-mode\n",
|
||||||
__func__));
|
__func__);
|
||||||
VbDisplayScreen(ctx,
|
VbDisplayScreen(ctx,
|
||||||
cparams,
|
cparams,
|
||||||
VB_SCREEN_DEVELOPER_WARNING,
|
VB_SCREEN_DEVELOPER_WARNING,
|
||||||
@@ -321,8 +321,8 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
* No virtual dev-mode switch, so go directly
|
* No virtual dev-mode switch, so go directly
|
||||||
* to recovery mode.
|
* to recovery mode.
|
||||||
*/
|
*/
|
||||||
VBDEBUG(("%s() - going to recovery\n",
|
VB2_DEBUG("%s() - going to recovery\n",
|
||||||
__func__));
|
__func__);
|
||||||
vb2_nv_set(ctx, VB2_NV_RECOVERY_REQUEST,
|
vb2_nv_set(ctx, VB2_NV_RECOVERY_REQUEST,
|
||||||
VBNV_RECOVERY_RW_DEV_SCREEN);
|
VBNV_RECOVERY_RW_DEV_SCREEN);
|
||||||
VbAudioClose(audio);
|
VbAudioClose(audio);
|
||||||
@@ -331,14 +331,14 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
break;
|
break;
|
||||||
case 0x04:
|
case 0x04:
|
||||||
/* Ctrl+D = dismiss warning; advance to timeout */
|
/* Ctrl+D = dismiss warning; advance to timeout */
|
||||||
VBDEBUG(("VbBootDeveloper() - "
|
VB2_DEBUG("VbBootDeveloper() - "
|
||||||
"user pressed Ctrl+D; skip delay\n"));
|
"user pressed Ctrl+D; skip delay\n");
|
||||||
ctrl_d_pressed = 1;
|
ctrl_d_pressed = 1;
|
||||||
goto fallout;
|
goto fallout;
|
||||||
break;
|
break;
|
||||||
case 0x0c:
|
case 0x0c:
|
||||||
VBDEBUG(("VbBootDeveloper() - "
|
VB2_DEBUG("VbBootDeveloper() - "
|
||||||
"user pressed Ctrl+L; Try legacy boot\n"));
|
"user pressed Ctrl+L; Try legacy boot\n");
|
||||||
VbTryLegacy(allow_legacy);
|
VbTryLegacy(allow_legacy);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -349,11 +349,11 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
*/
|
*/
|
||||||
case 0x15:
|
case 0x15:
|
||||||
/* Ctrl+U = try USB boot, or beep if failure */
|
/* Ctrl+U = try USB boot, or beep if failure */
|
||||||
VBDEBUG(("VbBootDeveloper() - "
|
VB2_DEBUG("VbBootDeveloper() - "
|
||||||
"user pressed Ctrl+U; try USB\n"));
|
"user pressed Ctrl+U; try USB\n");
|
||||||
if (!allow_usb) {
|
if (!allow_usb) {
|
||||||
VBDEBUG(("VbBootDeveloper() - "
|
VB2_DEBUG("VbBootDeveloper() - "
|
||||||
"USB booting is disabled\n"));
|
"USB booting is disabled\n");
|
||||||
VbExDisplayDebugInfo(
|
VbExDisplayDebugInfo(
|
||||||
"WARNING: Booting from external media "
|
"WARNING: Booting from external media "
|
||||||
"(USB/SD) has not been enabled. Refer "
|
"(USB/SD) has not been enabled. Refer "
|
||||||
@@ -383,7 +383,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
VBDEBUG(("VbBootDeveloper() - pressed key %d\n", key));
|
VB2_DEBUG("VbBootDeveloper() - pressed key %d\n", key);
|
||||||
VbCheckDisplayKey(ctx, cparams, key);
|
VbCheckDisplayKey(ctx, cparams, key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -393,7 +393,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
|
|
||||||
/* If defaulting to legacy boot, try that unless Ctrl+D was pressed */
|
/* If defaulting to legacy boot, try that unless Ctrl+D was pressed */
|
||||||
if (use_legacy && !ctrl_d_pressed) {
|
if (use_legacy && !ctrl_d_pressed) {
|
||||||
VBDEBUG(("VbBootDeveloper() - defaulting to legacy\n"));
|
VB2_DEBUG("VbBootDeveloper() - defaulting to legacy\n");
|
||||||
VbTryLegacy(allow_legacy);
|
VbTryLegacy(allow_legacy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Timeout or Ctrl+D; attempt loading from fixed disk */
|
/* Timeout or Ctrl+D; attempt loading from fixed disk */
|
||||||
VBDEBUG(("VbBootDeveloper() - trying fixed disk\n"));
|
VB2_DEBUG("VbBootDeveloper() - trying fixed disk\n");
|
||||||
VbAudioClose(audio);
|
VbAudioClose(audio);
|
||||||
return VbTryLoadKernel(ctx, cparams, VB_DISK_FLAG_FIXED);
|
return VbTryLoadKernel(ctx, cparams, VB_DISK_FLAG_FIXED);
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,7 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
uint32_t key;
|
uint32_t key;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
VBDEBUG(("VbBootRecovery() start\n"));
|
VB2_DEBUG("VbBootRecovery() start\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the dev-mode switch is off and the user didn't press the recovery
|
* If the dev-mode switch is off and the user didn't press the recovery
|
||||||
@@ -448,8 +448,8 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
* back here, thus, we won't be able to give a user a chance to
|
* back here, thus, we won't be able to give a user a chance to
|
||||||
* reboot to workaround boot hicups.
|
* reboot to workaround boot hicups.
|
||||||
*/
|
*/
|
||||||
VBDEBUG(("VbBootRecovery() saving recovery reason (%#x)\n",
|
VB2_DEBUG("VbBootRecovery() saving recovery reason (%#x)\n",
|
||||||
shared->recovery_reason));
|
shared->recovery_reason);
|
||||||
vb2_nv_set(ctx, VB2_NV_RECOVERY_SUBCODE,
|
vb2_nv_set(ctx, VB2_NV_RECOVERY_SUBCODE,
|
||||||
shared->recovery_reason);
|
shared->recovery_reason);
|
||||||
/*
|
/*
|
||||||
@@ -459,7 +459,7 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
vb2_nv_commit(ctx);
|
vb2_nv_commit(ctx);
|
||||||
|
|
||||||
VbDisplayScreen(ctx, cparams, VB_SCREEN_OS_BROKEN, 0);
|
VbDisplayScreen(ctx, cparams, VB_SCREEN_OS_BROKEN, 0);
|
||||||
VBDEBUG(("VbBootRecovery() waiting for manual recovery\n"));
|
VB2_DEBUG("VbBootRecovery() waiting for manual recovery\n");
|
||||||
while (1) {
|
while (1) {
|
||||||
VbCheckDisplayKey(ctx, cparams, VbExKeyboardRead());
|
VbCheckDisplayKey(ctx, cparams, VbExKeyboardRead());
|
||||||
if (VbWantShutdown(cparams->gbb->flags))
|
if (VbWantShutdown(cparams->gbb->flags))
|
||||||
@@ -469,9 +469,9 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Loop and wait for a recovery image */
|
/* Loop and wait for a recovery image */
|
||||||
VBDEBUG(("VbBootRecovery() waiting for a recovery image\n"));
|
VB2_DEBUG("VbBootRecovery() waiting for a recovery image\n");
|
||||||
while (1) {
|
while (1) {
|
||||||
VBDEBUG(("VbBootRecovery() attempting to load kernel2\n"));
|
VB2_DEBUG("VbBootRecovery() attempting to load kernel2\n");
|
||||||
retval = VbTryLoadKernel(ctx, cparams, VB_DISK_FLAG_REMOVABLE);
|
retval = VbTryLoadKernel(ctx, cparams, VB_DISK_FLAG_REMOVABLE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -520,8 +520,8 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
* any case we don't like this. Beep
|
* any case we don't like this. Beep
|
||||||
* and ignore.
|
* and ignore.
|
||||||
*/
|
*/
|
||||||
VBDEBUG(("%s() - ^D but rec switch "
|
VB2_DEBUG("%s() - ^D but rec switch "
|
||||||
"is pressed\n", __func__));
|
"is pressed\n", __func__);
|
||||||
VbExBeep(120, 400);
|
VbExBeep(120, 400);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -537,23 +537,23 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
|
|||||||
switch (VbUserConfirms(ctx, cparams,
|
switch (VbUserConfirms(ctx, cparams,
|
||||||
vbc_flags)) {
|
vbc_flags)) {
|
||||||
case 1:
|
case 1:
|
||||||
VBDEBUG(("%s() Enabling dev-mode...\n",
|
VB2_DEBUG("%s() Enabling dev-mode...\n",
|
||||||
__func__));
|
__func__);
|
||||||
if (TPM_SUCCESS != SetVirtualDevMode(1))
|
if (TPM_SUCCESS != SetVirtualDevMode(1))
|
||||||
return VBERROR_TPM_SET_BOOT_MODE_STATE;
|
return VBERROR_TPM_SET_BOOT_MODE_STATE;
|
||||||
VBDEBUG(("%s() Reboot so it will take "
|
VB2_DEBUG("%s() Reboot so it will take "
|
||||||
"effect\n", __func__));
|
"effect\n", __func__);
|
||||||
if (VbExGetSwitches
|
if (VbExGetSwitches
|
||||||
(VB_INIT_FLAG_ALLOW_USB_BOOT))
|
(VB_INIT_FLAG_ALLOW_USB_BOOT))
|
||||||
VbAllowUsbBoot(ctx);
|
VbAllowUsbBoot(ctx);
|
||||||
return VBERROR_REBOOT_REQUIRED;
|
return VBERROR_REBOOT_REQUIRED;
|
||||||
case -1:
|
case -1:
|
||||||
VBDEBUG(("%s() - Shutdown requested\n",
|
VB2_DEBUG("%s() - Shutdown requested\n",
|
||||||
__func__));
|
__func__);
|
||||||
return VBERROR_SHUTDOWN_REQUESTED;
|
return VBERROR_SHUTDOWN_REQUESTED;
|
||||||
default: /* zero, actually */
|
default: /* zero, actually */
|
||||||
VBDEBUG(("%s() - Not enabling "
|
VB2_DEBUG("%s() - Not enabling "
|
||||||
"dev-mode\n", __func__));
|
"dev-mode\n", __func__);
|
||||||
/*
|
/*
|
||||||
* Jump out of the outer loop to
|
* Jump out of the outer loop to
|
||||||
* refresh the display quickly.
|
* refresh the display quickly.
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "2sysincludes.h"
|
||||||
|
#include "2common.h"
|
||||||
|
|
||||||
#include "tlcl.h"
|
#include "tlcl.h"
|
||||||
#include "tlcl_internal.h"
|
#include "tlcl_internal.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
@@ -176,8 +179,8 @@ VbError_t VbExTpmOpen(void)
|
|||||||
if (saved_errno != EBUSY)
|
if (saved_errno != EBUSY)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
VBDEBUG(("TPM: retrying %s: %s\n",
|
VB2_DEBUG("TPM: retrying %s: %s\n",
|
||||||
device_path, strerror(errno)));
|
device_path, strerror(errno));
|
||||||
|
|
||||||
/* Stall until TPM comes back. */
|
/* Stall until TPM comes back. */
|
||||||
delay.tv_sec = 0;
|
delay.tv_sec = 0;
|
||||||
@@ -216,7 +219,7 @@ VbError_t VbExTpmSendReceive(const uint8_t* request, uint32_t request_length,
|
|||||||
|
|
||||||
#ifdef VBOOT_DEBUG
|
#ifdef VBOOT_DEBUG
|
||||||
struct timeval before, after;
|
struct timeval before, after;
|
||||||
VBDEBUG(("request (%d bytes):\n", request_length));
|
VB2_DEBUG("request (%d bytes):\n", request_length);
|
||||||
DbgPrintBytes(request, request_length);
|
DbgPrintBytes(request, request_length);
|
||||||
gettimeofday(&before, NULL);
|
gettimeofday(&before, NULL);
|
||||||
#endif
|
#endif
|
||||||
@@ -227,11 +230,11 @@ VbError_t VbExTpmSendReceive(const uint8_t* request, uint32_t request_length,
|
|||||||
|
|
||||||
#ifdef VBOOT_DEBUG
|
#ifdef VBOOT_DEBUG
|
||||||
gettimeofday(&after, NULL);
|
gettimeofday(&after, NULL);
|
||||||
VBDEBUG(("response (%d bytes):\n", *response_length));
|
VB2_DEBUG("response (%d bytes):\n", *response_length);
|
||||||
DbgPrintBytes(response, *response_length);
|
DbgPrintBytes(response, *response_length);
|
||||||
VBDEBUG(("execution time: %dms\n",
|
VB2_DEBUG("execution time: %dms\n",
|
||||||
(int) ((after.tv_sec - before.tv_sec) * 1000 +
|
(int) ((after.tv_sec - before.tv_sec) * 1000 +
|
||||||
(after.tv_usec - before.tv_usec) / 1000)));
|
(after.tv_usec - before.tv_usec) / 1000));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|||||||
@@ -791,12 +791,12 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize)
|
|||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
if (pipe(mosys_to_crossystem) < 0) {
|
if (pipe(mosys_to_crossystem) < 0) {
|
||||||
VBDEBUG(("pipe() error\n"));
|
fprintf(stderr, "pipe() error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pid = fork()) < 0) {
|
if ((pid = fork()) < 0) {
|
||||||
VBDEBUG(("fork() error\n"));
|
fprintf(stderr, "fork() error\n");
|
||||||
close(mosys_to_crossystem[0]);
|
close(mosys_to_crossystem[0]);
|
||||||
close(mosys_to_crossystem[1]);
|
close(mosys_to_crossystem[1]);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -806,7 +806,7 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize)
|
|||||||
if (STDOUT_FILENO != mosys_to_crossystem[1]) {
|
if (STDOUT_FILENO != mosys_to_crossystem[1]) {
|
||||||
if (dup2(mosys_to_crossystem[1], STDOUT_FILENO)
|
if (dup2(mosys_to_crossystem[1], STDOUT_FILENO)
|
||||||
!= STDOUT_FILENO) {
|
!= STDOUT_FILENO) {
|
||||||
VBDEBUG(("stdout dup2() failed (mosys)\n"));
|
fprintf(stderr, "stdout dup2() failed (mosys)\n");
|
||||||
close(mosys_to_crossystem[1]);
|
close(mosys_to_crossystem[1]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -814,7 +814,7 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize)
|
|||||||
/* Execute mosys */
|
/* Execute mosys */
|
||||||
execv(InAndroid() ? MOSYS_ANDROID_PATH : MOSYS_CROS_PATH, argv);
|
execv(InAndroid() ? MOSYS_ANDROID_PATH : MOSYS_CROS_PATH, argv);
|
||||||
/* We shouldn't be here; exit now! */
|
/* We shouldn't be here; exit now! */
|
||||||
VBDEBUG(("execv() of mosys failed\n"));
|
fprintf(stderr, "execv() of mosys failed\n");
|
||||||
close(mosys_to_crossystem[1]);
|
close(mosys_to_crossystem[1]);
|
||||||
exit(1);
|
exit(1);
|
||||||
} else { /* Parent */
|
} else { /* Parent */
|
||||||
@@ -832,9 +832,8 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize)
|
|||||||
}
|
}
|
||||||
close(mosys_to_crossystem[0]);
|
close(mosys_to_crossystem[0]);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
VBDEBUG(("read() error reading output from mosys\n"));
|
fprintf(stderr, "read() error on output from mosys\n");
|
||||||
if (waitpid(pid, &status, 0) < 0 || status) {
|
if (waitpid(pid, &status, 0) < 0 || status) {
|
||||||
VBDEBUG(("waitpid() or mosys error\n"));
|
|
||||||
fprintf(stderr, "waitpid() or mosys error\n");
|
fprintf(stderr, "waitpid() or mosys error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ int DigestFile(char *input_file, enum vb2_hash_algorithm alg,
|
|||||||
struct vb2_digest_context ctx;
|
struct vb2_digest_context ctx;
|
||||||
|
|
||||||
if( (input_fd = open(input_file, O_RDONLY)) == -1 ) {
|
if( (input_fd = open(input_file, O_RDONLY)) == -1 ) {
|
||||||
VBDEBUG(("Couldn't open %s\n", input_file));
|
fprintf(stderr, "Couldn't open %s\n", input_file);
|
||||||
return VB2_ERROR_UNKNOWN;
|
return VB2_ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
vb2_digest_init(&ctx, alg);
|
vb2_digest_init(&ctx, alg);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ uint8_t* ReadFile(const char* filename, uint64_t* sizeptr)
|
|||||||
|
|
||||||
f = fopen(filename, "rb");
|
f = fopen(filename, "rb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
VBDEBUG(("Unable to open file %s\n", filename));
|
fprintf(stderr, "Unable to open file %s\n", filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ uint8_t* ReadFile(const char* filename, uint64_t* sizeptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(1 != fread(buf, size, 1, f)) {
|
if(1 != fread(buf, size, 1, f)) {
|
||||||
VBDEBUG(("Unable to read from file %s\n", filename));
|
fprintf(stderr, "Unable to read from file %s\n", filename);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
free(buf);
|
free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -103,12 +103,12 @@ int WriteFile(const char* filename, const void *data, uint64_t size)
|
|||||||
{
|
{
|
||||||
FILE *f = fopen(filename, "wb");
|
FILE *f = fopen(filename, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
VBDEBUG(("Unable to open file %s\n", filename));
|
fprintf(stderr, "Unable to open file %s\n", filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 != fwrite(data, size, 1, f)) {
|
if (1 != fwrite(data, size, 1, f)) {
|
||||||
VBDEBUG(("Unable to write to file %s\n", filename));
|
fprintf(stderr, "Unable to write to file %s\n", filename);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
unlink(filename); /* Delete any partial file */
|
unlink(filename); /* Delete any partial file */
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len,
|
|||||||
uint8_t digest[VB2_SHA512_DIGEST_SIZE]; /* Longest digest */
|
uint8_t digest[VB2_SHA512_DIGEST_SIZE]; /* Longest digest */
|
||||||
|
|
||||||
if (algorithm >= VB2_ALG_COUNT) {
|
if (algorithm >= VB2_ALG_COUNT) {
|
||||||
VBDEBUG(("SignatureDigest() called with invalid algorithm!\n"));
|
fprintf(stderr, "SignatureDigest(): "
|
||||||
|
"Called with invalid algorithm!\n");
|
||||||
} else if (VB2_SUCCESS ==
|
} else if (VB2_SUCCESS ==
|
||||||
vb2_digest_buffer(buf, len, vb2_crypto_to_hash(algorithm),
|
vb2_digest_buffer(buf, len, vb2_crypto_to_hash(algorithm),
|
||||||
digest, sizeof(digest))) {
|
digest, sizeof(digest))) {
|
||||||
@@ -60,7 +61,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
|
|||||||
uint8_t* signature = NULL;
|
uint8_t* signature = NULL;
|
||||||
uint8_t* signature_digest = SignatureDigest(buf, len, algorithm);
|
uint8_t* signature_digest = SignatureDigest(buf, len, algorithm);
|
||||||
if (!signature_digest) {
|
if (!signature_digest) {
|
||||||
VBDEBUG(("SignatureBuf(): Couldn't get signature digest\n"));
|
fprintf(stderr, "SignatureBuf(): "
|
||||||
|
"Couldn't get signature digest\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
|
|||||||
const uint8_t* digestinfo = NULL;
|
const uint8_t* digestinfo = NULL;
|
||||||
if (VB2_SUCCESS != vb2_digest_info(hash_alg, &digestinfo,
|
if (VB2_SUCCESS != vb2_digest_info(hash_alg, &digestinfo,
|
||||||
&digestinfo_size)) {
|
&digestinfo_size)) {
|
||||||
VBDEBUG(("SignatureBuf(): Couldn't get digest info\n"));
|
fprintf(stderr, "SignatureBuf(): Couldn't get digest info\n");
|
||||||
free(signature_digest);
|
free(signature_digest);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -79,8 +81,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
|
|||||||
|
|
||||||
key_fp = fopen(key_file, "r");
|
key_fp = fopen(key_file, "r");
|
||||||
if (!key_fp) {
|
if (!key_fp) {
|
||||||
VBDEBUG(("SignatureBuf(): Couldn't open key file: %s\n",
|
fprintf(stderr, "SignatureBuf(): Couldn't open key file: %s\n",
|
||||||
key_file));
|
key_file);
|
||||||
free(signature_digest);
|
free(signature_digest);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -88,8 +90,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
|
|||||||
signature = (uint8_t *)malloc(
|
signature = (uint8_t *)malloc(
|
||||||
vb2_rsa_sig_size(vb2_crypto_to_signature(algorithm)));
|
vb2_rsa_sig_size(vb2_crypto_to_signature(algorithm)));
|
||||||
else
|
else
|
||||||
VBDEBUG(("SignatureBuf(): Couldn't read private key from: %s\n",
|
fprintf(stderr, "SignatureBuf(): "
|
||||||
key_file));
|
"Couldn't read private key from: %s\n", key_file);
|
||||||
if (signature) {
|
if (signature) {
|
||||||
if (-1 == RSA_private_encrypt(
|
if (-1 == RSA_private_encrypt(
|
||||||
signature_digest_len, /* Input length. */
|
signature_digest_len, /* Input length. */
|
||||||
@@ -97,8 +99,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
|
|||||||
signature, /* Output signature. */
|
signature, /* Output signature. */
|
||||||
key, /* Key to use. */
|
key, /* Key to use. */
|
||||||
RSA_PKCS1_PADDING)) /* Padding to use. */
|
RSA_PKCS1_PADDING)) /* Padding to use. */
|
||||||
VBDEBUG(("SignatureBuf(): "
|
fprintf(stderr, "SignatureBuf(): "
|
||||||
"RSA_private_encrypt() failed.\n"));
|
"RSA_private_encrypt() failed.\n");
|
||||||
}
|
}
|
||||||
fclose(key_fp);
|
fclose(key_fp);
|
||||||
if (key)
|
if (key)
|
||||||
|
|||||||
@@ -231,21 +231,21 @@ uint32_t VbExKeyboardRead(void) {
|
|||||||
now = current_time;
|
now = current_time;
|
||||||
|
|
||||||
if (kbd_fire_key && now >= kbd_fire_at) {
|
if (kbd_fire_key && now >= kbd_fire_at) {
|
||||||
VBDEBUG((" VbExKeyboardRead() - returning %d at %d msec\n",
|
VB2_DEBUG(" VbExKeyboardRead() - returning %d at %d msec\n",
|
||||||
kbd_fire_key, now));
|
kbd_fire_key, now);
|
||||||
tmp = kbd_fire_key;
|
tmp = kbd_fire_key;
|
||||||
kbd_fire_key = 0;
|
kbd_fire_key = 0;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
VBDEBUG((" VbExKeyboardRead() - returning %d at %d msec\n",
|
VB2_DEBUG(" VbExKeyboardRead() - returning %d at %d msec\n",
|
||||||
0, now));
|
0, now);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VbExSleepMs(uint32_t msec) {
|
void VbExSleepMs(uint32_t msec) {
|
||||||
current_ticks += (uint64_t)msec * TICKS_PER_MSEC;
|
current_ticks += (uint64_t)msec * TICKS_PER_MSEC;
|
||||||
current_time = current_ticks / TICKS_PER_MSEC;
|
current_time = current_ticks / TICKS_PER_MSEC;
|
||||||
VBDEBUG(("VbExSleepMs(%d) -> %d\n", msec, current_time));
|
VB2_DEBUG("VbExSleepMs(%d) -> %d\n", msec, current_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t VbExGetTimer(void) {
|
uint64_t VbExGetTimer(void) {
|
||||||
@@ -253,7 +253,7 @@ uint64_t VbExGetTimer(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VbError_t VbExBeep(uint32_t msec, uint32_t frequency) {
|
VbError_t VbExBeep(uint32_t msec, uint32_t frequency) {
|
||||||
VBDEBUG(("VbExBeep(%d, %d) at %d msec\n", msec, frequency, current_time));
|
VB2_DEBUG("VbExBeep(%d, %d) at %d msec\n", msec, frequency, current_time);
|
||||||
|
|
||||||
if (current_event < max_events &&
|
if (current_event < max_events &&
|
||||||
msec == expected_event[current_event].msec &&
|
msec == expected_event[current_event].msec &&
|
||||||
@@ -271,31 +271,31 @@ VbError_t VbExBeep(uint32_t msec, uint32_t frequency) {
|
|||||||
VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale) {
|
VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale) {
|
||||||
switch(screen_type) {
|
switch(screen_type) {
|
||||||
case VB_SCREEN_BLANK:
|
case VB_SCREEN_BLANK:
|
||||||
VBDEBUG(("VbExDisplayScreen(BLANK)\n"));
|
VB2_DEBUG("VbExDisplayScreen(BLANK)\n");
|
||||||
break;
|
break;
|
||||||
case VB_SCREEN_DEVELOPER_WARNING:
|
case VB_SCREEN_DEVELOPER_WARNING:
|
||||||
VBDEBUG(("VbExDisplayScreen(DEV)\n"));
|
VB2_DEBUG("VbExDisplayScreen(DEV)\n");
|
||||||
break;
|
break;
|
||||||
case VB_SCREEN_DEVELOPER_EGG:
|
case VB_SCREEN_DEVELOPER_EGG:
|
||||||
VBDEBUG(("VbExDisplayScreen(EGG)\n"));
|
VB2_DEBUG("VbExDisplayScreen(EGG)\n");
|
||||||
break;
|
break;
|
||||||
case VB_SCREEN_RECOVERY_REMOVE:
|
case VB_SCREEN_RECOVERY_REMOVE:
|
||||||
VBDEBUG(("VbExDisplayScreen(REMOVE)\n"));
|
VB2_DEBUG("VbExDisplayScreen(REMOVE)\n");
|
||||||
break;
|
break;
|
||||||
case VB_SCREEN_RECOVERY_INSERT:
|
case VB_SCREEN_RECOVERY_INSERT:
|
||||||
VBDEBUG(("VbExDisplayScreen(INSERT)\n"));
|
VB2_DEBUG("VbExDisplayScreen(INSERT)\n");
|
||||||
break;
|
break;
|
||||||
case VB_SCREEN_RECOVERY_NO_GOOD:
|
case VB_SCREEN_RECOVERY_NO_GOOD:
|
||||||
VBDEBUG(("VbExDisplayScreen(NO_GOOD)\n"));
|
VB2_DEBUG("VbExDisplayScreen(NO_GOOD)\n");
|
||||||
break;
|
break;
|
||||||
case VB_SCREEN_OS_BROKEN:
|
case VB_SCREEN_OS_BROKEN:
|
||||||
VBDEBUG(("VbExDisplayScreen(BROKEN)\n"));
|
VB2_DEBUG("VbExDisplayScreen(BROKEN)\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
VBDEBUG(("VbExDisplayScreen(%d)\n", screen_type));
|
VB2_DEBUG("VbExDisplayScreen(%d)\n", screen_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
VBDEBUG((" current_time is %d msec\n", current_time));
|
VB2_DEBUG(" current_time is %d msec\n", current_time);
|
||||||
|
|
||||||
return VBERROR_SUCCESS;
|
return VBERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -307,7 +307,7 @@ static void VbBootDeveloperSoundTest(void) {
|
|||||||
int num_tests = sizeof(test) / sizeof(test_case_t);
|
int num_tests = sizeof(test) / sizeof(test_case_t);
|
||||||
|
|
||||||
for (i=0; i<num_tests; i++) {
|
for (i=0; i<num_tests; i++) {
|
||||||
VBDEBUG(("STARTING %s ...\n", test[i].name));
|
VB2_DEBUG("STARTING %s ...\n", test[i].name);
|
||||||
ResetMocks();
|
ResetMocks();
|
||||||
gbb.flags = test[i].gbb_flags;
|
gbb.flags = test[i].gbb_flags;
|
||||||
beep_return = test[i].beep_return;
|
beep_return = test[i].beep_return;
|
||||||
@@ -316,8 +316,8 @@ static void VbBootDeveloperSoundTest(void) {
|
|||||||
max_events = test[i].num_events;
|
max_events = test[i].num_events;
|
||||||
expected_event = test[i].notes;
|
expected_event = test[i].notes;
|
||||||
(void) VbBootDeveloper(&ctx, &cparams);
|
(void) VbBootDeveloper(&ctx, &cparams);
|
||||||
VBDEBUG(("INFO: matched %d total %d expected %d\n",
|
VB2_DEBUG("INFO: matched %d total %d expected %d\n",
|
||||||
matched_events, current_event, test[i].num_events));
|
matched_events, current_event, test[i].num_events);
|
||||||
TEST_TRUE(matched_events == test[i].num_events &&
|
TEST_TRUE(matched_events == test[i].num_events &&
|
||||||
current_event == test[i].num_events, test[i].name);
|
current_event == test[i].num_events, test[i].name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
|
|||||||
int i;
|
int i;
|
||||||
int num_disks = 0;
|
int num_disks = 0;
|
||||||
|
|
||||||
VBDEBUG(("My %s\n", __FUNCTION__));
|
VB2_DEBUG("My %s\n", __FUNCTION__);
|
||||||
|
|
||||||
*infos_ptr = mock_disks;
|
*infos_ptr = mock_disks;
|
||||||
|
|
||||||
@@ -248,14 +248,14 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
|
|||||||
t->disks_to_provide[i].flags;
|
t->disks_to_provide[i].flags;
|
||||||
mock_disks[num_disks].handle = (VbExDiskHandle_t)
|
mock_disks[num_disks].handle = (VbExDiskHandle_t)
|
||||||
t->disks_to_provide[i].diskname;
|
t->disks_to_provide[i].diskname;
|
||||||
VBDEBUG((" mock_disk[%d] %" PRIu64 " %" PRIu64
|
VB2_DEBUG(" mock_disk[%d] %" PRIu64 " %" PRIu64
|
||||||
" 0x%x %s\n", i,
|
" 0x%x %s\n", i,
|
||||||
mock_disks[num_disks].bytes_per_lba,
|
mock_disks[num_disks].bytes_per_lba,
|
||||||
mock_disks[num_disks].lba_count,
|
mock_disks[num_disks].lba_count,
|
||||||
mock_disks[num_disks].flags,
|
mock_disks[num_disks].flags,
|
||||||
(mock_disks[num_disks].handle
|
(mock_disks[num_disks].handle
|
||||||
? (char *)mock_disks[num_disks].handle
|
? (char *)mock_disks[num_disks].handle
|
||||||
: "0")));
|
: "0"));
|
||||||
num_disks++;
|
num_disks++;
|
||||||
} else {
|
} else {
|
||||||
mock_disks[num_disks].handle =
|
mock_disks[num_disks].handle =
|
||||||
@@ -268,8 +268,8 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
|
|||||||
else
|
else
|
||||||
*count = num_disks;
|
*count = num_disks;
|
||||||
|
|
||||||
VBDEBUG((" *count=%" PRIu32 "\n", *count));
|
VB2_DEBUG(" *count=%" PRIu32 "\n", *count);
|
||||||
VBDEBUG((" return 0x%x\n", t->diskgetinfo_return_val));
|
VB2_DEBUG(" return 0x%x\n", t->diskgetinfo_return_val);
|
||||||
|
|
||||||
return t->diskgetinfo_return_val;
|
return t->diskgetinfo_return_val;
|
||||||
}
|
}
|
||||||
@@ -278,8 +278,8 @@ VbError_t VbExDiskFreeInfo(VbDiskInfo *infos,
|
|||||||
VbExDiskHandle_t preserve_handle)
|
VbExDiskHandle_t preserve_handle)
|
||||||
{
|
{
|
||||||
got_load_disk = (const char *)preserve_handle;
|
got_load_disk = (const char *)preserve_handle;
|
||||||
VBDEBUG(("%s(): got_load_disk = %s\n", __FUNCTION__,
|
VB2_DEBUG("%s(): got_load_disk = %s\n", __FUNCTION__,
|
||||||
got_load_disk ? got_load_disk : "0"));
|
got_load_disk ? got_load_disk : "0");
|
||||||
return VBERROR_SUCCESS;
|
return VBERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,9 +287,9 @@ VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params,
|
|||||||
VbCommonParams *cparams)
|
VbCommonParams *cparams)
|
||||||
{
|
{
|
||||||
got_find_disk = (const char *)params->disk_handle;
|
got_find_disk = (const char *)params->disk_handle;
|
||||||
VBDEBUG(("%s(%d): got_find_disk = %s\n", __FUNCTION__,
|
VB2_DEBUG("%s(%d): got_find_disk = %s\n", __FUNCTION__,
|
||||||
load_kernel_calls,
|
load_kernel_calls,
|
||||||
got_find_disk ? got_find_disk : "0"));
|
got_find_disk ? got_find_disk : "0");
|
||||||
if (t->external_expected[load_kernel_calls] !=
|
if (t->external_expected[load_kernel_calls] !=
|
||||||
!!(params->boot_flags & BOOT_FLAG_EXTERNAL_GPT))
|
!!(params->boot_flags & BOOT_FLAG_EXTERNAL_GPT))
|
||||||
got_external_mismatch++;
|
got_external_mismatch++;
|
||||||
@@ -300,8 +300,8 @@ void vb2_nv_set(struct vb2_context *ctx,
|
|||||||
enum vb2_nv_param param,
|
enum vb2_nv_param param,
|
||||||
uint32_t value)
|
uint32_t value)
|
||||||
{
|
{
|
||||||
VBDEBUG(("%s(): got_recovery_request_val = %d (0x%x)\n", __FUNCTION__,
|
VB2_DEBUG("%s(): got_recovery_request_val = %d (0x%x)\n", __FUNCTION__,
|
||||||
value, value));
|
value, value);
|
||||||
got_recovery_request_val = value;
|
got_recovery_request_val = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ void FixChecksum(VbDevMusic *hdr) {
|
|||||||
|
|
||||||
/* Reset mock data (for use before each test) */
|
/* Reset mock data (for use before each test) */
|
||||||
static void ResetMocks(void) {
|
static void ResetMocks(void) {
|
||||||
VBDEBUG(("ResetMocks()\n"));
|
|
||||||
memset(&cparams, 0, sizeof(cparams));
|
memset(&cparams, 0, sizeof(cparams));
|
||||||
cparams.gbb_data = &gbb;
|
cparams.gbb_data = &gbb;
|
||||||
cparams.gbb = &gbb;
|
cparams.gbb = &gbb;
|
||||||
|
|||||||
Reference in New Issue
Block a user