From patchwork Fri Jul 22 16:02:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 592467 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp634546mab; Fri, 22 Jul 2022 09:02:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uxqMXDrIUGJDU1/YpYTao5VtOogI+0isOetjBlZ+Jpp7rFAJ/VQtEtgpdcfbsr2UWy/dCB X-Received: by 2002:a05:6e02:1c2f:b0:2dc:ee01:b242 with SMTP id m15-20020a056e021c2f00b002dcee01b242mr286590ilh.148.1658505759996; Fri, 22 Jul 2022 09:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658505759; cv=none; d=google.com; s=arc-20160816; b=t5IClA8CQmUA06Qarb08m09qLyIitcGvEGJe0NJiQpp6dHFcyPO3P1AytnWxAWqxkD KljU0RFZb3t59GaSASLjg6iiIHccDkAKCAwFgADXVhl64C9CF4mo/tMZgDLaO48icLC4 6y1bbj9avxFAKYPRb8xC9n/sC2DO3fz/nF4GSt2AgOjuDG7P4tBVMifCYJ10Je5DZicq JkhdzHdR/Bs8NFGT3TqDA+rCgWR5zuWgVP9Ve3mZJEKYdPMekw4oZECZMfgnqCx4Mlqe t9emWDrGgb5Xc1n6fTCfACPnSqcfZFuL6m5G9GPP171Yh87Cfg5tBxhmp5aSoCSuUZme FGGQ== 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=QPZovtHO+ZHJ/EGXb26y5rHUfQ8LGAjBuy26j71XRr4=; b=JHVZKdMu/G29dJ48mJYdY0+WFXMEIsSvLgLvlQuqU502jKoJypXvfAXHtMqxnp+R8s trbUOnHgobMNbrUVRL/xAIh3wZKQsopqb0Y30+vRnNl0mjL+sG9He3mEY4GRVa1BGIVl RAR8kP3f/Z+M7Y3N3ng2YzVBqIXp5ghvqq3tn2FRo34+07WgIinGw/sScduA+/frkJ20 bBMdQS7IPr1wgPcGPBCgrHd3i0IgsZcm4nRKEveudUoptmTshUiQFSIMyuxaSy1P521V B8CIh5l/nZH9rKlPeaDGE1eRjMkbbuXpTyo0tvUiHRr3IU7u69x/9Pjx8DzHrkKeZO6B PWUQ== 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 c32-20020a023b20000000b0033e83f03034si3949965jaa.137.2022.07.22.09.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:02:39 -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 3D2D483D7F; Fri, 22 Jul 2022 18:02:34 +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 1BFE282142; Fri, 22 Jul 2022 18:02:31 +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 4B66382142 for ; Fri, 22 Jul 2022 18:02:28 +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 F423F1063; Fri, 22 Jul 2022 09:02:27 -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 B5F213F73D; Fri, 22 Jul 2022 09:02:25 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Tom Rini Subject: [PATCH v8 0/8] tpm: rng: Move TPM RNG functionality to driver model Date: Fri, 22 Jul 2022 21:32:01 +0530 Message-Id: <20220722160209.863840-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. [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 Changes since V7: * Added a paragraph in the commit message highlighting the absence of the compatible string in the RNG driver, as suggested by Simon. * Rearranged the inclusion of headers as per the coding style guidelines, as suggested by Simon. * Use TPM_RNG_DRV_NAME for the RNG child name as suggested by Simon. Ilias Apalodimas (1): efi_loader: initialize the RNG protocol after the TCC2 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 | 40 +++++++++++++--- include/tpm_api.h | 10 ++++ lib/Kconfig | 1 + lib/efi_loader/efi_setup.c | 14 +++--- lib/tpm_api.c | 98 +++++++++++++++++--------------------- test/dm/rng.c | 29 +++++++++++ 13 files changed, 213 insertions(+), 82 deletions(-) create mode 100644 doc/usage/cmd/rng.rst create mode 100644 drivers/rng/tpm_rng.c