Message ID | 20211102152056.241769-4-amirmizi6@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add tpm i2c ptp driver | expand |
On Tue, 2021-11-02 at 17:20 +0200, amirmizi6@gmail.com wrote: > From: Amir Mizinski <amirmizi6@gmail.com> > > Add a condition to enable communication with the TPM while the TPM is in > firmware update mode. > In such a case if power was cut during the TPM firmware update, the driver > should ignore the "selftest" command return code (TPM2_RC_UPGRADE or > TPM2_RC_COMMAND_CODE) and skip the rest of the TPM initialization > sequence. > > Suggested-by: Benoit Houyere <benoit.houyere@st.com> > Signed-off-by: Amir Mizinski <amirmizi6@gmail.com> This is a half-baked handling of the FW upgrade mode. There's another patch in progress that aims to do proper handling for it: https://lore.kernel.org/linux-integrity/20210930160241.9691-1-borysmn@axis.com/ I CC'd Borys for further comments/discussion. /Jarkko
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index a25815a..c2b541d 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -729,6 +729,10 @@ int tpm2_auto_startup(struct tpm_chip *chip) goto out; rc = tpm2_do_selftest(chip); + + if (rc == TPM2_RC_UPGRADE || rc == TPM2_RC_COMMAND_CODE) + return 0; + if (rc && rc != TPM2_RC_INITIALIZE) goto out; diff --git a/include/linux/tpm.h b/include/linux/tpm.h index aa11fe3..c5bf934 100644 --- a/include/linux/tpm.h +++ b/include/linux/tpm.h @@ -207,6 +207,7 @@ enum tpm2_return_codes { TPM2_RC_INITIALIZE = 0x0100, /* RC_VER1 */ TPM2_RC_FAILURE = 0x0101, TPM2_RC_DISABLED = 0x0120, + TPM2_RC_UPGRADE = 0x012D, TPM2_RC_COMMAND_CODE = 0x0143, TPM2_RC_TESTING = 0x090A, /* RC_WARN */ TPM2_RC_REFERENCE_H0 = 0x0910,