From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: u-boot@lists.denx.de
Cc: "Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Simon Glass" <sjg@chromium.org>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Eddie James" <eajames@linux.ibm.com>,
"Michal Suchanek" <msuchanek@suse.de>,
"Rasmus Villemoes" <rasmus.villemoes@prevas.dk>,
"Dzmitry Sankouski" <dsankouski@gmail.com>,
"Robert Marko" <robimarko@gmail.com>,
"Sean Anderson" <sean.anderson@seco.com>,
"Nikhil M Jain" <n-jain1@ti.com>,
"Abdellatif El Khlifi" <abdellatif.elkhlifi@arm.com>,
"Andrew Davis" <afd@ti.com>,
"Daniel Golle" <daniel@makrotopia.org>,
"Safae Ouajih" <souajih@baylibre.com>,
"Mattijs Korpershoek" <mkorpershoek@baylibre.com>,
"Pali Rohár" <pali@kernel.org>,
"Sughosh Ganu" <sughosh.ganu@linaro.org>,
"Roger Knecht" <rknecht@pm.me>,
"Steven Lawrance" <steven.lawrance@softathome.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Rui Miguel Silva" <rui.silva@linaro.org>,
"Stephen Carlson" <stcarlso@linux.microsoft.com>,
"Marek Vasut" <marex@denx.de>,
"Kautuk Consul" <kconsul@ventanamicro.com>,
"Leo Yu-Chi Liang" <ycliang@andestech.com>,
"Brandon Maier" <brandon.maier@collins.com>,
"Patrick Delaunay" <patrick.delaunay@foss.st.com>
Subject: [PATCH 9/9] tpm: Make 'tpm init' to call tpm_auto_start()
Date: Wed, 10 May 2023 10:43:57 +0300 [thread overview]
Message-ID: <20230510074359.2837818-9-ilias.apalodimas@linaro.org> (raw)
In-Reply-To: <20230510074359.2837818-1-ilias.apalodimas@linaro.org>
For a TPM device to be operational we need to initialize it and
perform its startup sequence. The 'tpm init' command currently calls
tpm_init() which ends up calling the ->open() per-device callback and
performs the initial hardware configuration as well as requesting
locality 0 for the caller. We recently added tpm_auto_start() though,
which automates the initialization process -- On top of that calling
tpm_init() on selftests is a bit problematic, since calling it twice
will return -EBUSY the second time although there is no actual problem
with the TPM or the software stack.
So let's wire up the 'tpm init' command and call tpm_auto_start() which
leaves the device in an operational state.
It's worth noting that calling tpm_init() only, doesn't allow a someone
to use the TPM since the startup sequence is mandatory. We keep
repeating the pattern of calling
- tpm_init
- tpm_startup
- tpm_self_test_full or tpm_continue_self_test
So we don't expect any regression or boot delays with the current
change.
While at it fix the identation of test_tpm_autostart() comments as well
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
cmd/tpm-common.c | 3 ++-
test/dm/tpm.c | 9 +++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/cmd/tpm-common.c b/cmd/tpm-common.c
index d0c63cadf413..9b1ad0b371df 100644
--- a/cmd/tpm-common.c
+++ b/cmd/tpm-common.c
@@ -11,6 +11,7 @@
#include <asm/unaligned.h>
#include <linux/string.h>
#include <tpm-common.h>
+#include <tpm_api.h>
#include "tpm-user-utils.h"
static struct udevice *tpm_dev;
@@ -364,7 +365,7 @@ int do_tpm_init(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
if (rc)
return rc;
- return report_return_code(tpm_init(dev));
+ return report_return_code(tpm_auto_start(dev));
}
int do_tpm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
diff --git a/test/dm/tpm.c b/test/dm/tpm.c
index 3defb3c3da1f..cde933ab2848 100644
--- a/test/dm/tpm.c
+++ b/test/dm/tpm.c
@@ -98,10 +98,11 @@ static int test_tpm_autostart(struct unit_test_state *uts,
if (reinit)
ut_assertok(tpm_init(dev));
- /*
- * tpm_auto_start will rerun tpm_init() if reinit, but handles the
- * -EBUSY return code internally.
- */
+
+ /*
+ * tpm_auto_start will rerun tpm_init() if reinit, but handles the
+ * -EBUSY return code internally.
+ */
ut_assertok(tpm_auto_start(dev));
return 0;
--
2.39.2
next prev parent reply other threads:[~2023-05-10 7:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 7:43 [PATCH 1/9] tpm: Fix spelling for tpmu_ha union Ilias Apalodimas
2023-05-10 7:43 ` [PATCH 2/9] tpm: sandbox: Update for needed TPM2 capabilities Ilias Apalodimas
2023-05-10 7:43 ` [PATCH 3/9] tpm: Support boot measurements Ilias Apalodimas
2023-05-10 7:43 ` [PATCH 4/9] bootm: Support boot measurement Ilias Apalodimas
2023-05-10 7:43 ` [PATCH 5/9] test: Add sandbox TPM " Ilias Apalodimas
2023-05-10 7:43 ` [PATCH 6/9] doc: Add measured boot documentation Ilias Apalodimas
2023-05-10 7:43 ` [PATCH 7/9] test: use a non system PCR for testing PCR extend Ilias Apalodimas
2023-05-10 14:31 ` Simon Glass
2023-05-10 15:26 ` Ilias Apalodimas
2023-05-10 20:46 ` Simon Glass
2023-05-10 7:43 ` [PATCH 8/9] test: Account PCR updates properly during testing Ilias Apalodimas
2023-05-10 14:31 ` Simon Glass
2023-05-10 15:25 ` Ilias Apalodimas
2023-05-10 20:46 ` Simon Glass
2023-05-10 7:43 ` Ilias Apalodimas [this message]
2023-05-10 14:31 ` [PATCH 9/9] tpm: Make 'tpm init' to call tpm_auto_start() Simon Glass
2023-05-10 15:32 ` Ilias Apalodimas
2023-05-10 15:49 ` Ilias Apalodimas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230510074359.2837818-9-ilias.apalodimas@linaro.org \
--to=ilias.apalodimas@linaro.org \
--cc=abdellatif.elkhlifi@arm.com \
--cc=afd@ti.com \
--cc=brandon.maier@collins.com \
--cc=daniel@makrotopia.org \
--cc=dsankouski@gmail.com \
--cc=eajames@linux.ibm.com \
--cc=kconsul@ventanamicro.com \
--cc=linus.walleij@linaro.org \
--cc=marex@denx.de \
--cc=mkorpershoek@baylibre.com \
--cc=msuchanek@suse.de \
--cc=n-jain1@ti.com \
--cc=pali@kernel.org \
--cc=patrick.delaunay@foss.st.com \
--cc=rasmus.villemoes@prevas.dk \
--cc=rknecht@pm.me \
--cc=robimarko@gmail.com \
--cc=rui.silva@linaro.org \
--cc=sean.anderson@seco.com \
--cc=sjg@chromium.org \
--cc=souajih@baylibre.com \
--cc=stcarlso@linux.microsoft.com \
--cc=steven.lawrance@softathome.com \
--cc=sughosh.ganu@linaro.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
--cc=ycliang@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).