[SLOF] [PATCH v4 20/33] tpm2: prepare tpmhw_transmit for TPM2 commands

Stefan Berger stefanb at linux.vnet.ibm.com
Thu Dec 12 07:27:15 AEDT 2019


---
 lib/libtpm/tcgbios.c     | 10 +++++++++-
 lib/libtpm/tcgbios_int.h |  8 ++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
index af29406..6762bcc 100644
--- a/lib/libtpm/tcgbios.c
+++ b/lib/libtpm/tcgbios.c
@@ -120,7 +120,6 @@ tpm_simple_cmd(uint8_t locty, uint32_t ordinal, int param_size, uint16_t param,
 		uint16_t param;
 	} __attribute__((packed)) req = {
 		.trqh.totlen = cpu_to_be32(sizeof(req.trqh) + param_size),
-		.trqh.tag = cpu_to_be16(TPM_TAG_RQU_CMD),
 		.trqh.ordinal = cpu_to_be32(ordinal),
 	};
 	uint8_t obuffer[64];
@@ -128,6 +127,15 @@ tpm_simple_cmd(uint8_t locty, uint32_t ordinal, int param_size, uint16_t param,
 	uint32_t obuffer_len = sizeof(obuffer);
 	int ret;
 
+	switch (TPM_version) {
+	case TPM_VERSION_1_2:
+		req.trqh.tag = cpu_to_be16(TPM_TAG_RQU_CMD);
+		break;
+	case TPM_VERSION_2:
+		req.trqh.tag = cpu_to_be16(TPM2_ST_NO_SESSIONS);
+		break;
+	}
+
 	switch (param_size) {
 	case 2:
 		req.param = cpu_to_be16(param);
diff --git a/lib/libtpm/tcgbios_int.h b/lib/libtpm/tcgbios_int.h
index 39e1ea4..473de3a 100644
--- a/lib/libtpm/tcgbios_int.h
+++ b/lib/libtpm/tcgbios_int.h
@@ -195,4 +195,12 @@ struct tpm_rsp_getcap_buffersize {
 #define TPM_PPI_OP_SET_OWNERINSTALL_TRUE 8
 #define TPM_PPI_OP_SET_OWNERINSTALL_FALSE 9
 
+/****************************************************************
+ * TPM v2.0 hardware commands
+ ****************************************************************/
+
+/* TPM 2 command tags */
+#define TPM2_ST_NO_SESSIONS         0x8001
+#define TPM2_ST_SESSIONS            0x8002
+
 #endif /* TCGBIOS_INT_H */
-- 
2.17.1



More information about the SLOF mailing list