diff mbox

tpm2-cmd: try full selftest once if continue selftest failed

Message ID 20171222135610.7056-1-Alexander.Steffen@infineon.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Alexander Steffen Dec. 22, 2017, 1:56 p.m. UTC
If the usual approach of triggering only the missing selftests failed, give
the TPM another chance by requesting all selftests once.

With the current implementation, this will only help for TPMs that then
choose to run the selftests synchronously and return the selftest result.
There is no retry loop that again polls a TPM returning TPM_RC_TESTING in
this case.

Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
---
Patch depends on https://patchwork.kernel.org/patch/10105483/

 drivers/char/tpm/tpm2-cmd.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Jarkko Sakkinen Jan. 18, 2018, 6:46 p.m. UTC | #1
On Fri, Dec 22, 2017 at 02:56:10PM +0100, Alexander Steffen wrote:
> If the usual approach of triggering only the missing selftests failed, give
> the TPM another chance by requesting all selftests once.
> 
> With the current implementation, this will only help for TPMs that then
> choose to run the selftests synchronously and return the selftest result.
> There is no retry loop that again polls a TPM returning TPM_RC_TESTING in
> this case.
> 
> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> ---
> Patch depends on https://patchwork.kernel.org/patch/10105483/

NAK because of dependency.

/Jarkko
diff mbox

Patch

diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index c17e753..b5c34d8 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -871,6 +871,14 @@  static int tpm2_do_selftest(struct tpm_chip *chip)
 		tpm_msleep(delay_msec);
 	}
 
+	if (rc != TPM2_RC_SUCCESS) {
+		cmd.header.in = tpm2_selftest_header;
+		cmd.params.selftest_in.full_test = 1;
+
+		rc = tpm_transmit_cmd(chip, NULL, &cmd, TPM2_SELF_TEST_IN_SIZE,
+				      0, 0, "full selftest");
+	}
+
 	return rc;
 }