aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>2020-06-01 17:34:33 -0300
committerOliver O'Halloran <oohall@gmail.com>2020-10-01 13:42:40 +1000
commit48833b96098ce14260cdc9711b25ce424129f6a5 (patch)
tree8438c494ca3cb5479129daf509890dec9c4e8811
parent65192599d2364dbe0c078b6beb7810318dd9ce18 (diff)
downloadskiboot-48833b96098ce14260cdc9711b25ce424129f6a5.zip
skiboot-48833b96098ce14260cdc9711b25ce424129f6a5.tar.gz
skiboot-48833b96098ce14260cdc9711b25ce424129f6a5.tar.bz2
libstb/tss2: Add basic Build infrastructure for tss2
Co-authored-by: Eric Richter <erichte@linux.ibm.com> Signed-off-by: Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
-rw-r--r--libstb/Makefile.inc5
-rw-r--r--libstb/tpm_chip.c25
-rw-r--r--libstb/tpm_chip.h5
-rw-r--r--libstb/tss2/Makefile.inc34
-rw-r--r--libstb/tss2/netinet/in.h16
5 files changed, 84 insertions, 1 deletions
diff --git a/libstb/Makefile.inc b/libstb/Makefile.inc
index d0f9a8c..0b4715b 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 12ba47f..004750f 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 b2459e4..49bf2f5 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 0000000..15514ae
--- /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 0000000..d8f5c5c
--- /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 */