diff options
-rw-r--r-- | firmware/lib/vboot_api_kernel.c | 9 | ||||
-rw-r--r-- | firmware/lib/vboot_kernel.c | 20 |
2 files changed, 21 insertions, 8 deletions
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 898d9bea..c97caba7 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -638,8 +638,14 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams* cparams, p.shared_data_size = cparams->shared_data_size; p.gbb_data = cparams->gbb_data; p.gbb_size = cparams->gbb_size; + + /* + * this could be set to NULL, in which case the vboot header information + * about the load address and size will be used + */ p.kernel_buffer = kparams->kernel_buffer; p.kernel_buffer_size = kparams->kernel_buffer_size; + p.nv_context = &vnc; p.boot_flags = 0; if (shared->flags & VBSD_BOOT_DEV_SWITCH_ON) @@ -748,6 +754,9 @@ VbSelectAndLoadKernel_exit: /* Stop timer */ shared->timer_vb_select_and_load_kernel_exit = VbExGetTimer(); + kparams->kernel_buffer = p.kernel_buffer; + kparams->kernel_buffer_size = p.kernel_buffer_size; + VBDEBUG(("VbSelectAndLoadKernel() returning %d\n", (int)retval)); /* Pass through return value from boot path */ diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index 190dc1bf..44064b95 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -159,9 +159,7 @@ VbError_t LoadKernel(LoadKernelParams* params) { /* Sanity Checks */ if (!params || !params->bytes_per_lba || - !params->ending_lba || - !params->kernel_buffer || - !params->kernel_buffer_size) { + !params->ending_lba) { VBDEBUG(("LoadKernel() called with invalid params\n")); retval = VBERROR_INVALID_PARAMETER; goto LoadKernelExit; @@ -404,12 +402,18 @@ VbError_t LoadKernel(LoadKernelParams* params) { } body_offset_sectors = body_offset / blba; - /* Verify kernel body fits in the buffer */ body_sectors = (preamble->body_signature.data_size + blba - 1) / blba; - if (body_sectors * blba > params->kernel_buffer_size) { - VBDEBUG(("Kernel body doesn't fit in memory.\n")); - shpart->check_result = VBSD_LKP_CHECK_BODY_EXCEEDS_MEM; - goto bad_kernel; + if (!params->kernel_buffer) { + /* Get kernel load address and size from the header. */ + params->kernel_buffer = (void*) ((long)preamble->body_load_address); + params->kernel_buffer_size = body_sectors * blba; + } else { + /* Verify kernel body fits in the buffer */ + if (body_sectors * blba > params->kernel_buffer_size) { + VBDEBUG(("Kernel body doesn't fit in memory.\n")); + shpart->check_result = VBSD_LKP_CHECK_BODY_EXCEEDS_MEM; + goto bad_kernel; + } } /* Verify kernel body fits in the partition */ |