[Skiboot] [PATCH v2 3/3] tpm_extendl: don't measure when no tpm is registered

Claudio Carvalho cclaudio at linux.vnet.ibm.com
Wed Nov 2 09:40:27 AEDT 2016


This fixes tpm_extendl() to measure only when the list of
registered tpms is not empty.

Fixes: 3837c6f0cf4cffb5de874413eed755c0c698b076
Signed-off-by: Claudio Carvalho <cclaudio at linux.vnet.ibm.com>
---
 libstb/status_codes.h |  1 +
 libstb/tpm_chip.c     | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libstb/status_codes.h b/libstb/status_codes.h
index e67c17b..4896132 100644
--- a/libstb/status_codes.h
+++ b/libstb/status_codes.h
@@ -31,6 +31,7 @@
 #define STB_MEASURE_FAILED		-200
 
 /* TPM */
+#define STB_NO_TPM_INITIALIZED	 300
 #define STB_TPM_OVERFLOW	-300
 #define STB_TPM_TIMEOUT	-301
 
diff --git a/libstb/tpm_chip.c b/libstb/tpm_chip.c
index 65ab290..3be323f 100644
--- a/libstb/tpm_chip.c
+++ b/libstb/tpm_chip.c
@@ -187,12 +187,12 @@ void tpm_init(void)
 
 	if (list_empty(&tpm_list))
 		/**
-		 * @fwts-label TPMNotInitialized
+		 * @fwts-label NoTPMRegistered
 		 * @fwts-advice No TPM chip has been initialized. We may not
 		 * have a compatible tpm driver or there is no tpm node in the
 		 * device tree with the expected bindings.
 		 */
-		prlog(PR_ERR, "TPM: no tpm chip has been initialized\n");
+		prlog(PR_ERR, "TPM: no tpm chip registered\n");
 
 }
 
@@ -234,6 +234,12 @@ int tpm_extendl(TPM_Pcr pcr,
 	measured = 0;
 	failed = 0;
 
+	if (list_empty(&tpm_list)) {
+		prlog(PR_NOTICE, "TPM: %s (pcr%d) not measured. No TPM "
+		      "registered/enabled\n", event_msg, pcr);
+		return STB_NO_TPM_INITIALIZED;
+	}
+
 	list_for_each(&tpm_list, tpm, link) {
 		if (!tpm->enabled)
 			continue;
-- 
1.9.1



More information about the Skiboot mailing list