From patchwork Mon Jul 4 13:34:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 587139 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1ec:0:0:0:0 with SMTP id 12csp839341map; Mon, 4 Jul 2022 06:35:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u7IvM6Sbw0TuAiu3SO0eL3dnFQI/HBEFVFmx3vTI0ry2CUup2EDVrC1f7Dm0NYk0V4jYQp X-Received: by 2002:a2e:a4cc:0:b0:25a:7c00:618f with SMTP id p12-20020a2ea4cc000000b0025a7c00618fmr17259045ljm.82.1656941731365; Mon, 04 Jul 2022 06:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656941731; cv=none; d=google.com; s=arc-20160816; b=s15+wrE7IPFlsRX6pXCVYzNyMDPfe2oZKOHgjQBu/mE0egxVNdjDLK0h63yWpmsINn Y4TxzqsydiRVGsBH3kAF0efRr+GJLl0K7Dt/JOvznRtJA/Jk1jzxvj1iM7tC2sB8puVE +3UNTWsw1GhZAtkWAvCHt4EvEEq5LMfVn5kA7hD/r3KCIu6L8YRLMe7Ofl4VtqMF8s4X 6yhSlLnZCNoKz8v64rJoESJMtRp8wCBtX8qm5QtE+Uma7WRFYDzOY8a/yko30kosVHMD TmVGuEdFE2wk0+IuS3zKP4ne+UHR8UPvfGabvLZ6e+6YKArcqvQJRLearuqgPLpslLAF rTYw== 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; bh=L8v2/5HwPCDJSQdKIUnn4VgzHx3U8cjM55AjJuGSIvM=; b=Gx2qoYwKpnBEuUpJV7bekF+yy/a0B42X0tJ/QJ3JzaEy3JtN+KxyeGjPF5fpXF5MBT Mj0MB1c0i5URw5cDyxGcQge7wK2zAV228S681LcafM5MRMPT7ppL4xoUP8+WVlLONl0q shNZoVG6gEg3E0TyuUmeKuWf2Y/gtCBt8tSjbRT/YE1RIDhjpSul8JrPrUPFANXcQ8kA OjJFK1rMx5iA6e/JcLWYnTnRlvGtnTyk5m8/sMIo0sA7WGD+NGhdzOFfqXukxCut9+xI TzoWu6MuzT+rpeeLT4Y/IPm73CyO3SKjVfNMM+t4XJu/NJfnzelu5+lqW8TarXXYoyV0 Y/6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id p6-20020a056512234600b0047956678e30si3854979lfu.379.2022.07.04.06.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 06:35:31 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (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 0DEE6843C1; Mon, 4 Jul 2022 15:35:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 4A90C820E8; Mon, 4 Jul 2022 15:35:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id ACE72844A2 for ; Mon, 4 Jul 2022 15:35:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5A9C723A; Mon, 4 Jul 2022 06:35:12 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 643B73F66F; Mon, 4 Jul 2022 06:35:10 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Tom Rini Subject: [PATCH v6 0/7] tpm: rng: Move TPM RNG functionality to driver model Date: Mon, 4 Jul 2022 19:04:37 +0530 Message-Id: <20220704133444.1110715-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean The TPM device provides the random number generator(RNG) functionality, whereby sending a command to the TPM device results in the TPM device responding with random bytes. There was a discussion on the mailing list earlier[1], where it was explained that platforms with a TPM device can install the EFI_RNG_PROTOCOL for getting the random bytes instead of populating the dtb with the kaslr-seed property. That would make it possible to measure the dtb. The TPM uclass driver adds the RNG child device as part of it's post_probe function. Some additional changes have also been made to facilitate the use of the RNG devices, including extending the 'rng' command to take the RNG device as one of the command-line parameters. This series depends on a patch[2] from Simon Glass for moving the TPM device version detection functions to the tpm_api.h header as static inline functions. These patches were under discussion earlier, specifically the patch to add the RNG functionality under the TPM device as a child, either through manual binding or through the device tree. Ilias had commented on the discussion last[3]. The discussion can be resumed through this version. I have dropped certain patches which were changing some of the TPM API functions to return an int instead of the current u32. These patches have been dropped due to review comments from Simon[4]. This work can be taken up separately, if desired. [1] - https://lore.kernel.org/u-boot/20220103120738.47835-1-ilias.apalodimas@linaro.org/ [2] - https://lore.kernel.org/u-boot/20220301001125.1554442-2-sjg@chromium.org/T/#u [3] - https://lists.denx.de/pipermail/u-boot/2022-April/481708.html [4] - https://lists.denx.de/pipermail/u-boot/2022-March/477883.html Simon Glass (1): tpm: Export the TPM-version functions Sughosh Ganu (6): tpm: rng: Add driver model interface for TPM RNG device tpm: Add the RNG child device cmd: rng: Add support for selecting RNG device cmd: rng: Use a statically allocated array for random bytes doc: rng: Add documentation for the rng command test: rng: Add a UT testcase for the rng command cmd/Kconfig | 1 + cmd/rng.c | 42 +++++++++++------ doc/usage/cmd/rng.rst | 26 +++++++++++ doc/usage/index.rst | 1 + drivers/rng/Kconfig | 11 +++++ drivers/rng/Makefile | 1 + drivers/rng/tpm_rng.c | 23 ++++++++++ drivers/tpm/tpm-uclass.c | 37 +++++++++++++-- include/tpm_api.h | 10 ++++ lib/Kconfig | 1 + lib/tpm-v1.c | 13 +++--- lib/tpm-v2.c | 6 +-- lib/tpm_api.c | 98 ++++++++++++++++++---------------------- test/dm/rng.c | 29 ++++++++++++ 14 files changed, 217 insertions(+), 82 deletions(-) create mode 100644 doc/usage/cmd/rng.rst create mode 100644 drivers/rng/tpm_rng.c