summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-08-12 15:12:47 -0600
committerChromeBot <chrome-bot@google.com>2013-08-24 09:37:48 -0700
commit981cb2acdc2f26ae27732a4e590c326787936381 (patch)
tree1a6bf6aa9a2ac8f81bedcf59e44a2bc215c2c2fb
parent798cc91de11d5a78e379c67731dcafaf2aae01e1 (diff)
downloadvboot-981cb2acdc2f26ae27732a4e590c326787936381.tar.gz
Enable vboot for sandbox and improve debugging/format strings
Some functions of vboot are disabled for sandbox because sandbox could not support them. This has changed, so remove the sandbox #ifdefs in the code. Some printf() strings cause warnings on sandbox - mostly that uin64_t is not 'long long' on a 64-bit machine. The existing format strings in U-Boot do not seem to take account of this, so add casts to remove the warnings. Also add a few more debug strings to make it easier to see what is happening in the vboot flow. BUG=chrome-os-partner:21115 BRANCH=pit TEST=manual crosfw -b sandbox -V See there are no warnings. Change-Id: I86f90a693e4bd23fcacf6d48297dd32229348dd4 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/65621 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--firmware/lib/vboot_api_kernel.c4
-rw-r--r--firmware/lib/vboot_audio.c7
-rw-r--r--firmware/lib/vboot_common.c14
-rw-r--r--firmware/lib/vboot_common_init.c2
-rw-r--r--firmware/lib/vboot_firmware.c6
-rw-r--r--firmware/lib/vboot_kernel.c17
6 files changed, 22 insertions, 28 deletions
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 744ad4d6..7ad45929 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -87,8 +87,8 @@ uint32_t VbTryLoadKernel(VbCommonParams *cparams, LoadKernelParams *p,
if (512 != disk_info[i].bytes_per_lba ||
32 > disk_info[i].lba_count ||
get_info_flags != disk_info[i].flags) {
- VBDEBUG((" skipping: bytes_per_lba=%lld "
- "lba_count=%lld flags=0x%x\n",
+ VBDEBUG((" skipping: bytes_per_lba=%" PRIu64
+ " lba_count=%" PRIu64 " flags=0x%x\n",
disk_info[i].bytes_per_lba,
disk_info[i].lba_count,
disk_info[i].flags));
diff --git a/firmware/lib/vboot_audio.c b/firmware/lib/vboot_audio.c
index 8f96b68e..5414f325 100644
--- a/firmware/lib/vboot_audio.c
+++ b/firmware/lib/vboot_audio.c
@@ -221,7 +221,8 @@ VbAudioContext *VbAudioOpen(VbCommonParams *cparams)
VbExSleepMs(10);
b = VbExGetTimer();
ticks_per_msec = (b - a) / 10ULL ;
- VBDEBUG(("VbAudioOpen() - ticks_per_msec is %llu\n", ticks_per_msec));
+ VBDEBUG(("VbAudioOpen() - ticks_per_msec is %" PRIu64 "\n",
+ ticks_per_msec));
/* Initialize */
Memset(audio, 0, sizeof(*audio));
@@ -260,10 +261,6 @@ int VbAudioLooping(VbAudioContext *audio)
uint16_t msec = 0;
int looping = 1;
-#if defined(CONFIG_SANDBOX)
- return 0;
-#endif
-
now = VbExGetTimer();
while (audio->next_note < audio->note_count &&
now >= audio->play_until) {
diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c
index bd937102..b30a982e 100644
--- a/firmware/lib/vboot_common.c
+++ b/firmware/lib/vboot_common.c
@@ -146,8 +146,14 @@ RSAPublicKey *PublicKeyToRSA(const VbPublicKey *key)
int VerifyData(const uint8_t *data, uint64_t size, const VbSignature *sig,
const RSAPublicKey *key)
{
+ VBDEBUG((" - sig_size=%d, expecting %d for algorithm %d\n",
+ (unsigned)sig->sig_size, siglen_map[key->algorithm],
+ key->algorithm));
if (sig->sig_size != siglen_map[key->algorithm]) {
- VBDEBUG(("Wrong signature size for algorithm.\n"));
+ VBDEBUG(("Wrong data signature size for algorithm, "
+ "sig_size=%d, expected %d for algorithm %d.\n",
+ (int)sig->sig_size, siglen_map[key->algorithm],
+ key->algorithm));
return 1;
}
if (sig->data_size > size) {
@@ -166,7 +172,7 @@ int VerifyDigest(const uint8_t *digest, const VbSignature *sig,
const RSAPublicKey *key)
{
if (sig->sig_size != siglen_map[key->algorithm]) {
- VBDEBUG(("Wrong signature size for algorithm.\n"));
+ VBDEBUG(("Wrong digest signature size for algorithm.\n"));
return 1;
}
@@ -304,6 +310,7 @@ int VerifyFirmwarePreamble(const VbFirmwarePreambleHeader *preamble,
{
const VbSignature *sig = &preamble->preamble_signature;
+ VBDEBUG(("Verifying preamble.\n"));
/* Sanity checks before attempting signature of data */
if(size < EXPECTED_VBFIRMWAREPREAMBLEHEADER2_0_SIZE) {
VBDEBUG(("Not enough data for preamble header 2.0.\n"));
@@ -450,6 +457,9 @@ int VbSharedDataSetKernelKey(VbSharedDataHeader *header, const VbPublicKey *src)
{
VbPublicKey *kdest = &header->kernel_subkey;
+ VBDEBUG(("Saving kernel subkey to shared data: size %d, algo %d\n",
+ siglen_map[src->algorithm], (int)src->algorithm));
+
if (!header)
return VBOOT_SHARED_DATA_INVALID;
diff --git a/firmware/lib/vboot_common_init.c b/firmware/lib/vboot_common_init.c
index 0e5e9f3e..2f3cf385 100644
--- a/firmware/lib/vboot_common_init.c
+++ b/firmware/lib/vboot_common_init.c
@@ -15,7 +15,7 @@
int VbSharedDataInit(VbSharedDataHeader *header, uint64_t size)
{
VBDEBUG(("VbSharedDataInit, %d bytes, header %d bytes\n", (int)size,
- sizeof(VbSharedDataHeader)));
+ (int)sizeof(VbSharedDataHeader)));
if (size < sizeof(VbSharedDataHeader)) {
VBDEBUG(("Not enough data for header.\n"));
diff --git a/firmware/lib/vboot_firmware.c b/firmware/lib/vboot_firmware.c
index d909e9fc..c5000cb7 100644
--- a/firmware/lib/vboot_firmware.c
+++ b/firmware/lib/vboot_firmware.c
@@ -209,11 +209,13 @@ int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
}
/* Handle preamble flag for using the RO normal/dev code path */
+ VBDEBUG(("Preamble flags %#x\n", VbGetFirmwarePreambleFlags(preamble)));
if (VbGetFirmwarePreambleFlags(preamble) &
VB_FIRMWARE_PREAMBLE_USE_RO_NORMAL) {
/* Fail if calling firmware doesn't support RO normal */
if (!(shared->flags & VBSD_BOOT_RO_NORMAL_SUPPORT)) {
+ VBDEBUG(("No RO normal support.\n"));
*check_result = VBSD_LF_CHECK_NO_RO_NORMAL;
RSAPublicKeyFree(data_key);
continue;
@@ -351,8 +353,10 @@ int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
* recovery was not previously requested. */
if (!(shared->flags & VBSD_BOOT_RO_NORMAL_SUPPORT) &&
VBNV_RECOVERY_NOT_REQUESTED == shared->recovery_reason &&
- VBERROR_SUCCESS != retval)
+ VBERROR_SUCCESS != retval) {
+ VBDEBUG(("RO normal but we got an error.\n"));
shared->recovery_reason = recovery;
+ }
return retval;
}
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index d63d4eed..05dbe068 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -294,17 +294,6 @@ VbError_t LoadKernel(LoadKernelParams *params)
goto bad_kernel;
}
-#if defined(CONFIG_SANDBOX)
- /* Silence compiler warnings */
- combined_version = 0;
- body_offset = body_offset;
- body_offset_sectors = body_offset_sectors;
- body_sectors = body_sectors;
- kernel_subkey = kernel_subkey;
- key_block = key_block;
- key_version = key_version;
- preamble = preamble;
-#else
/* Verify the key block. */
key_block = (VbKeyBlockHeader*)kbuf;
if (0 != KeyBlockVerify(key_block, KBUF_SIZE,
@@ -504,7 +493,6 @@ VbError_t LoadKernel(LoadKernelParams *params)
/* Done with the kernel signing key, so can free it now */
RSAPublicKeyFree(data_key);
data_key = NULL;
-#endif
/*
* If we're still here, the kernel is valid. Save the first
@@ -528,13 +516,8 @@ VbError_t LoadKernel(LoadKernelParams *params)
* size, or the dest should be a struct, so we know it's big
* enough.
*/
-#if defined(CONFIG_SANDBOX)
- params->bootloader_address = 0;
- params->bootloader_size = 0;
-#else
params->bootloader_address = preamble->bootloader_address;
params->bootloader_size = preamble->bootloader_size;
-#endif
/* Update GPT to note this is the kernel we're trying */
GptUpdateKernelEntry(&gpt, GPT_UPDATE_ENTRY_TRY);