From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@ibm.com header.s=pp1 header.b=FnlyliBq; spf=pass (domain: linux.ibm.com, ip: 148.163.156.1, mailfrom: stefanb@linux.ibm.com) 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=gXrk5NMAQN+AewQXR8muPO/aFUWZOE+Zb6Yt9pAClXk=; b=FnlyliBqhFovf7OnfTRSuKVcE33oK4sxKOVKkcoCPA2kmI5ECL+zSV7lziYdBVLBdbCD yN9MMxNQkbvYv64m81uB5YlIldR/5262XMGX+662854D3douvgju3YMu5fWvkHQpjXPT hIrsNp/NvT3cY4FGWfzIkm+5mi794aLa1PhL2NxTPwMe2DQ4C2/rH0x+8SMra72ot7yv lRj/UzVyCeMML0ZDgU1PO8hhFMP3srmwv33vYnoF1xtneDlNd/4UMVgf+UHHFUEhHIA2 qN0HPJE9nvn9LsQSr1hDPrcxxwbC1jVNFYJDR/FeNmz5eNnXRJDBBpPLlBJ+CpAFPFnd 4A== 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 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 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 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 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 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 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) 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) 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: [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> X-Mailer: git-send-email 2.31.1 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 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=909 clxscore=1015 impostorscore=0 adultscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109140070 Content-Transfer-Encoding: quoted-printable 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 ();=0D }=0D =0D + // We need to connect all trusted consoles for TCG PP. Here we treat all= =0D + // consoles in OVMF to be trusted consoles.=0D + PlatformInitializeConsole (=0D + XenDetected() ? gXenPlatformConsole : gPlatformConsole);=0D +=0D + //=0D + // Process TPM PPI request; this may require keyboard input=0D + //=0D + Tcg2PhysicalPresenceLibProcessRequest (NULL);=0D +=0D //=0D // Prevent further changes to LockBoxes or SMRAM.=0D + // Any TPM 2 Physical Presence Interface opcode must be handled before.= =0D //=0D Handle =3D NULL;=0D Status =3D gBS->InstallProtocolInterface (&Handle,=0D @@ -402,9 +413,6 @@ PlatformBootManagerBeforeConsole ( //=0D EfiBootManagerDispatchDeferredImages ();=0D =0D - PlatformInitializeConsole (=0D - XenDetected() ? gXenPlatformConsole : gPlatformConsole);=0D -=0D FrontPageTimeout =3D GetFrontPageTimeoutFromQemu ();=0D PcdStatus =3D PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout);=0D ASSERT_RETURN_ERROR (PcdStatus);=0D @@ -1511,11 +1519,6 @@ PlatformBootManagerAfterConsole ( //=0D PciAcpiInitialization ();=0D =0D - //=0D - // Process TPM PPI request=0D - //=0D - Tcg2PhysicalPresenceLibProcessRequest (NULL);=0D -=0D //=0D // Process QEMU's -kernel command line option=0D //=0D 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 ( //=0D EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);=0D =0D + // We need to connect all trusted consoles for TCG PP. Here we treat all= =0D + // consoles in OVMF to be trusted consoles.=0D + PlatformInitializeConsole (gPlatformConsole);=0D +=0D + //=0D + // Process TPM PPI request=0D + //=0D + Tcg2PhysicalPresenceLibProcessRequest (NULL);=0D +=0D //=0D // Prevent further changes to LockBoxes or SMRAM.=0D + // Any TPM 2 Physical Presence Interface opcode must be handled before.= =0D //=0D Handle =3D NULL;=0D Status =3D gBS->InstallProtocolInterface (&Handle,=0D @@ -390,8 +400,6 @@ PlatformBootManagerBeforeConsole ( //=0D EfiBootManagerDispatchDeferredImages ();=0D =0D - PlatformInitializeConsole (gPlatformConsole);=0D -=0D PlatformRegisterOptionsAndKeys ();=0D =0D //=0D @@ -1445,11 +1453,6 @@ PlatformBootManagerAfterConsole ( //=0D PciAcpiInitialization ();=0D =0D - //=0D - // Process TPM PPI request=0D - //=0D - Tcg2PhysicalPresenceLibProcessRequest (NULL);=0D -=0D //=0D // Perform some platform specific connect sequence=0D //=0D 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 ( //=0D EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);=0D =0D + // We need to connect all trusted consoles for TCG PP. Here we treat all= =0D + // consoles in OVMF to be trusted consoles.=0D + PlatformInitializeConsole (gPlatformConsole);=0D +=0D + //=0D + // Process TPM PPI request=0D + //=0D + Tcg2PhysicalPresenceLibProcessRequest (NULL);=0D +=0D //=0D // Prevent further changes to LockBoxes or SMRAM.=0D + // Any TPM 2 Physical Presence Interface opcode must be handled before.= =0D //=0D Handle =3D NULL;=0D Status =3D gBS->InstallProtocolInterface (&Handle,=0D @@ -353,8 +363,6 @@ PlatformBootManagerBeforeConsole ( //=0D EfiBootManagerDispatchDeferredImages ();=0D =0D - PlatformInitializeConsole (gPlatformConsole);=0D -=0D Status =3D gRT->SetVariable (=0D EFI_TIME_OUT_VARIABLE_NAME,=0D &gEfiGlobalVariableGuid,=0D @@ -1310,11 +1318,6 @@ PlatformBootManagerAfterConsole ( //=0D PciAcpiInitialization ();=0D =0D - //=0D - // Process TPM PPI request=0D - //=0D - Tcg2PhysicalPresenceLibProcessRequest (NULL);=0D -=0D //=0D // Process QEMU's -kernel command line option=0D //=0D --=20 2.31.1