From patchwork Wed Nov 3 15:09:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 516763 Delivered-To: patch@linaro.org Received: by 2002:adf:eccd:0:0:0:0:0 with SMTP id s13csp712315wro; Wed, 3 Nov 2021 08:09:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh+8FFuZbfcHszBqixmg6xmeMxb+lmhAOgHQI/oIUzBlS+QYneOgCLAGbyt61nM/aJqdZE X-Received: by 2002:a17:907:3f92:: with SMTP id hr18mr42971365ejc.348.1635952194316; Wed, 03 Nov 2021 08:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635952194; cv=none; d=google.com; s=arc-20160816; b=dDjqZxmnxJKOx1ihl1yQvSchtQUY6zZPGihyVD3Vvs55G+/8msjcD2uJf1ZMk3XbBr 2aBfyb0R4M7ecrLlSMR+w59Dz95LVw/rIuN/4WUAdReB6oitKN+RWWlbAWCmt+jsKuV5 sG7vuL4nd25dULi3SqXJEvBtm8+ftr/yZf0A8hEdik0uEMq4/gkA/YvlzRM+vXpOwVqu uPjG3+JEHrHj9H0yGPbfGBGy6PjUEGUQJ3HPcY0ztAXcxjRTgnGdhG3Em+IYJfbihbcU ZGfIXSCMHedfkcGjvAQtb5KOSmbpHoBhisEYBQNJ/oNy7BvJrhfUlZqXr+votMddobG4 oYvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=l00nRgvAwLslnvqOLPWwF4xGSyAWhlUOn79eLOKtOBQ=; b=kT+ydCzpeqYzU6y/YAxjJS7TMQVLQjRB66E+dWWTLV/rpcpUtmqyPFW8byk7e6X73q TNgtaAsSY97KwiZl5CF/QtvEwuDEfvlou6e8n9IWM+ip6jbYKP8BE2ds2G+0m/OUS8bN GNAlv7cKAdF2L9MNI2Ot6MI+mF9cHXDbvRoWMcWc7AoK3z0Po0v+2GjV1y/Ygc13XXNV /ZqD3fpAjnV0Z+UtRjVbuHUaLU8F/DCEQE+XfGYCycbvefl+4JQKYv3YvcmnBtBI5LxL dsyX6rMw0OLuJqLmEjqX35cs7zKHFldXzNmom5+Ggm3uTmbjfLO+P4wmGpv7jtoPAU0M +H8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ThSW7jX/"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id gn6si4053306ejc.196.2021.11.03.08.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 08:09:54 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ThSW7jX/"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 74B5B835B3; Wed, 3 Nov 2021 16:09:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ThSW7jX/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BB415835AF; Wed, 3 Nov 2021 16:09:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 98FD782DB4 for ; Wed, 3 Nov 2021 16:09:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x330.google.com with SMTP id z11-20020a1c7e0b000000b0030db7b70b6bso4887936wmc.1 for ; Wed, 03 Nov 2021 08:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=l00nRgvAwLslnvqOLPWwF4xGSyAWhlUOn79eLOKtOBQ=; b=ThSW7jX/YzAQpzTQemwCW4wTos6VYKctpmQQAw13xsmK9RMrGwhVOAKM7cPiS0qB6S F4nButwxClLIWbzPlNX5gFz4/rMYsZVx8lZ1/gHgb+OW2UpmcDaIsJPfnKwFzc7AGt+b j1zfJ47FDDm/1ZX+3lVMXZRnNRIHTsnltiVp56H7COeicHtsRC8K+hAH5zBkNCw4dAll A/vXRFBm5pSXtKEOJ7fuZJt8sIl+ZUT/Nq6duKasSRvfsmUjH96DYlrWl5IiukZpOnsI Sf7598da9Qn32PbbkvKPrWrtAmTjvFM5CKbjDMwH91ES9YuqeesdM+Y6FcJuK/jlFAv5 1hKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=l00nRgvAwLslnvqOLPWwF4xGSyAWhlUOn79eLOKtOBQ=; b=NpKjIpLBZ4pxVp9fPpxm/WlCQ6cRNtQHdwm86GfTm1oouchz2BEZHY8ns6qcB6ltHG V+LzOWAZUBYO+rQb136afXY9xHgUvgjzhTpEWcbaReqv6m+luH4eSC4etTsvlmYoTxgD nviOKkHaNaa9i6XPmZdVqGJQbcNR0TmY90WGsxyMzZwpNT3bXY9LjHgHp3iIzVIgMy8N 7FC+59Sl1TXvdioQQKBlP38ya0K9PvcrMmk/yk+hnUNvH1+viBXB9EWCBfIR1QA8y7rU 9fnjZquukjGANtmDXRRYvCR+Ee3ZWfkJ0eT8Lj+hpNdgGeVdcaNpvgruZW3RQdDgpz/b +PmQ== X-Gm-Message-State: AOAM533ndWvgT9+3EtUxUyRqzyEpLAHC55bkGRsDRl8k42LWwEn7kmUi RnlpclHZOTxuIw6vSm2jE3RQRpJopD7BLg== X-Received: by 2002:a1c:2386:: with SMTP id j128mr16183393wmj.8.1635952171121; Wed, 03 Nov 2021 08:09:31 -0700 (PDT) Received: from apalos.home ([2a02:587:4682:26e0:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id f19sm2094947wmq.34.2021.11.03.08.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 08:09:30 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: trini@konsulko.com, Ilias Apalodimas , Rick Chen , Sean Anderson , Simon Glass , Heinrich Schuchardt , Masahisa Kojima Subject: [PATCH 0/6 v4] TPM cleanups and MMIO driver Date: Wed, 3 Nov 2021 17:09:03 +0200 Message-Id: <20211103150910.69732-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi! This is the followup series on the TPM cleanup and driver additions. The major change since v3 [1] is that I implemented Simon's request and converted an existing driver using the API. We now have two consumers of the API, MMIO and SPI TPMs. It's worth noting that using the API reduces the code duplication in the SPI TPM driver a lot. I've tested the SPI TPM on an RPI4 with [2]. As far as I can tell everything seems to be working fine, including the EFI TCG2 protocol. The MMIO one was tested with QEMU and SWTPM [3] and I've added documentation on how to reproduce that. There was also a discussion on v2 [4] regarding the MMIO accesses and if we should convert those to a uclass. But the MMIO functions are just calling io(read|write), so after considering it for a while, I couldn't find any reasonable abstraction that would justify another uclass. [1] https://lore.kernel.org/u-boot/20210708082310.87540-1-ilias.apalodimas@linaro.org/ [2] https://buyzero.de/en/products/letstrust-hardware-tpm-trusted-platform-module [3] https://github.com/stefanberger/swtpm [4] https://lore.kernel.org/u-boot/CAPnjgZ1U6VgeOcTuy-G=nbYFTNnu_8MqGf-o6LF6ivk=TwE4iQ@mail.gmail.com/ Changes since v3: - Coverted SPI TPM to use the API as well - moved some log_info to log_debug - Added documentation on how to run QEMU and enabled TPM by default on arm qemu builds Changes since v2: - Add myself as a maintainer on TPM drivers Changes since v1: - split off the tis core code into a different file Ilias Apalodimas (6): tpm2: Introduce TIS tpm core tpm2: Add a TPMv2 MMIO TIS driver tpm: Use the new API on tpm2 spi driver configs: Enable tpmv2 mmio on qemu for arm/arm64 doc: qemu: Add instructions for swtpm usage MAINTAINERS: Add entry for TPM drivers MAINTAINERS | 5 + configs/qemu_arm64_defconfig | 2 + configs/qemu_arm_defconfig | 2 + doc/board/emulation/qemu-arm.rst | 25 ++ drivers/tpm/Kconfig | 9 + drivers/tpm/Makefile | 3 +- drivers/tpm/tpm2_tis_core.c | 523 +++++++++++++++++++++++++++++++ drivers/tpm/tpm2_tis_mmio.c | 152 +++++++++ drivers/tpm/tpm2_tis_spi.c | 440 ++------------------------ drivers/tpm/tpm_tis.h | 39 +++ include/tpm-v2.h | 1 + 11 files changed, 791 insertions(+), 410 deletions(-) create mode 100644 drivers/tpm/tpm2_tis_core.c create mode 100644 drivers/tpm/tpm2_tis_mmio.c -- 2.33.1