summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2021-05-05 11:51:37 -0700
committerCommit Bot <commit-bot@chromium.org>2021-05-10 19:35:48 +0000
commit47ab1d3018323a28217d7d52a48dcbe51b9ec93f (patch)
tree796ee98aa518b7433ee9228ce1fd3c044c74a635
parent0902a08d74f090b747f59de616abfdf2131b1ae3 (diff)
downloadvboot-47ab1d3018323a28217d7d52a48dcbe51b9ec93f.tar.gz
vboot: Add vb2api_secdata_fwmp_create()
This commit adds a method to create an empty Firmware Management Parameters (FWMP) object in secure storage context. This can be used to initialize the FWMP space just after it's been created by firmware. BUG=b:184677625 BRANCH=None TEST=With other changes in coreboot to create and write the FWMP space, `emerge-keeby coreboot`. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I614975609a44ec18ff018970056e6e45e68265ed Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2875533 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--firmware/2lib/2secdata_fwmp.c19
-rw-r--r--firmware/2lib/include/2api.h9
2 files changed, 28 insertions, 0 deletions
diff --git a/firmware/2lib/2secdata_fwmp.c b/firmware/2lib/2secdata_fwmp.c
index a28b5bbf..cec24813 100644
--- a/firmware/2lib/2secdata_fwmp.c
+++ b/firmware/2lib/2secdata_fwmp.c
@@ -60,6 +60,25 @@ vb2_error_t vb2api_secdata_fwmp_check(struct vb2_context *ctx, uint8_t *size)
return VB2_SUCCESS;
}
+uint32_t vb2api_secdata_fwmp_create(struct vb2_context *ctx)
+{
+ struct vb2_secdata_fwmp *sec = (void *)&ctx->secdata_fwmp;
+
+ /* Clear the entire struct */
+ memset(sec, 0, sizeof(*sec));
+
+ /* Set to current version */
+ sec->struct_version = VB2_SECDATA_FWMP_VERSION;
+
+ /* Set the structure size */
+ sec->struct_size = sizeof(*sec);
+
+ /* Calculate initial CRC */
+ sec->crc8 = vb2_secdata_fwmp_crc(sec);
+
+ return sizeof(*sec);
+}
+
vb2_error_t vb2_secdata_fwmp_init(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index bd3b05f1..fb8bc51b 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -578,6 +578,15 @@ uint32_t vb2api_secdata_kernel_create(struct vb2_context *ctx);
uint32_t vb2api_secdata_kernel_create_v0(struct vb2_context *ctx);
/**
+ * Create an empty Firmware Management Parameters (FWMP) in secure storage
+ * context.
+ *
+ * @param ctx Context pointer
+ * @return size of created FWMP secure storage data in bytes
+ */
+uint32_t vb2api_secdata_fwmp_create(struct vb2_context *ctx);
+
+/**
* Check the validity of firmware management parameters (FWMP) space.
*
* Checks size, version, and CRC. If the struct size is larger than the size