summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-08-30 21:05:38 -0600
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2022-09-03 16:59:05 +0300
commit5208ed187cb6314dc64657802e8e5bb5a5e3a7fb (patch)
tree6954b55d47f5b86d6cc4d3d6ac9bfc7d79187523 /lib
parent4c57ec76b7254cf1743748b70239bddf6100237a (diff)
tpm: Allow committing non-volatile data
Add an option to tell the TPM to commit non-volatile data immediately it is changed, rather than waiting until later. This is needed in some situations, since if the device reboots it may not write the data. Add definitions for the rest of the Cr50 commands while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/tpm-v2.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
index edee9854a7..697b982e07 100644
--- a/lib/tpm-v2.c
+++ b/lib/tpm-v2.c
@@ -704,3 +704,24 @@ u32 tpm2_report_state(struct udevice *dev, uint vendor_cmd, uint vendor_subcmd,
return 0;
}
+
+u32 tpm2_enable_nvcommits(struct udevice *dev, uint vendor_cmd,
+ uint vendor_subcmd)
+{
+ u8 command_v2[COMMAND_BUFFER_SIZE] = {
+ /* header 10 bytes */
+ tpm_u16(TPM2_ST_NO_SESSIONS), /* TAG */
+ tpm_u32(10 + 2), /* Length */
+ tpm_u32(vendor_cmd), /* Command code */
+
+ tpm_u16(vendor_subcmd),
+ };
+ int ret;
+
+ ret = tpm_sendrecv_command(dev, command_v2, NULL, NULL);
+ log_debug("ret=%s, %x\n", dev->name, ret);
+ if (ret)
+ return ret;
+
+ return 0;
+}