summaryrefslogtreecommitdiff
path: root/drivers/tpm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-07-18 23:18:02 +0300
committerSimon Glass <sjg@chromium.org>2021-08-01 18:05:24 +0300
commit0c0ddada656f9d642a5c3904bc225b2b4fb49fe4 (patch)
treed8ce6c503940a76519dc7f17f8ed0a45e49a8532 /drivers/tpm
parent46aed06cb7bbdc0e01c6c43a5d446d12e75e62b4 (diff)
downloadu-boot-0c0ddada656f9d642a5c3904bc225b2b4fb49fe4.tar.xz
sandbox: tpm: Track whether the state is valid
Add checking as to whether the current TPM state is valid, so we can implement reading/writing the state. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/tpm')
-rw-r--r--drivers/tpm/tpm2_tis_sandbox.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c
index 5e0bd30469..c287ca2278 100644
--- a/drivers/tpm/tpm2_tis_sandbox.c
+++ b/drivers/tpm/tpm2_tis_sandbox.c
@@ -49,6 +49,7 @@ static const u8 sandbox_extended_once_pcr[] = {
* Information about our TPM emulation. This is preserved in the sandbox
* state file if enabled.
*
+ * @valid: true if this is valid (only used in s_state)
* @init_done: true if open() has been called
* @startup_done: true if TPM2_CC_STARTUP has been processed
* @tests_done: true if TPM2_CC_SELF_TEST has be processed
@@ -62,6 +63,7 @@ static const u8 sandbox_extended_once_pcr[] = {
* @nvdata: non-volatile data, used to store important things for the platform
*/
struct sandbox_tpm2 {
+ bool valid;
/* TPM internal states */
bool init_done;
bool startup_done;
@@ -73,6 +75,8 @@ struct sandbox_tpm2 {
u32 pcr_extensions[SANDBOX_TPM_PCR_NB];
};
+static struct sandbox_tpm2 s_state, *g_state;
+
/*
* Check the tag validity depending on the command (authentication required or
* not). If authentication is required, check it is valid. Update the auth
@@ -606,11 +610,13 @@ static int sandbox_tpm2_probe(struct udevice *dev)
/* Use the TPM v2 stack */
priv->version = TPM_V2;
- memset(tpm, 0, sizeof(*tpm));
-
priv->pcr_count = 32;
priv->pcr_select_min = 2;
+ if (s_state.valid)
+ memcpy(tpm, &s_state, sizeof(*tpm));
+ g_state = tpm;
+
return 0;
}