From patchwork Thu Nov 18 08:13:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 519239 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp625008imj; Thu, 18 Nov 2021 00:13:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3VE71yf/DOreJ7ZVtzTNuURdI8mkbWxCFT6HPblSDqO2JJjEJkXtIKplGuPoZsSlGJfYG X-Received: by 2002:a05:6402:254b:: with SMTP id l11mr5543843edb.225.1637223236050; Thu, 18 Nov 2021 00:13:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637223236; cv=none; d=google.com; s=arc-20160816; b=ZapKIizpdAwTF6PINLAiVeZDC3TcsXe1J0zBovfJlhN+G+/mvyR/uul8H+0rZGHaXV u/BzSb0SAc8G3nEuNcrJIIVmXm35sA8tvK8iY9QMX7NpNPlJDvZG0tv+h8OZVQLnoC22 sAsnIeT/MqkIudxf/saaUCRX8Ykg5wZY5EEVmQijh3THArHk92ksN1L4f5KlehAJYFk7 f/HjJbuF/rcbyA/NxpY1yywHt1Ti4iq0Yk6vZIxkgcRkneJgN/KrOdIRjYEopxXpy7G/ q9Hb/xbiaRNAF6+SuT3CL2mynIt+7bECSW04tZ+rqBDhH0nWJWzRZ/uAcylEPT4al07f +Vjg== 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=SDKm14Aj87qzJLIl5bodGNFmcc+jClIAkPN2TVjryhs=; b=DLrO+vDcatNktN4tZ+ZogblnzrFnlUrvC7I7jTe/1+oU6+TMvGDSRWad0Dgzu5OC3+ 3x5V1rM+9Y7NnXRZTuKHIWHHkUABEs3gAu1Mt+2/XOSh3Om57a+jvIcw39QLX89S34lz iTi1C1a4sWCY0XFTfM3f35036cexFx2FuON8lO4AyyuDmOn6J6eWxd+2iLuxX36OFjZY B6YuVoO2pBp9sZI50h8u8CJBzux5DSWQlEZ/nM1842UJ+IVo7rT+ANB70qiYcly+ms+2 9ADZlKP2ecbA7lejHK4iT7OsdkapW1lDSjip7BOHdR2BQwZL5ez+f3etZxZJfzZoyywU 4AMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ec3hvbIB; 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 f12si5463868edx.614.2021.11.18.00.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 00:13:56 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Ec3hvbIB; 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 3EC4782F4B; Thu, 18 Nov 2021 09:13:52 +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="Ec3hvbIB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 695AB82F5D; Thu, 18 Nov 2021 09:13:50 +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-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) (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 9744D82BA4 for ; Thu, 18 Nov 2021 09:13:46 +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-ed1-x52a.google.com with SMTP id g14so23340170edz.2 for ; Thu, 18 Nov 2021 00:13:46 -0800 (PST) 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=SDKm14Aj87qzJLIl5bodGNFmcc+jClIAkPN2TVjryhs=; b=Ec3hvbIBTWzC96eB40O2Co/97skdKKIr/vUgmLQvIBf5r9Eu5859VyWFx29iwWcxcT jpdx6qIlwhuLiuKeGH5orzaWv5t01GAhx5Murx5GG4yLTV1KM8ttogrdxK+GB4ZmGxO/ D2I7pe2S9Z15C+jmJTYoeLfrvcIZGMxH4eb/OT1tDbpKQYUNLR1MfLthF/IR+iodPcjm bpZiSicMfDkkDE3KrCZQtCRw5DLfG0no0ZjQINxgmkJcmVPsnT9ENvQyN+MUWiEIjW5B PemXMdqaFDNPGktZmna7x8vp8YMu5Vg5aPEbenujB53oc4MJE3kKPc4oFGj7jhrM/YVU 0NRQ== 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=SDKm14Aj87qzJLIl5bodGNFmcc+jClIAkPN2TVjryhs=; b=tkGY8E9zgxi2uMX8KKgC7BVfnJeIfWUdk2pzFI0Y7NXOpabuE6GQj7QaT2TagPgnDH U1ILIjqm15F35KMByZ0G80Oncjr3096xan2+5yGi5Nub0+SVNXn/009ZWL6oUyiJxKaL 4GGzMF860zQUYClAb4xA+hxLjLr995s1Up2EKVrqfCwdLAPmXe29ZPzSdqjoGOHVIg8A APLmN5XvdZpZfbn90hmnjw/tTg/Qhjav38PBNysXxrqy6CAZgMFf81JFWi+CxSrsHOEZ re9mt0WxZfCM4jq7tScxtSXeL8HI8timsvJN2j8gGgzFcHGUYZr+TTSRWJm3W3NC5MZE QPUQ== X-Gm-Message-State: AOAM533saSsa0VakqY09bKd10jZHwjZ9KuVch30t3XE1LUFlt9DWoUhi qfFmWKCHs9lGpzR4WvXu2ckNwg== X-Received: by 2002:a05:6402:4c4:: with SMTP id n4mr8550829edw.30.1637223226238; Thu, 18 Nov 2021 00:13:46 -0800 (PST) Received: from localhost.localdomain (ppp-94-66-220-79.home.otenet.gr. [94.66.220.79]) by smtp.gmail.com with ESMTPSA id g9sm1311389edb.52.2021.11.18.00.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 00:13:45 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [PATCH] efi_loader: startup the tpm device when installing the protocol Date: Thu, 18 Nov 2021 10:13:42 +0200 Message-Id: <20211118081343.107963-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.35 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 Due to U-Boot's lazy binding mentality the TPM is probed but not properly initialized. The user can startup the device from the command line e.g 'tpm2 startup TPM2_SU_CLEAR'. However we can initialize the TPM during the TCG protocol installation, which is easier to use overall. Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_tcg2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 9a36ba0f1568..1daec6d0c6f9 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1943,6 +1944,7 @@ efi_status_t efi_tcg2_register(void) efi_status_t ret = EFI_SUCCESS; struct udevice *dev; struct efi_event *event; + u32 err; ret = platform_get_tpm2_device(&dev); if (ret != EFI_SUCCESS) { @@ -1950,6 +1952,13 @@ efi_status_t efi_tcg2_register(void) return EFI_SUCCESS; } + /* initialize the TPM as early as possible. */ + err = tpm_startup(dev, TPM_ST_CLEAR); + if (err) { + log_err("TPM startup failed\n"); + goto fail; + } + ret = efi_init_event_log(); if (ret != EFI_SUCCESS) goto fail;