From patchwork Thu Apr 2 16:52:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mauro S. M. Rodrigues" X-Patchwork-Id: 1265694 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48tTdx6tHkz9sQx for ; Fri, 3 Apr 2020 03:53:09 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48tTdx6XPkzDrT2 for ; Fri, 3 Apr 2020 03:53:09 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=maurosr@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48tTdv2DJWzDrFm for ; Fri, 3 Apr 2020 03:53:07 +1100 (AEDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 032GacjH181294 for ; Thu, 2 Apr 2020 12:53:04 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 304mcchvym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 02 Apr 2020 12:53:04 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 032GpE0D023591 for ; Thu, 2 Apr 2020 16:53:03 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma02wdc.us.ibm.com with ESMTP id 301x77aakg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 02 Apr 2020 16:53:03 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 032Gr2V150069950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Apr 2020 16:53:02 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D95B1112065; Thu, 2 Apr 2020 16:53:02 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79D1A112061; Thu, 2 Apr 2020 16:53:02 +0000 (GMT) Received: from localhost (unknown [9.85.171.202]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 2 Apr 2020 16:53:02 +0000 (GMT) From: "Mauro S. M. Rodrigues" To: skiboot@lists.ozlabs.org Date: Thu, 2 Apr 2020 13:52:05 -0300 Message-Id: <20200402165211.1618402-3-maurosr@linux.vnet.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200402165211.1618402-1-maurosr@linux.vnet.ibm.com> References: <20200402165211.1618402-1-maurosr@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-02_06:2020-04-02, 2020-04-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=1 bulkscore=0 mlxscore=0 adultscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004020131 Subject: [Skiboot] [PATCH 2/8] libstb/tss2: Add basic Build infrastructure for tss2 X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.ibm.com, nayna@linux.ibm.com Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Co-authored-by: Eric Richter Signed-off-by: Mauro S. M. Rodrigues --- libstb/Makefile.inc | 4 +++- libstb/tpm_chip.c | 20 ++++++++++++++++++++ libstb/tpm_chip.h | 4 ++++ libstb/tss2/Makefile.inc | 34 ++++++++++++++++++++++++++++++++++ libstb/tss2/netinet/in.h | 16 ++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 libstb/tss2/Makefile.inc create mode 100644 libstb/tss2/netinet/in.h diff --git libstb/Makefile.inc libstb/Makefile.inc index d0f9a8c021..de669887a5 100644 --- libstb/Makefile.inc +++ libstb/Makefile.inc @@ -14,10 +14,12 @@ 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 -$(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 libstb/tpm_chip.c libstb/tpm_chip.c index 12ba47f589..3bf2542dca 100644 --- libstb/tpm_chip.c +++ libstb/tpm_chip.c @@ -18,6 +18,26 @@ static struct list_head tpm_list = LIST_HEAD_INIT(tpm_list); +static struct tpm_dev *tpm_device; +static struct tpm_driver *tpm_driver; + +void tss_tpm_register(struct tpm_dev *dev, struct tpm_driver *driver) +{ + tpm_device = dev; + tpm_driver = driver; +} + + +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 libstb/tpm_chip.h libstb/tpm_chip.h index b2459e4f77..bf41114c3b 100644 --- libstb/tpm_chip.h +++ libstb/tpm_chip.h @@ -54,6 +54,10 @@ struct tpm_chip { /* TSS tweak */ typedef struct tpm_chip TpmTarget; +void tss_tpm_register(struct tpm_dev *dev, struct tpm_driver *driver); +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 libstb/tss2/Makefile.inc libstb/tss2/Makefile.inc new file mode 100644 index 0000000000..5d0fb8f5a9 --- /dev/null +++ libstb/tss2/Makefile.inc @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# 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 -DTPM_SKIBOOT +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 libstb/tss2/netinet/in.h libstb/tss2/netinet/in.h new file mode 100644 index 0000000000..ec39217388 --- /dev/null +++ libstb/tss2/netinet/in.h @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: Apache-2.0 +/* Copyright 2020 IBM Corp. */ + +#ifndef _NETINIT_IN_H +#define _NETINIT_IN_H + +//#pragma message "Implment in.h functions \n" + +#include + +#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 */