summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2020-02-13 17:13:04 +0800
committerCommit Bot <commit-bot@chromium.org>2020-02-19 10:29:53 +0000
commit83ab1908e8173cddc8405a341fe1dc79a2c8d911 (patch)
tree3bafb48b6bfd0ee691d5b28f80894b7ea2e61f0f /firmware
parent414f0078d2c57eb0bf6334d0b7486e1ebb36a499 (diff)
downloadvboot-83ab1908e8173cddc8405a341fe1dc79a2c8d911.tar.gz
vboot: use vboot2 for storing kernel rollback versions
Migrate to using vboot2 shared data fields for storing kernel rollback versions: kernel_version_tpm_start(1) --> kernel_version_secdata(2) kernel_version_tpm(1) --> kernel_version(2) kernel_version_lowest(1) --> [removed] Also remove VBSD from tests which no longer need it. BUG=b:124141368, chromium:1038260 TEST=make clean && make runtests BRANCH=none Change-Id: I26c2ccede5fba52e1477b625ef5fc6181f60aadf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2053179 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/lib/vboot_api_kernel.c17
-rw-r--r--firmware/lib/vboot_kernel.c10
-rw-r--r--firmware/lib20/api_kernel.c3
3 files changed, 14 insertions, 16 deletions
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index e2c1a6c1..72224e19 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -168,7 +168,6 @@ static int vb2_reset_nv_requests(struct vb2_context *ctx)
vb2_error_t VbBootNormal(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
- VbSharedDataHeader *shared = sd->vbsd;
uint32_t max_rollforward = vb2_nv_get(ctx,
VB2_NV_KERNEL_MAX_ROLLFORWARD);
@@ -203,20 +202,20 @@ vb2_error_t VbBootNormal(struct vb2_context *ctx)
* version to less than the version currently in the TPM. That is,
* we're limiting rollforward, not allowing rollback.
*/
- if (max_rollforward < shared->kernel_version_tpm_start)
- max_rollforward = shared->kernel_version_tpm_start;
+ if (max_rollforward < sd->kernel_version_secdata)
+ max_rollforward = sd->kernel_version_secdata;
- if (shared->kernel_version_tpm > max_rollforward) {
+ if (sd->kernel_version > max_rollforward) {
VB2_DEBUG("Limiting TPM kernel version roll-forward "
"to %#x < %#x\n",
- max_rollforward, shared->kernel_version_tpm);
+ max_rollforward, sd->kernel_version);
- shared->kernel_version_tpm = max_rollforward;
+ sd->kernel_version = max_rollforward;
}
- if (shared->kernel_version_tpm > shared->kernel_version_tpm_start) {
+ if (sd->kernel_version > sd->kernel_version_secdata) {
vb2_secdata_kernel_set(ctx, VB2_SECDATA_KERNEL_VERSIONS,
- shared->kernel_version_tpm);
+ sd->kernel_version);
}
return rv;
@@ -381,6 +380,8 @@ vb2_error_t VbSelectAndLoadKernel(struct vb2_context *ctx,
/* Translate vboot2 flags and fields into vboot1. */
if (sd->flags & VB2_SD_FLAG_KERNEL_SIGNED)
sd->vbsd->flags |= VBSD_KERNEL_KEY_VERIFIED;
+ sd->vbsd->kernel_version_tpm_start = sd->kernel_version_secdata;
+ sd->vbsd->kernel_version_tpm = sd->kernel_version;
return rv;
}
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index 722b74de..8118599d 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -439,7 +439,6 @@ vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_workbuf wb;
- VbSharedDataHeader *shared = sd->vbsd;
VbSharedDataKernelCall shcall;
int found_partitions = 0;
uint32_t lowest_version = LOWEST_TPM_VERSION;
@@ -543,7 +542,7 @@ vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params)
kernel_subkey,
lpflags,
params,
- shared->kernel_version_tpm,
+ sd->kernel_version,
shpart,
&wb);
VbExStreamClose(stream);
@@ -611,7 +610,7 @@ vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params)
* Otherwise, we'll check all the other headers to see if they
* contain a newer key.
*/
- if (shpart->combined_version == shared->kernel_version_tpm) {
+ if (shpart->combined_version == sd->kernel_version) {
VB2_DEBUG("Same kernel version\n");
break;
}
@@ -625,7 +624,6 @@ gpt_done:
if (params->partition_number > 0) {
VB2_DEBUG("Good partition %d\n", params->partition_number);
shcall.check_result = VBSD_LKC_CHECK_GOOD_PARTITION;
- shared->kernel_version_lowest = lowest_version;
/*
* Sanity check - only store a new TPM version if we found one.
* If lowest_version is still at its initial value, we didn't
@@ -633,8 +631,8 @@ gpt_done:
* didn't look.
*/
if (lowest_version != LOWEST_TPM_VERSION &&
- lowest_version > shared->kernel_version_tpm)
- shared->kernel_version_tpm = lowest_version;
+ lowest_version > sd->kernel_version)
+ sd->kernel_version = lowest_version;
/* Success! */
rv = VB2_SUCCESS;
diff --git a/firmware/lib20/api_kernel.c b/firmware/lib20/api_kernel.c
index 1e96f281..8b146093 100644
--- a/firmware/lib20/api_kernel.c
+++ b/firmware/lib20/api_kernel.c
@@ -72,8 +72,7 @@ vb2_error_t vb2api_kernel_phase1(struct vb2_context *ctx)
/* Read kernel version from secdata. */
sd->kernel_version_secdata =
vb2_secdata_kernel_get(ctx, VB2_SECDATA_KERNEL_VERSIONS);
- sd->vbsd->kernel_version_tpm = sd->kernel_version_secdata;
- sd->vbsd->kernel_version_tpm_start = sd->kernel_version_secdata;
+ sd->kernel_version = sd->kernel_version_secdata;
/* Find the key to use to verify the kernel keyblock */
if ((ctx->flags & VB2_CONTEXT_RECOVERY_MODE)) {