From patchwork Wed Jul 20 12:29:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 591860 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp4892729max; Wed, 20 Jul 2022 05:30:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tReMqvDzHsdVXiThx7flqzC1MJAtzjX/YM/WSfgGV1jC4dJ4Xek9QHUJeFhFRYQbEHZdpv X-Received: by 2002:a05:6638:2713:b0:341:4773:16f0 with SMTP id m19-20020a056638271300b00341477316f0mr15103144jav.263.1658320214913; Wed, 20 Jul 2022 05:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658320214; cv=none; d=google.com; s=arc-20160816; b=FHvWjaluovkn7u0rXxW1wiRpOaoVgB7Ya3C3635+sEfJsIWfwJAopdxj+GLuacwrU2 T/RUcoYJtv5pm1R6sV/TB71NE/iWejnxNPCGox1R89/Z6rdF0wMjmIzmhAAYI4DIN5El 7PTZQXSZl8jlaDLHQGXFUUx/N78+UTCYKrfMduc7qeZBTLbr0g8QkEVAk52D0FK3Y08x 10Gd/5DdH/LuQi5t5pEdnfhXBQ6xGvbOYgpg7SNk7R3Ev8Ik1uHj8HhSmAl0Gj8nVQgF JRD4uf3YczlvFCFAffoIzSaI2jt5tn579SEMyHg7U25ne5RoAqD35zMuHN/vzTZkxdb+ 6kSw== 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=OapXa7mdegCJ4ub8n1p6NcXnKUTl8vGlEkGhLDblGqU=; b=tHwHX4n7ZR/YqaLgB+Q3uoNce0mD0q/G6UlyXlbnYu/oc6kxHqv+4CjvKQLpjPknaD 8n6TdvZOeALLGtLj4wOCTyjzD79w57N9Vme/LW0OWDmOesFMc+GGFHSoAfgLB3vzrfRz q6WJzC87S+7GkwZP3e3Y3J3CGnDD33uNA2cKWFqPZHR0io0BT1K7sOoEUY09diRIq3Yf 9w9U4qmGY/WRlo5jawv/jfElQtHPx5xTHQbXsoPvCaD8VvQgRzLBSYHEkrVqbJVX7bc/ zru4wOow2s4iCG2yNzNaf4Tza7Ob5DRTj68ITjNTFdssanO1FaPOUmxTqQeTBd73Rzo3 1jCQ== 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 9-20020a056e0220c900b002dd0a466147si2430079ilq.70.2022.07.20.05.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 05:30:14 -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 61FEB8405E; Wed, 20 Jul 2022 14:30:09 +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 66DF884055; Wed, 20 Jul 2022 14:30:07 +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 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 682B880361 for ; Wed, 20 Jul 2022 14:30:03 +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 01A5C1576; Wed, 20 Jul 2022 05:30:03 -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 BE07A3F73D; Wed, 20 Jul 2022 05:30:00 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Tom Rini Subject: [PATCH v7 0/7] tpm: rng: Move TPM RNG functionality to driver model Date: Wed, 20 Jul 2022 17:59:19 +0530 Message-Id: <20220720122926.415659-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.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 | 9 ++++ 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_api.c | 98 ++++++++++++++++++---------------------- test/dm/rng.c | 29 ++++++++++++ 12 files changed, 205 insertions(+), 73 deletions(-) create mode 100644 doc/usage/cmd/rng.rst create mode 100644 drivers/rng/tpm_rng.c