From nobody Mon Feb 9 01:19:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+80677+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80677+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1631669139; cv=none; d=zohomail.com; s=zohoarc; b=eGAnKWOzKjWSSabhKiq3yBhDq6v3MHe0lnShpzNwaAMdSwzEAVSxOE9qIt14qDDTzYIno7NFhQ8GUL6NPex7uMh+qW/RcXa7rw5mOMI+yxcq3Bet2BPWRdfDZAvMAnv2p7ObeoWyPJ4xqAmOCP7fVMvtDZJQLBwhO+ny5oyDnz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631669139; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=rvUTi5SRfSbFr7e2pXQzPqvlCVyxIc7/Nxis+PGh3rU=; b=eAzcMVrVZ90MlS7RCdi0zBbOWRbSnWUUSZYgffyEJ7v94pkJQWEPUUHFidn87LgA6poHVl/UN4JQ4W99lot9jIB2CXoEOXoTg+pCzWJLAyck4XLxsqt2oepT0JeRLajKI9wxhrbeL0u8kTNYYmgx3bhtBmF/vxlu29aKMWspUVM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80677+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1631669139942599.7273104787006; Tue, 14 Sep 2021 18:25:39 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id g0HZYY1788612x2DJgqkc6kB; Tue, 14 Sep 2021 18:25:39 -0700 X-Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.158.5]) by mx.groups.io with SMTP id smtpd.web11.1682.1631669137735805179 for ; Tue, 14 Sep 2021 18:25:38 -0700 X-Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 18ELxULr015162; Tue, 14 Sep 2021 21:25:20 -0400 X-Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3b31gqy0er-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Sep 2021 21:25:19 -0400 X-Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 18F1ExaD008123; Tue, 14 Sep 2021 21:25:19 -0400 X-Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 3b31gqy0e9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Sep 2021 21:25:19 -0400 X-Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18F17oOO011976; Wed, 15 Sep 2021 01:25:18 GMT X-Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma02dal.us.ibm.com with ESMTP id 3b0m3bf80v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Sep 2021 01:25:18 +0000 X-Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18F1PH9H39191032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 01:25:17 GMT X-Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50A0E112062; Wed, 15 Sep 2021 01:25:17 +0000 (GMT) X-Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32493112065; Wed, 15 Sep 2021 01:25:17 +0000 (GMT) X-Received: from sbct-2.pok.ibm.com (unknown [9.47.158.152]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 15 Sep 2021 01:25:17 +0000 (GMT) From: "Stefan Berger" To: devel@edk2.groups.io Cc: mhaeuser@posteo.de, spbrogan@outlook.com, marcandre.lureau@redhat.com, kraxel@redhat.com, jiewen.yao@intel.com, rebecca@bsdio.com, grehan@freebsd.org, brijesh.singh@amd.com, erdemaktas@google.com, jejb@linux.ibm.com, min.m.xu@intel.com, thomas.lendacky@amd.com, ardb+tianocore@kernel.org, jordan.l.justen@intel.com, Stefan Berger , Stefan Berger , Jiewen Yao Subject: [edk2-devel] [PATCH v3 2/4] OvmfPkg: Handle TPM 2 physical presence opcodes much earlier Date: Tue, 14 Sep 2021 21:25:04 -0400 Message-Id: <20210915012506.2619693-3-stefanb@linux.ibm.com> In-Reply-To: <20210915012506.2619693-1-stefanb@linux.ibm.com> References: <20210915012506.2619693-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7iXY7TfeAplMjx49CfPKjcw7XqgLViL8 X-Proofpoint-ORIG-GUID: -0yR-l0YGzIlrbfDKfnXM49aImvaS4YO Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,stefanb@linux.ibm.com X-Gm-Message-State: JaT814ApHSeGTRjbqcVOV5RZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631669139; bh=4sPE/PHrz/G89fm8yku4qGPHgy2BVy1uE3SFIMh5VXM=; h=Cc:Date:From:Reply-To:Subject:To; b=iRYqKqbmXaZz4VSehrsOt0TJdraQ+cG8PIsB4oaZbiGr9Qx0VsDgsHufGs48ySm1PXf IU5nN2BCigXB4lfrxP/aP+WIzBCTDS8QruKGkCKfVRmiJfWqpt1ogjoVQOiGvBkTLfdrP nl2fkUVKQIXBVRPdqH+8Iz4IhjvXNXD2JtM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631669140479100004 Content-Type: text/plain; charset="utf-8" From: Stefan Berger Handle the TPM 2 physical presence interface (PPI) opcodes in PlatformBootManagerBeforeConsole() before the TPM 2 platform hierarchy is disabled. Since the handling of the PPI opcodes may require inter- action with the user, initialize the keyboard before handling PPI codes. Cc: Rebecca Cran Cc: Peter Grehan Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Min Xu Cc: Tom Lendacky Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Gerd Hoffmann Signed-off-by: Stefan Berger Reviewed-by: Jiewen Yao --- .../PlatformBootManagerLib/BdsPlatform.c | 19 +++++++++++-------- .../PlatformBootManagerLibBhyve/BdsPlatform.c | 17 ++++++++++------- .../PlatformBootManagerLibGrub/BdsPlatform.c | 17 ++++++++++------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg= /Library/PlatformBootManagerLib/BdsPlatform.c index 71f63b2448..4448722e19 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c @@ -387,8 +387,19 @@ PlatformBootManagerBeforeConsole ( SaveS3BootScript (); } =20 + // We need to connect all trusted consoles for TCG PP. Here we treat all + // consoles in OVMF to be trusted consoles. + PlatformInitializeConsole ( + XenDetected() ? gXenPlatformConsole : gPlatformConsole); + + // + // Process TPM PPI request; this may require keyboard input + // + Tcg2PhysicalPresenceLibProcessRequest (NULL); + // // Prevent further changes to LockBoxes or SMRAM. + // Any TPM 2 Physical Presence Interface opcode must be handled before. // Handle =3D NULL; Status =3D gBS->InstallProtocolInterface (&Handle, @@ -402,9 +413,6 @@ PlatformBootManagerBeforeConsole ( // EfiBootManagerDispatchDeferredImages (); =20 - PlatformInitializeConsole ( - XenDetected() ? gXenPlatformConsole : gPlatformConsole); - FrontPageTimeout =3D GetFrontPageTimeoutFromQemu (); PcdStatus =3D PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout); ASSERT_RETURN_ERROR (PcdStatus); @@ -1511,11 +1519,6 @@ PlatformBootManagerAfterConsole ( // PciAcpiInitialization (); =20 - // - // Process TPM PPI request - // - Tcg2PhysicalPresenceLibProcessRequest (NULL); - // // Process QEMU's -kernel command line option // diff --git a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c b/Ov= mfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c index eaade4adea..513d2f00a7 100644 --- a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c @@ -375,8 +375,18 @@ PlatformBootManagerBeforeConsole ( // EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); =20 + // We need to connect all trusted consoles for TCG PP. Here we treat all + // consoles in OVMF to be trusted consoles. + PlatformInitializeConsole (gPlatformConsole); + + // + // Process TPM PPI request + // + Tcg2PhysicalPresenceLibProcessRequest (NULL); + // // Prevent further changes to LockBoxes or SMRAM. + // Any TPM 2 Physical Presence Interface opcode must be handled before. // Handle =3D NULL; Status =3D gBS->InstallProtocolInterface (&Handle, @@ -390,8 +400,6 @@ PlatformBootManagerBeforeConsole ( // EfiBootManagerDispatchDeferredImages (); =20 - PlatformInitializeConsole (gPlatformConsole); - PlatformRegisterOptionsAndKeys (); =20 // @@ -1445,11 +1453,6 @@ PlatformBootManagerAfterConsole ( // PciAcpiInitialization (); =20 - // - // Process TPM PPI request - // - Tcg2PhysicalPresenceLibProcessRequest (NULL); - // // Perform some platform specific connect sequence // diff --git a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c b/Ovm= fPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c index 7cceeea487..1c5405f620 100644 --- a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c @@ -338,8 +338,18 @@ PlatformBootManagerBeforeConsole ( // EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); =20 + // We need to connect all trusted consoles for TCG PP. Here we treat all + // consoles in OVMF to be trusted consoles. + PlatformInitializeConsole (gPlatformConsole); + + // + // Process TPM PPI request + // + Tcg2PhysicalPresenceLibProcessRequest (NULL); + // // Prevent further changes to LockBoxes or SMRAM. + // Any TPM 2 Physical Presence Interface opcode must be handled before. // Handle =3D NULL; Status =3D gBS->InstallProtocolInterface (&Handle, @@ -353,8 +363,6 @@ PlatformBootManagerBeforeConsole ( // EfiBootManagerDispatchDeferredImages (); =20 - PlatformInitializeConsole (gPlatformConsole); - Status =3D gRT->SetVariable ( EFI_TIME_OUT_VARIABLE_NAME, &gEfiGlobalVariableGuid, @@ -1310,11 +1318,6 @@ PlatformBootManagerAfterConsole ( // PciAcpiInitialization (); =20 - // - // Process TPM PPI request - // - Tcg2PhysicalPresenceLibProcessRequest (NULL); - // // Process QEMU's -kernel command line option // --=20 2.31.1 -=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 (#80677): https://edk2.groups.io/g/devel/message/80677 Mute This Topic: https://groups.io/mt/85617943/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-