From nobody Fri Apr 19 06:14:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60004+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60004+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590015541; cv=none; d=zohomail.com; s=zohoarc; b=KeJ8IjoKWnobKkDKBPlqZzqRfM9Kgq95qjmRJl9RiC2ctY6KeigwBOzoc9ycqVvVl6CbJMxmNKUtqHvj/BBwSAdkhBVzAvAb+9VfqZ9u0x9T96d8umyGuJxvYX84zt74uI6kIvv8CTcBhjNxH1ulORx3jTObqR/u1MTo7dO83nw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590015541; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ejsQXZCk/6heif0l/3JXnG8ciUd8Bn0XIJx/WgzfdPw=; b=coDOOUQ6R09HURbkB5lA1uI+H4n4NeRLKi/d3kekqwlNizfQ7Qi2xismVZbR0FkQUf++DtQ+nKFwPtKfCt1d6hlpr08e6xNa23L2Avj5kgeSfiBI7siqvT0lQeyWgllG5CEnlBzt1hEcdtLec/GlfTcwV0Q3xLSjnZDE+qNmoc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60004+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1590015541029466.86124403978374; Wed, 20 May 2020 15:59:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UXqBYY1788612xmVH1rAqCec; Wed, 20 May 2020 15:59:00 -0700 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web10.195.1590015538490869451 for ; Wed, 20 May 2020 15:58:59 -0700 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-iQm6BQdmNAi4WKHax1pWqQ-1; Wed, 20 May 2020 18:58:53 -0400 X-MC-Unique: iQm6BQdmNAi4WKHax1pWqQ-1 X-Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A976080B700; Wed, 20 May 2020 22:58:52 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-121.ams2.redhat.com [10.36.115.121]) by smtp.corp.redhat.com (Postfix) with ESMTP id D94C648D7E; Wed, 20 May 2020 22:58:50 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Eric Auger , Jordan Justen , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Simon Hardy , Stefan Berger Subject: [edk2-devel] [PATCH 1/3] OvmfPkg/Tcg2ConfigPei: clean up some lib class dependencies Date: Thu, 21 May 2020 00:58:39 +0200 Message-Id: <20200520225841.17793-2-lersek@redhat.com> In-Reply-To: <20200520225841.17793-1-lersek@redhat.com> References: <20200520225841.17793-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: VP2ysSE6OsmIyhuHSnVsRooRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1590015540; bh=ejsQXZCk/6heif0l/3JXnG8ciUd8Bn0XIJx/WgzfdPw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=GIKClW+kXcVc+tCx5YYdbOwIq5PaLvH/i16xSrtl+OFvTl6S7ZK0f37BzYGGHkVL1nd e7bCoozOlijx6wAoGgmv3XhLa1OCsmev2h/Z5gQePgOJJUBtnNnoM1nIDFFDZ/dyXEp0+ 3804jNITWE/euBwhzis7BW/lN8KFRiuc8oA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Commit 89236992913f introduced an explicit Tpm12CommandLib dependency to Tcg2ConfigPei. In reality this lib class is not consumed by Tcg2ConfigPei at all (such a dependency is not even inherited from other lib instances). Simplify the module by dropping the superfluous dependency. (The Tpm12CommandLib class resolution that was also added in commit 89236992913f is not useless, at the platform build level: it is consumed by TcgPei and TcgDxe. Meaning that said Tpm12CommandLib resolution should have likely been a part of the subsequent patch in the original series, namely commit 6be54f15a0c9.) Commit 89236992913f also introduced SwapBytesXx() calls. Those functions are provided by BaseLib. Spell out the BaseLib dependency. Functionally, this patch is a no-op. Cc: Ard Biesheuvel Cc: Eric Auger Cc: Jordan Justen Cc: Marc-Andr=C3=A9 Lureau Cc: Philippe Mathieu-Daud=C3=A9 Cc: Simon Hardy Cc: Stefan Berger Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2728 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude Tested-by: Ard Biesheuvel --- OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf | 2 +- OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf b/OvmfPkg/Tcg/Tcg2Con= fig/Tcg2ConfigPei.inf index 97c529c91d0b..b79d0a3fb912 100644 --- a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf +++ b/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf @@ -30,9 +30,9 @@ [Packages] =20 [LibraryClasses] PeimEntryPoint + BaseLib DebugLib PeiServicesLib - Tpm12CommandLib Tpm12DeviceLib Tpm2DeviceLib =20 diff --git a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c b/OvmfPkg/Tcg/Tcg2Conf= ig/Tcg2ConfigPeim.c index 5b5075bded92..44abd6c541f9 100644 --- a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c +++ b/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c @@ -15,11 +15,11 @@ #include =20 #include +#include #include #include #include #include -#include #include =20 STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmSelectedPpi =3D { --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60004): https://edk2.groups.io/g/devel/message/60004 Mute This Topic: https://groups.io/mt/74362541/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 06:14:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60003+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60003+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590015540; cv=none; d=zohomail.com; s=zohoarc; b=feYKkBbxe1JdPdclWSdD4lto5a8XhYJH0mBu1gqfMsufF1aIsYFnZTUSKBHASNyFeO1AGPcUAm0f2fs6g9btL9zSgUdY/34+kKQZFgohK3/RwJzdyeDQ7h6HLkXMHIUByn7+VL8Lq/PpphSEuzihdczdnSO9IHVyO2EUgVxkbm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590015540; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=4dJ9RYdm3ETKnwhwTJS2yKkG5Ce9gUFJeUsJLfyr29E=; b=Hx5/SQtLC2tv2kzimPNn9kYhp/dnnjzYLauUt5sYmTlk7/Zr4NgcwcL6dcyzjW05Hp0qYQ7gKhqfVVJN79vAcT4CvhohE3A4kzWFdRsoZIroxIqRqXLrxcEQHJjVpa178JUjBlEbIyY743APmWc+lenUzB7OxvdcJodgERy9UpQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60003+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1590015540569644.5435821971798; Wed, 20 May 2020 15:59:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SOKpYY1788612xzacW9IsIBi; Wed, 20 May 2020 15:59:00 -0700 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web10.196.1590015538783076622 for ; Wed, 20 May 2020 15:58:59 -0700 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-LKuJ03uOPo-9bxVd1d6ERw-1; Wed, 20 May 2020 18:58:56 -0400 X-MC-Unique: LKuJ03uOPo-9bxVd1d6ERw-1 X-Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC7771800D42; Wed, 20 May 2020 22:58:54 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-121.ams2.redhat.com [10.36.115.121]) by smtp.corp.redhat.com (Postfix) with ESMTP id 086EE48D7E; Wed, 20 May 2020 22:58:52 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Eric Auger , Jordan Justen , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Simon Hardy , Stefan Berger Subject: [edk2-devel] [PATCH 2/3] OvmfPkg/Tcg2ConfigPei: factor out InternalTpm12Detect() Date: Thu, 21 May 2020 00:58:40 +0200 Message-Id: <20200520225841.17793-3-lersek@redhat.com> In-Reply-To: <20200520225841.17793-1-lersek@redhat.com> References: <20200520225841.17793-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: u5kvvPNwiTO1YAAo9IA3rCVjx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1590015540; bh=4dJ9RYdm3ETKnwhwTJS2yKkG5Ce9gUFJeUsJLfyr29E=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=l0nQe81pDm+33ZYuMt1DQXv92+lHSsD98BKay82PHhEkAIZUqDk2tET7OPt5fbkjo/+ viEPV+7IvkZ8dLcO/OCEHgc8WGcfVYKKuV8TUH9I0wEArzO5DmNT/fEE8zt3ZfLuevdTg 1E0oEWHZkNxn4qi5zM8Lubd7K3tuozaE5vU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Move the calls to the Tpm12RequestUseTpm() and Tpm12SubmitCommand() Tpm12DeviceLib functions to a separate C file, so that we can override these actions in a subsequent patch. This code movement requires moving the TPM_RSP_GET_TICKS / TestTpm12() helper structure / function too. While at it, give the TestTpm12() function @retval / @return documentation, plus wrap an overlong line in it. Functionally, this patch is a no-op. Cc: Ard Biesheuvel Cc: Eric Auger Cc: Jordan Justen Cc: Marc-Andr=C3=A9 Lureau Cc: Philippe Mathieu-Daud=C3=A9 Cc: Simon Hardy Cc: Stefan Berger Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2728 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude Tested-by: Ard Biesheuvel --- OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf | 2 + OvmfPkg/Tcg/Tcg2Config/Tpm12Support.h | 30 ++++++++ OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c | 46 +----------- OvmfPkg/Tcg/Tcg2Config/Tpm12Support.c | 79 ++++++++++++++++++++ 4 files changed, 115 insertions(+), 42 deletions(-) diff --git a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf b/OvmfPkg/Tcg/Tcg2Con= fig/Tcg2ConfigPei.inf index b79d0a3fb912..aa996b7da778 100644 --- a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf +++ b/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf @@ -21,6 +21,8 @@ [Defines] =20 [Sources] Tcg2ConfigPeim.c + Tpm12Support.c + Tpm12Support.h =20 [Packages] MdePkg/MdePkg.dec diff --git a/OvmfPkg/Tcg/Tcg2Config/Tpm12Support.h b/OvmfPkg/Tcg/Tcg2Config= /Tpm12Support.h new file mode 100644 index 000000000000..c739775d2353 --- /dev/null +++ b/OvmfPkg/Tcg/Tcg2Config/Tpm12Support.h @@ -0,0 +1,30 @@ +/** @file + Declare the InternalTpm12Detect() function, hiding the TPM-1.2 detection + internals. + + Copyright (C) 2020, Red Hat, Inc. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef TPM12_SUPPORT_H_ +#define TPM12_SUPPORT_H_ + +#include + +/** + Detect the presence of a TPM with interface version 1.2. + + @retval EFI_SUCCESS TPM-1.2 available. The Tpm12RequestUseTpm() and + Tpm12SubmitCommand(TPM_ORD_GetTicks) operations + (from the Tpm12DeviceLib class) have succeeded. + + @return Error codes propagated from Tpm12RequestUseTpm(= ) and + Tpm12SubmitCommand(). +**/ +EFI_STATUS +InternalTpm12Detect ( + VOID + ); + +#endif // TPM12_SUPPORT_H_ diff --git a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c b/OvmfPkg/Tcg/Tcg2Conf= ig/Tcg2ConfigPeim.c index 44abd6c541f9..cc54d95cad19 100644 --- a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c +++ b/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c @@ -15,13 +15,13 @@ #include =20 #include -#include #include #include #include -#include #include =20 +#include "Tpm12Support.h" + STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmSelectedPpi =3D { (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), &gEfiTpmDeviceSelectedGuid, @@ -34,44 +34,6 @@ STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmInitializationD= onePpiList =3D { NULL }; =20 -#pragma pack (1) - -typedef struct { - TPM_RSP_COMMAND_HDR Hdr; - TPM_CURRENT_TICKS CurrentTicks; -} TPM_RSP_GET_TICKS; - -#pragma pack () - -/** - Probe for the TPM for 1.2 version, by sending TPM1.2 GetTicks - - Sending a TPM1.2 command to a TPM2 should return a TPM1.2 - header (tag =3D 0xc4) and error code (TPM_BADTAG =3D 0x1e) -**/ -static -EFI_STATUS -TestTpm12 ( - ) -{ - EFI_STATUS Status; - TPM_RQU_COMMAND_HDR Command; - TPM_RSP_GET_TICKS Response; - UINT32 Length; - - Command.tag =3D SwapBytes16 (TPM_TAG_RQU_COMMAND); - Command.paramSize =3D SwapBytes32 (sizeof (Command)); - Command.ordinal =3D SwapBytes32 (TPM_ORD_GetTicks); - - Length =3D sizeof (Response); - Status =3D Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Len= gth, (UINT8 *)&Response); - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - /** The entry point for Tcg2 configuration driver. =20 @@ -90,8 +52,8 @@ Tcg2ConfigPeimEntryPoint ( =20 DEBUG ((DEBUG_INFO, "%a\n", __FUNCTION__)); =20 - Status =3D Tpm12RequestUseTpm (); - if (!EFI_ERROR (Status) && !EFI_ERROR (TestTpm12 ())) { + Status =3D InternalTpm12Detect (); + if (!EFI_ERROR (Status)) { DEBUG ((DEBUG_INFO, "%a: TPM1.2 detected\n", __FUNCTION__)); Size =3D sizeof (gEfiTpmDeviceInstanceTpm12Guid); Status =3D PcdSetPtrS ( diff --git a/OvmfPkg/Tcg/Tcg2Config/Tpm12Support.c b/OvmfPkg/Tcg/Tcg2Config= /Tpm12Support.c new file mode 100644 index 000000000000..4f5a775c7a03 --- /dev/null +++ b/OvmfPkg/Tcg/Tcg2Config/Tpm12Support.c @@ -0,0 +1,79 @@ +/** @file + Implement the InternalTpm12Detect() function on top of the Tpm12DeviceLib + class. + + Copyright (C) 2020, Red Hat, Inc. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include + +#include "Tpm12Support.h" + +#pragma pack (1) +typedef struct { + TPM_RSP_COMMAND_HDR Hdr; + TPM_CURRENT_TICKS CurrentTicks; +} TPM_RSP_GET_TICKS; +#pragma pack () + +/** + Probe for the TPM for 1.2 version, by sending TPM1.2 GetTicks + + Sending a TPM1.2 command to a TPM2 should return a TPM1.2 + header (tag =3D 0xc4) and error code (TPM_BADTAG =3D 0x1e) + + @retval EFI_SUCCESS TPM version 1.2 probing successful. + + @return Error codes propagated from Tpm12SubmitCommand(). +**/ +STATIC +EFI_STATUS +TestTpm12 ( + ) +{ + EFI_STATUS Status; + TPM_RQU_COMMAND_HDR Command; + TPM_RSP_GET_TICKS Response; + UINT32 Length; + + Command.tag =3D SwapBytes16 (TPM_TAG_RQU_COMMAND); + Command.paramSize =3D SwapBytes32 (sizeof (Command)); + Command.ordinal =3D SwapBytes32 (TPM_ORD_GetTicks); + + Length =3D sizeof (Response); + Status =3D Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Len= gth, + (UINT8 *)&Response); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + +/** + Detect the presence of a TPM with interface version 1.2. + + @retval EFI_SUCCESS TPM-1.2 available. The Tpm12RequestUseTpm() and + Tpm12SubmitCommand(TPM_ORD_GetTicks) operations + (from the Tpm12DeviceLib class) have succeeded. + + @return Error codes propagated from Tpm12RequestUseTpm(= ) and + Tpm12SubmitCommand(). +**/ +EFI_STATUS +InternalTpm12Detect ( + VOID + ) +{ + EFI_STATUS Status; + + Status =3D Tpm12RequestUseTpm (); + if (EFI_ERROR (Status)) { + return Status; + } + + return TestTpm12 (); +} --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60003): https://edk2.groups.io/g/devel/message/60003 Mute This Topic: https://groups.io/mt/74362540/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 06:14:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60006+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60006+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590015544; cv=none; d=zohomail.com; s=zohoarc; b=cwIuPmu6ovq0nVK2/OKlFW4z6Mbaeur65Iw5+TgGUi8d4OXl76/a04KdYPH6brZ4yrmiXcmcdrp4QV27+GXiiDhgoY9vz6rJaHyvumtxzTyP9Y1zY3je2o3ImXHkZkneL5oCtor4lVlBlx76AV/tM0xkNZyEzEkEmqJJC9V6SnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590015544; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=MCVGi6qLKdz+18qskK5HZcfREDK9rsM0gqTGWZkVkfk=; b=YuAF5SqlhZBqxglK4fnLSeD+gqupWwUpGV+iUMHdV44IKezxG1pUEmTTYkcF2GZGw39yqYo7te/V3LLF2bb2gzNDmSWPSxifDOFkALrrr1jAT2ImNSpZgnLc8udRyVloi035Vxod6Ax1o095U48zUi5HpvONh2CWDAROQeteVpY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60006+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1590015544186718.294862815953; Wed, 20 May 2020 15:59:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id tOJzYY1788612xEkMVgnB3wi; Wed, 20 May 2020 15:59:03 -0700 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web11.177.1590015542605172843 for ; Wed, 20 May 2020 15:59:02 -0700 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-FwNv9_dAMZiL1GCY0hKhhQ-1; Wed, 20 May 2020 18:58:58 -0400 X-MC-Unique: FwNv9_dAMZiL1GCY0hKhhQ-1 X-Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 213F31853C61; Wed, 20 May 2020 22:58:57 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-121.ams2.redhat.com [10.36.115.121]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BF7948D7E; Wed, 20 May 2020 22:58:55 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Eric Auger , Jordan Justen , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Simon Hardy , Stefan Berger Subject: [edk2-devel] [PATCH 3/3] OvmfPkg/Tcg2ConfigPei: skip TPM-1.2 detection when building for ARM/AARCH64 Date: Thu, 21 May 2020 00:58:41 +0200 Message-Id: <20200520225841.17793-4-lersek@redhat.com> In-Reply-To: <20200520225841.17793-1-lersek@redhat.com> References: <20200520225841.17793-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: PVBMld6Fnzv4IZuhHYDk1UNIx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1590015543; bh=MCVGi6qLKdz+18qskK5HZcfREDK9rsM0gqTGWZkVkfk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=F8n89EbcD8eMP2DJOKz6EvGiootNEEVkZtPy3dr/kLYhKJ+NTXeTG6lFeTYlp9qTbjy Isi0IbRi7O86fn2IpdSMRqjdUdRXbq9JhJ2ciZmveFjfwmaNNXVfjhXGEYF99auI6mc41 wApdkRTMMl3oApQyEtTrAHMG8Mf7aqp0JwE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Dating back to commits f5cb3767038e and ddd34a818315d, the "ArmVirtPkg/ArmVirtQemu.dsc" platform includes the "OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf" module when the TPM2_ENABLE build flag is defined. This was regressed in commit 89236992913f, which added a Tpm12DeviceLib dependency to Tcg2ConfigPei. "ArmVirtQemu.dsc" does not resolve that class to any instance, so now we get a build failure: > build.py... > ArmVirtPkg/ArmVirtQemu.dsc(...): error 4000: Instance of library class > [Tpm12DeviceLib] is not found > in [OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf] [AARCH64] > consumed by module [OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf] The TPM-1.2 code in OvmfPkg/Tcg2ConfigPei is limited to a special use case (a kind of physical TPM-1.2 assignment), and that has never applied to "ArmVirtQemu.dsc". Short-circuit the TPM-1.2 detection in the ARM/AARCH64 builds of OvmfPkg/Tcg2ConfigPei, removing the Tpm12DeviceLib dependency. Functionally, this patch is a no-op on IA32 / X64. Cc: Ard Biesheuvel Cc: Eric Auger Cc: Jordan Justen Cc: Marc-Andr=C3=A9 Lureau Cc: Philippe Mathieu-Daud=C3=A9 Cc: Simon Hardy Cc: Stefan Berger Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2728 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude Tested-by: Ard Biesheuvel --- OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf | 11 +++++++-- OvmfPkg/Tcg/Tcg2Config/Tpm12Support.h | 4 ++++ OvmfPkg/Tcg/Tcg2Config/Tpm12SupportNull.c | 25 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf b/OvmfPkg/Tcg/Tcg2Con= fig/Tcg2ConfigPei.inf index aa996b7da778..194ebfba6409 100644 --- a/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf +++ b/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf @@ -21,9 +21,14 @@ [Defines] =20 [Sources] Tcg2ConfigPeim.c - Tpm12Support.c Tpm12Support.h =20 +[Sources.IA32, Sources.X64] + Tpm12Support.c + +[Sources.ARM, Sources.AARCH64] + Tpm12SupportNull.c + [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec @@ -35,9 +40,11 @@ [LibraryClasses] BaseLib DebugLib PeiServicesLib - Tpm12DeviceLib Tpm2DeviceLib =20 +[LibraryClasses.IA32, LibraryClasses.X64] + Tpm12DeviceLib + [Guids] gEfiTpmDeviceSelectedGuid ## PRODUCES ## GUID # Used as a PPI = GUID gEfiTpmDeviceInstanceTpm20DtpmGuid ## SOMETIMES_CONSUMES diff --git a/OvmfPkg/Tcg/Tcg2Config/Tpm12Support.h b/OvmfPkg/Tcg/Tcg2Config= /Tpm12Support.h index c739775d2353..d92c43253081 100644 --- a/OvmfPkg/Tcg/Tcg2Config/Tpm12Support.h +++ b/OvmfPkg/Tcg/Tcg2Config/Tpm12Support.h @@ -15,6 +15,10 @@ /** Detect the presence of a TPM with interface version 1.2. =20 + @retval EFI_UNSUPPORTED The platform that includes this particular + implementation of the function does not support + TPM-1.2. + @retval EFI_SUCCESS TPM-1.2 available. The Tpm12RequestUseTpm() and Tpm12SubmitCommand(TPM_ORD_GetTicks) operations (from the Tpm12DeviceLib class) have succeeded. diff --git a/OvmfPkg/Tcg/Tcg2Config/Tpm12SupportNull.c b/OvmfPkg/Tcg/Tcg2Co= nfig/Tpm12SupportNull.c new file mode 100644 index 000000000000..7bb377b9b9b0 --- /dev/null +++ b/OvmfPkg/Tcg/Tcg2Config/Tpm12SupportNull.c @@ -0,0 +1,25 @@ +/** @file + Null implementation of InternalTpm12Detect(), always returning + EFI_UNSUPPORTED. + + Copyright (C) 2020, Red Hat, Inc. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "Tpm12Support.h" + +/** + Detect the presence of a TPM with interface version 1.2. + + @retval EFI_UNSUPPORTED The platform that includes this particular + implementation of the function does not support + TPM-1.2. +**/ +EFI_STATUS +InternalTpm12Detect ( + VOID + ) +{ + return EFI_UNSUPPORTED; +} --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60006): https://edk2.groups.io/g/devel/message/60006 Mute This Topic: https://groups.io/mt/74362544/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-