From nobody Mon Feb 9 03:13:09 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+80655+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+80655+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1631629108; cv=none; d=zohomail.com; s=zohoarc; b=O4n8KsvkRStao9ADa7eIJEuO4iiTLksG+ATN1SahA3eWSLfBfqmRZPxvJVqSsqkG1ED8ylkGrDPlQgG4uKgWvQO/lj9UfMV/A9ZbCYfXyq0J0HhzOWcTbb9enyZhVp/lm8tPOEHRyZ3l/dbbEzhD9/mHaSSFt8Dxe5w1KIUahWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631629108; 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=0m2WNw57QgdqiWljfO02gLZdxJPfc0OH9dzUXrkQUB4=; b=VLOg7xwIjpcOorhuLKYLsDWs7ByNsIJV6HNYEVKY3OYKZPoZtwnQ/uHG0mtz2kQhhGhLUYLML/u1rfP0Vyn58r1UOur7j0cXVxDWsR8H/G6EcQEeiR92hqYoI3xj3FjFFUl7uoyOkxNEE2kZfddU3n8AEz94R1+zMkXGMsmQcQI= 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+80655+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 1631629107917390.5328267614668; Tue, 14 Sep 2021 07:18:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EoVMYY1788612x6JNXwzmtkh; Tue, 14 Sep 2021 07:18:27 -0700 X-Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by mx.groups.io with SMTP id smtpd.web11.10621.1631629104947585056 for ; Tue, 14 Sep 2021 07:18:25 -0700 X-Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 18ED1EeT032226; Tue, 14 Sep 2021 10:18:24 -0400 X-Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b2v8cj5cb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Sep 2021 10:18:24 -0400 X-Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 18EEDUM7022033; Tue, 14 Sep 2021 10:18:23 -0400 X-Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b2v8cj5bv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Sep 2021 10:18:23 -0400 X-Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18EEC2SI025851; Tue, 14 Sep 2021 14:18:22 GMT X-Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma04dal.us.ibm.com with ESMTP id 3b0m3aqvdp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Sep 2021 14:18:22 +0000 X-Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18EEILst14090734 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Sep 2021 14:18:21 GMT X-Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4AD146A063; Tue, 14 Sep 2021 14:18:21 +0000 (GMT) X-Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C96C16A058; Tue, 14 Sep 2021 14:18:20 +0000 (GMT) X-Received: from sbct-2.pok.ibm.com (unknown [9.47.158.152]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 14 Sep 2021 14:18:20 +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, Stefan Berger , Stefan Berger Subject: [edk2-devel] [PATCH v2 2/4] OvmfPkg: Handle TPM 2 physical presence opcodes much earlier Date: Tue, 14 Sep 2021 10:18:16 -0400 Message-Id: <20210914141818.2583900-3-stefanb@linux.ibm.com> In-Reply-To: <20210914141818.2583900-1-stefanb@linux.ibm.com> References: <20210914141818.2583900-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Ibe5MUJaAcCkjwtz2VTHy_GqjowUEyug X-Proofpoint-ORIG-GUID: I4igZZ1gzgKlqy9kXtUmRlNqNTkJkLa5 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: JzpCqVX2VSLmPFcRCVmjN5hRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631629107; bh=qqR1jObmuXrOgJpSoJVaHCk3n/uqbQw8BkMqKYVMav8=; h=Cc:Date:From:Reply-To:Subject:To; b=vJpnMYdfYSuZTB72bk55ZuGy7XuLqKNlDbXelm4tdgFoutMPqmIq6Zja8XMkXjBLfTw nm7fy56eVkoOIOAaOhxOdJbFn1skeSehY/63b4jLC7s7Bc43atg/K4qrVI8tPOJY2Krlp A6YlAzTF7U0KyOme0tdJh22cpAezGC2Z2rc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631629163718100007 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. Signed-off-by: Stefan Berger --- .../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 (#80655): https://edk2.groups.io/g/devel/message/80655 Mute This Topic: https://groups.io/mt/85602991/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-