diff options
author | Randall Spangler <rspangler@chromium.org> | 2014-10-08 16:41:01 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-15 00:10:10 +0000 |
commit | 4184e626336fa8d794a21208387226f154d77d0f (patch) | |
tree | f5e03108edb836829498cc35a432f017bb1e707b /tests/vboot_kernel_tests.c | |
parent | 5dc75d16b6d5cb0ebc677e6572a2559c6157b8e4 (diff) | |
download | vboot-4184e626336fa8d794a21208387226f154d77d0f.tar.gz |
Use VbExStream APIs to read the kernel partition
This is necessary to support reading the kernel from raw NAND flash,
where the driver may need to skip over bad sectors, and absolute
sector addressing is thus not practical.
The impact is relatively minor. Vboot only did two reads per kernel
anyway, one for the first 64KB of the partition and a second for the
rest of the kernel data.
Firmware which uses vboot will need to implement the streaming APIs.
Or, as a really easy workaround, just copy the implementation from
firmware/stub/vboot_api_stub_stream.c, which translates from the new
streaming API to the old sector-based disk API.
BUG=chromium:403432
BRANCH=none
TEST=make runtests; passes.
CQ-DEPEND=CL:221992, CL:222885, CL:222945
Change-Id: I7437b489650c95c09ac68b67d4d86f9e15c2fa73
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222410
Reviewed-by: Daniel Ehrenberg <dehrenberg@chromium.org>
Diffstat (limited to 'tests/vboot_kernel_tests.c')
-rw-r--r-- | tests/vboot_kernel_tests.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c index 3712d0d3..0c26d212 100644 --- a/tests/vboot_kernel_tests.c +++ b/tests/vboot_kernel_tests.c @@ -153,6 +153,7 @@ static void ResetMocks(void) lkp.ending_lba = 1023; lkp.kernel_buffer = kernel_buffer; lkp.kernel_buffer_size = sizeof(kernel_buffer); + lkp.disk_handle = (VbExDiskHandle_t)1; memset(&kbh, 0, sizeof(kbh)); kbh.data_key.key_version = 2; @@ -162,7 +163,7 @@ static void ResetMocks(void) memset(&kph, 0, sizeof(kph)); kph.kernel_version = 1; kph.preamble_size = 4096 - kbh.key_block_size; - kph.body_signature.data_size = 70000; + kph.body_signature.data_size = 70144; kph.bootloader_address = 0xbeadd008; kph.bootloader_size = 0x1234; @@ -531,6 +532,12 @@ static void InvalidParamsTest(void) gpt_init_fail = 1; TEST_EQ(LoadKernel(&lkp, &cparams), VBERROR_NO_KERNEL_FOUND, "Bad GPT"); + + /* This causes the stream open call to fail */ + ResetMocks(); + lkp.disk_handle = NULL; + TEST_EQ(LoadKernel(&lkp, &cparams), VBERROR_INVALID_KERNEL_FOUND, + "Bad disk handle"); } static void LoadKernelTest(void) @@ -538,7 +545,9 @@ static void LoadKernelTest(void) uint32_t u; ResetMocks(); - TEST_EQ(LoadKernel(&lkp, &cparams), 0, "First kernel good"); + + u = LoadKernel(&lkp, &cparams); + TEST_EQ(u, 0, "First kernel good"); TEST_EQ(lkp.partition_number, 1, " part num"); TEST_EQ(lkp.bootloader_address, 0xbeadd008, " bootloader addr"); TEST_EQ(lkp.bootloader_size, 0x1234, " bootloader size"); @@ -689,6 +698,11 @@ static void LoadKernelTest(void) TEST_EQ(LoadKernel(&lkp, &cparams), VBERROR_INVALID_KERNEL_FOUND, "Kernel body offset"); + ResetMocks(); + kph.preamble_size += 65536; + TEST_EQ(LoadKernel(&lkp, &cparams), VBERROR_INVALID_KERNEL_FOUND, + "Kernel body offset huge"); + /* Check getting kernel load address from header */ ResetMocks(); kph.body_load_address = (size_t)kernel_buffer; @@ -709,7 +723,11 @@ static void LoadKernelTest(void) "Kernel too big for partition"); ResetMocks(); - disk_read_to_fail = 108; + kph.body_signature.data_size = 8192; + TEST_EQ(LoadKernel(&lkp, &cparams), 0, "Kernel tiny"); + + ResetMocks(); + disk_read_to_fail = 228; TEST_EQ(LoadKernel(&lkp, &cparams), VBERROR_INVALID_KERNEL_FOUND, "Fail reading kernel data"); |