summaryrefslogtreecommitdiff
path: root/firmware/lib20/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/lib20/misc.c')
-rw-r--r--firmware/lib20/misc.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/firmware/lib20/misc.c b/firmware/lib20/misc.c
index 89e46ec6..815d5ebe 100644
--- a/firmware/lib20/misc.c
+++ b/firmware/lib20/misc.c
@@ -27,7 +27,6 @@ int vb2_load_fw_keyblock(struct vb2_context *ctx)
struct vb2_keyblock *kb;
uint32_t block_size;
- uint32_t sec_version;
int rv;
vb2_workbuf_from_ctx(ctx, &wb);
@@ -78,15 +77,10 @@ int vb2_load_fw_keyblock(struct vb2_context *ctx)
if (rv)
return rv;
- /* Read the secure key version */
- rv = vb2_secdata_get(ctx, VB2_SECDATA_VERSIONS, &sec_version);
- if (rv)
- return rv;
-
/* Key version is the upper 16 bits of the composite firmware version */
if (kb->data_key.key_version > 0xffff)
return VB2_ERROR_FW_KEYBLOCK_VERSION_RANGE;
- if (kb->data_key.key_version < (sec_version >> 16))
+ if (kb->data_key.key_version < (sd->fw_version_secdata >> 16))
return VB2_ERROR_FW_KEYBLOCK_VERSION_ROLLBACK;
sd->fw_version = kb->data_key.key_version << 16;
@@ -140,7 +134,6 @@ int vb2_load_fw_preamble(struct vb2_context *ctx)
struct vb2_fw_preamble *pre;
uint32_t pre_size;
- uint32_t sec_version;
int rv;
vb2_workbuf_from_ctx(ctx, &wb);
@@ -184,11 +177,6 @@ int vb2_load_fw_preamble(struct vb2_context *ctx)
if (rv)
return rv;
- /* Read the secure key version */
- rv = vb2_secdata_get(ctx, VB2_SECDATA_VERSIONS, &sec_version);
- if (rv)
- return rv;
-
/*
* Firmware version is the lower 16 bits of the composite firmware
* version.
@@ -198,7 +186,7 @@ int vb2_load_fw_preamble(struct vb2_context *ctx)
/* Combine with the key version from vb2_load_fw_keyblock() */
sd->fw_version |= pre->firmware_version;
- if (sd->fw_version < sec_version)
+ if (sd->fw_version < sd->fw_version_secdata)
return VB2_ERROR_FW_PREAMBLE_VERSION_ROLLBACK;
/*
@@ -206,10 +194,11 @@ int vb2_load_fw_preamble(struct vb2_context *ctx)
* successfully booted the same slot last boot, roll forward the
* version in secure storage.
*/
- if (sd->fw_version > sec_version &&
+ if (sd->fw_version > sd->fw_version_secdata &&
sd->last_fw_slot == sd->fw_slot &&
sd->last_fw_result == VB2_FW_RESULT_SUCCESS) {
+ sd->fw_version_secdata = sd->fw_version;
rv = vb2_secdata_set(ctx, VB2_SECDATA_VERSIONS, sd->fw_version);
if (rv)
return rv;