[Skiboot] [PATCH 2/8] libstb/tss2: Add basic Build infrastructure for tss2

Mauro S. M. Rodrigues maurosr at linux.vnet.ibm.com
Tue Jun 2 06:34:33 AEST 2020


Co-authored-by: Eric Richter <erichte at linux.ibm.com>
Signed-off-by: Mauro S. M. Rodrigues <maurosr at linux.vnet.ibm.com>
---
 libstb/Makefile.inc      |  5 ++++-
 libstb/tpm_chip.c        | 25 +++++++++++++++++++++++++
 libstb/tpm_chip.h        |  5 +++++
 libstb/tss2/Makefile.inc | 34 ++++++++++++++++++++++++++++++++++
 libstb/tss2/netinet/in.h | 16 ++++++++++++++++
 5 files changed, 84 insertions(+), 1 deletion(-)
 create mode 100644 libstb/tss2/Makefile.inc
 create mode 100644 libstb/tss2/netinet/in.h

diff --git a/libstb/Makefile.inc b/libstb/Makefile.inc
index d0f9a8c021..0b4715b04c 100644
--- a/libstb/Makefile.inc
+++ b/libstb/Makefile.inc
@@ -14,10 +14,13 @@ include $(SRC)/$(LIBSTB_DIR)/secvar/Makefile.inc
 include $(SRC)/$(LIBSTB_DIR)/drivers/Makefile.inc
 include $(SRC)/$(LIBSTB_DIR)/tss/Makefile.inc
 include $(SRC)/$(LIBSTB_DIR)/crypto/Makefile.inc
+include $(SRC)/$(LIBSTB_DIR)/tss2/Makefile.inc
 
 CPPFLAGS += -I$(SRC)/$(LIBSTB_DIR)/crypto/mbedtls/include
+CPPFLAGS += -I$(SRC)/$(LIBSTB_DIR)/ibmtpm20tss/utils
+CFLAGS += -DTPM_SKIBOOT
 
-$(LIBSTB): $(LIBSTB_OBJS:%=$(LIBSTB_DIR)/%) $(DRIVERS) $(TSS) $(SECVAR) $(CRYPTO)
+$(LIBSTB): $(LIBSTB_OBJS:%=$(LIBSTB_DIR)/%) $(DRIVERS) $(TSS) $(SECVAR) $(CRYPTO) $(TSS2)
 
 libstb/create-container: libstb/create-container.c libstb/container-utils.c
 	$(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) \
diff --git a/libstb/tpm_chip.c b/libstb/tpm_chip.c
index 12ba47f589..004750f5fb 100644
--- a/libstb/tpm_chip.c
+++ b/libstb/tpm_chip.c
@@ -18,6 +18,31 @@
 
 static struct list_head tpm_list = LIST_HEAD_INIT(tpm_list);
 
+static struct tpm_dev *tpm_device = NULL;
+static struct tpm_driver *tpm_driver = NULL;
+
+void tss_tpm_register(struct tpm_dev *dev, struct tpm_driver *driver)
+{
+	tpm_device = dev;
+	tpm_driver = driver;
+}
+
+void tss_tpm_unregister(void)
+{
+	tpm_device = NULL;
+	tpm_driver = NULL;
+}
+
+struct tpm_dev* tpm_get_device(void)
+{
+	return tpm_device;
+}
+
+struct tpm_driver* tpm_get_driver(void)
+{
+	return tpm_driver;
+}
+
 #ifdef STB_DEBUG
 static void tpm_print_pcr(struct tpm_chip *tpm, TPM_Pcr pcr, TPM_Alg_Id alg,
 			  size_t size)
diff --git a/libstb/tpm_chip.h b/libstb/tpm_chip.h
index b2459e4f77..49bf2f5523 100644
--- a/libstb/tpm_chip.h
+++ b/libstb/tpm_chip.h
@@ -54,6 +54,11 @@ struct tpm_chip {
 /* TSS tweak */
 typedef struct tpm_chip TpmTarget;
 
+void tss_tpm_register(struct tpm_dev *dev, struct tpm_driver *driver);
+void tss_tpm_unregister(void);
+struct tpm_dev* tpm_get_device(void);
+struct tpm_driver* tpm_get_driver(void);
+
 /*
  * Register a tpm chip by binding the driver to dev.
  * Event log is also registered by this function.
diff --git a/libstb/tss2/Makefile.inc b/libstb/tss2/Makefile.inc
new file mode 100644
index 0000000000..15514ae099
--- /dev/null
+++ b/libstb/tss2/Makefile.inc
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+# Copyright 2020 IBM Corp
+# -*-Makefile-*-
+
+LIBSTB_DIR = libstb
+TSS2_DIR = $(LIBSTB_DIR)/tss2
+IBMTSS_DIR = $(TSS2_DIR)/ibmtpm20tss/utils
+
+SUBDIRS += $(TSS2_DIR) $(IBMTSS_DIR)
+
+CPPFLAGS += -I$(SRC)/$(LIBSTB_DIR)
+CPPFLAGS += -I$(SRC)/$(TSS2_DIR)
+CPPFLAGS += -I$(SRC)/$(IBMTSS_DIR)
+
+TSS2LIB_SRCS = tssprint.c tssprintcmd.c tssmarshal.c Unmarshal.c Commands.c
+TSS2LIB_SRCS += CommandAttributeData.c tssresponsecode.c tssccattributes.c
+
+TSS2_SRCS = $(addprefix ibmtpm20tss/utils/,$(TSS2LIB_SRCS))
+
+TSS2_OBJS = $(TSS2_SRCS:%.c=%.o)
+
+CFLAGS_$(TSS2_DIR)/ = -DTPM_POSIX -DTPM_TPM20
+CFLAGS_$(TSS2_DIR)/ += -DTPM_NOSOCKET -DTPM_TSS_NODEPRECATED
+CFLAGS_$(TSS2_DIR)/ += -DTPM_TSS_NOECC -DTPM_TSS_NORSA -DTPM_TSS_NOCRYPTO
+CFLAGS_$(TSS2_DIR)/ += -DTPM_TSS_NOFILE -DTPM_TSS_NOENV -DTPM_TSS_NOCMDCHECK
+
+CFLAGS_$(IBMTSS_DIR)/ = $(CFLAGS_$(TSS2_DIR)/)
+
+CFLAGS_SKIP_$(TSS2_DIR)/ = -Wsuggest-attribute=const
+CFLAGS_SKIP_$(IBMTSS_DIR)/ = $(CFLAGS_SKIP_$(TSS2_DIR)/)
+
+TSS2 = $(TSS2_DIR)/built-in.a
+
+$(TSS2): $(TSS2_OBJS:%=$(TSS2_DIR)/%)
diff --git a/libstb/tss2/netinet/in.h b/libstb/tss2/netinet/in.h
new file mode 100644
index 0000000000..d8f5c5cc4e
--- /dev/null
+++ b/libstb/tss2/netinet/in.h
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 
+/* Copyright 2020 IBM Corp. */
+
+#ifndef _NETINIT_IN_H
+#define _NETINIT_IN_H
+
+//#pragma message "Implment in.h functions \n"
+
+#include <include/types.h>
+
+#define htonl(x) cpu_to_be32(x)
+#define ntohl(x) be32_to_cpu(x)
+#define htons(x) cpu_to_be16(x)
+#define ntohs(x) be16_to_cpu(x)
+
+#endif /* _NETINIT_IN_H */
-- 
2.26.2



More information about the Skiboot mailing list