From patchwork Thu Feb 24 18:05:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 545590 Delivered-To: patch@linaro.org Received: by 2002:ac0:d8d1:0:0:0:0:0 with SMTP id b17csp436932imj; Thu, 24 Feb 2022 10:06:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzctKtvPQIBuOYrEK0xz3oOfeZ9+eMFhx/1J0/wg9afq00p9s5Jnio74tVHK3O6yBdk8z7Q X-Received: by 2002:a17:906:7e52:b0:6cf:cf1a:17f with SMTP id z18-20020a1709067e5200b006cfcf1a017fmr3221214ejr.251.1645725989660; Thu, 24 Feb 2022 10:06:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645725989; cv=none; d=google.com; s=arc-20160816; b=zW5XynCOK3lDAqTOCZYf/AK6bzkPq/MzCboH2HQWzard4sT0ECo3uGkfZJNwCdwD4F E5fqAjpOSIxY3lploIyOpDdnKIQmFE7QSSeQ0bGhpY4/tvsdVC3YRoVJ7HruiT4ZEw2N d1nJ58s8ZvxTSm3l9Cx5ryrfyzHQFI/Wp5wKpLSKvvg/zsJLVm0sBs3ZZOmIFQbXZIw6 JAeFMUedhHz0MKugVl613VFTYSF/7hAxBwDXPJNH9HAn9IxVzszvVXXYHG/2K40HwLaO qhdNsbcJ547RXVdyBKPR2sRy8j6pYC3n7Zqm43UgDPx+JNs3GH7V3tgIItkOCn9FfZ6+ fJpg== 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:message-id:date:subject:cc:to :from; bh=4i5fMNMifVrg6TR0fU1ArjNSaSSrRPu+0bRAAG8boBs=; b=LGL5W4SdT2mTdpksa2U+mPVC8tYq75E/o0bN8MYs9Z/1uq747/zAq+GSN8cXUhTrPr 5IYViUozVTX6l1Pj4R2ozuQFhgvjeZ7vHfK5ra4fahmjiYdiYIouM6kBuCruF1BnXghG WaeUkwMY/yCsmcW+DrIIse+sgeYeWw2wjtl6bZzpIICZ8vetH7Q7PUy3dbWgbIJ8UXIc 3vleKZqlmCKkTCOs8cMiDsCPoEuznuAoJJLttr26rSBE1ijKDsoLB5cUfzQskgGbAtRP gyw/ZWAhYzIoIcmL2QlRB1p23xXVPogKs5PxMGneQNYLqO77SF01q4KhxdUAnPaexVQA baRw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 g6-20020a170906198600b006d07e3a4564si71229ejd.169.2022.02.24.10.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 10:06:29 -0800 (PST) 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; 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=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 666D183C19; Thu, 24 Feb 2022 19:06:19 +0100 (CET) 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 6601583C5A; Thu, 24 Feb 2022 19:06:17 +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=-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 129A083C16 for ; Thu, 24 Feb 2022 19:06:14 +0100 (CET) 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 F33F5106F; Thu, 24 Feb 2022 10:06:12 -0800 (PST) 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 DA27A3F70D; Thu, 24 Feb 2022 10:06:10 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Mario Six Subject: [PATCH 00/10] tpm: rng: Move TPM RNG functionality to driver model Date: Thu, 24 Feb 2022 23:35:42 +0530 Message-Id: <20220224180552.26901-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 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.5 at phobos.denx.de X-Virus-Status: Clean 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. This patchset moves the already existing functions for getting random bytes from the TPM device to drivers complying with the RNG uclass. This is done since the EFI_RNG_PROTOCOL's get_rng routine uses the RNG uclass's dm_rng_read api to get the random bytes. The TPM uclass driver adds the RNG child device as part of it's post_probe function. The TPM uclass driver's child_pre_probe function initialises the TPM parent device for use -- this enables the RNG child device to be used subsequently. 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. [1] - https://lore.kernel.org/u-boot/20220103120738.47835-1-ilias.apalodimas@linaro.org/ Sughosh Ganu (10): tpm: Move tpm-utils header under the include directory tpm: rng: Change tpm_get_random to return an int tpm: Fix the return type of tpm_startup tpm: Move the TPM version detection functions to the uclass driver configs: gazerbeam: Build TPMV2 library routines configs: chromebook_coral: Build TPMV1 library routines tpm: rng: Move the TPM RNG functionality to driver model tpm: Add the RNG child device qemu: arm: Remove platform specific function to get RNG device cmd: rng: Add support for selecting RNG device board/emulation/qemu-arm/qemu-arm.c | 42 ------------------ cmd/rng.c | 31 +++++++++---- configs/chromebook_coral_defconfig | 1 - configs/gazerbeam_defconfig | 1 - drivers/rng/Makefile | 1 + drivers/rng/tpm1_rng.c | 68 ++++++++++++++++++++++++++++ drivers/rng/tpm2_rng.c | 68 ++++++++++++++++++++++++++++ drivers/tpm/tpm-uclass.c | 69 +++++++++++++++++++++++++++-- {lib => include}/tpm-utils.h | 0 include/tpm_api.h | 26 +++++++++-- lib/tpm-common.c | 2 +- lib/tpm-v1.c | 46 +------------------ lib/tpm-v2.c | 46 +------------------ lib/tpm_api.c | 42 +++++++++++------- 14 files changed, 276 insertions(+), 167 deletions(-) create mode 100644 drivers/rng/tpm1_rng.c create mode 100644 drivers/rng/tpm2_rng.c rename {lib => include}/tpm-utils.h (100%)