diff options
author | Joel Kitching <kitching@google.com> | 2021-04-22 21:03:35 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-15 19:35:54 +0000 |
commit | 43fa783cbf6014d23d8b23b5eb7b4e63b17864ec (patch) | |
tree | 31102ed2b9c528accadbc35358eb6031ff3c1fbf /firmware | |
parent | 39ea3ade28b733521b480da161c61848764a3096 (diff) | |
download | vboot-43fa783cbf6014d23d8b23b5eb7b4e63b17864ec.tar.gz |
vboot/vboot_kernel: pass VbDiskInfo into LoadKernel
Pass VbDiskInfo struct into LoadKernel, rather than copying all
of its members into LoadKernelParams. Remove the unused members
from LoadKernelParams.
This CL is part of a series to merge vboot1 and vboot2.0
kernel verification code; see b/181739551.
BUG=b:181739551
TEST=make clean && make runtests
BRANCH=none
Signed-off-by: Joel Kitching <kitching@google.com>
Change-Id: I60957426388c88b16e570b717addb5eaf65b5e4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2846281
Reviewed-by: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/lib/include/load_kernel_fw.h | 15 | ||||
-rw-r--r-- | firmware/lib/vboot_api_kernel.c | 12 | ||||
-rw-r--r-- | firmware/lib/vboot_kernel.c | 18 |
3 files changed, 15 insertions, 30 deletions
diff --git a/firmware/lib/include/load_kernel_fw.h b/firmware/lib/include/load_kernel_fw.h index 9e4db8e6..b4661c3a 100644 --- a/firmware/lib/include/load_kernel_fw.h +++ b/firmware/lib/include/load_kernel_fw.h @@ -15,26 +15,14 @@ struct vb2_context; /* Interface provided by verified boot library to BDS */ -/* Boot flags for LoadKernel().boot_flags */ -/* GPT is external */ -#define BOOT_FLAG_EXTERNAL_GPT (0x04ULL) - typedef struct LoadKernelParams { /* Inputs to LoadKernel() */ /* Disk handle for current device */ VbExDiskHandle_t disk_handle; - /* Bytes per lba sector on current device */ - uint64_t bytes_per_lba; - /* Number of LBA-addressable sectors on the main device */ - uint64_t streaming_lba_count; - /* Random-access GPT size */ - uint64_t gpt_lba_count; /* Destination buffer for kernel (normally at 0x100000) */ void *kernel_buffer; /* Size of kernel buffer in bytes */ uint64_t kernel_buffer_size; - /* Boot flags */ - uint64_t boot_flags; /* * Outputs from LoadKernel(); valid only if LoadKernel() returns @@ -60,6 +48,7 @@ typedef struct LoadKernelParams { * * Returns VB2_SUCCESS if successful. If unsuccessful, returns an error code. */ -vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params); +vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params, + VbDiskInfo *disk_info); #endif /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */ diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 5451033a..f1e191a1 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -91,20 +91,14 @@ vb2_error_t VbTryLoadKernel(struct vb2_context *ctx, uint32_t get_info_flags) disk_info[i].flags); continue; } + lkp.disk_handle = disk_info[i].handle; - lkp.bytes_per_lba = disk_info[i].bytes_per_lba; - lkp.gpt_lba_count = disk_info[i].lba_count; - lkp.streaming_lba_count = disk_info[i].streaming_lba_count - ?: lkp.gpt_lba_count; - lkp.boot_flags |= disk_info[i].flags & VB_DISK_FLAG_EXTERNAL_GPT - ? BOOT_FLAG_EXTERNAL_GPT : 0; - - vb2_error_t new_rv = LoadKernel(ctx, &lkp); + vb2_error_t new_rv = LoadKernel(ctx, &lkp, &disk_info[i]); VB2_DEBUG("LoadKernel() = %#x\n", new_rv); /* Stop now if we found a kernel. */ if (VB2_SUCCESS == new_rv) { - VbExDiskFreeInfo(disk_info, lkp.disk_handle); + VbExDiskFreeInfo(disk_info, disk_info[i].handle); return VB2_SUCCESS; } diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index 53e8b129..75b40c4e 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -456,7 +456,8 @@ static vb2_error_t vb2_load_partition( return VB2_SUCCESS; } -vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) +vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params, + VbDiskInfo *disk_info) { struct vb2_shared_data *sd = vb2_get_sd(ctx); int found_partitions = 0; @@ -471,12 +472,13 @@ vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) /* Read GPT data */ GptData gpt; - gpt.sector_bytes = (uint32_t)params->bytes_per_lba; - gpt.streaming_drive_sectors = params->streaming_lba_count; - gpt.gpt_drive_sectors = params->gpt_lba_count; - gpt.flags = params->boot_flags & BOOT_FLAG_EXTERNAL_GPT + gpt.sector_bytes = (uint32_t)disk_info->bytes_per_lba; + gpt.streaming_drive_sectors = disk_info->streaming_lba_count + ?: disk_info->lba_count; + gpt.gpt_drive_sectors = disk_info->lba_count; + gpt.flags = disk_info->flags & VB_DISK_FLAG_EXTERNAL_GPT ? GPT_FLAG_EXTERNAL : 0; - if (AllocAndReadGptData(params->disk_handle, &gpt)) { + if (AllocAndReadGptData(disk_info->handle, &gpt)) { VB2_DEBUG("Unable to read GPT data\n"); goto gpt_done; } @@ -501,7 +503,7 @@ vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) /* Set up the stream */ VbExStream_t stream = NULL; - if (VbExStreamOpen(params->disk_handle, + if (VbExStreamOpen(disk_info->handle, part_start, part_size, &stream)) { VB2_DEBUG("Partition error getting stream.\n"); VB2_DEBUG("Marking kernel as invalid.\n"); @@ -590,7 +592,7 @@ vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) gpt_done: /* Write and free GPT data */ - WriteAndFreeGptData(params->disk_handle, &gpt); + WriteAndFreeGptData(disk_info->handle, &gpt); /* Handle finding a good partition */ if (params->partition_number > 0) { |