From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@ibm.com header.s=pp1 header.b=MCckoZrt; spf=pass (domain: linux.ibm.com, ip: 148.163.158.5, mailfrom: stefanb@linux.ibm.com) 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 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=yp8UiB8t6FldxaSnRg0N/RMS85exGulVNgroM/0sd7A=; b=MCckoZrtq3ukkoL8gz8zQliK1vkB0POUzTUcLjelaFhgAUpoZZJzlrtSbjd3aqsKTFs7 3Ka2Jm5kFtRZatvknPF68aC98jArhgsz8dHhx9djxq81D/a9q/YudbqGiUB9Sh1reRlp DZBja25i7/hSX08FgqHUEnpvfjg5+AwNwG8VJlHfXiw/fpGUuPiEY6bnYEu8L2c7i4T/ fT/5v3w9wxwxcM9d28dtvYgLNQ8Ocn/f5WdmiFMuDKD3EFa4Djwz0JRhemHAHoiA3zNS i0NF2IT4HrHYgkNFIZaziSGUiYVsbXkIijV1rysjDgtKYjao2vJpDm5i7diEgZCD0W77 6A== 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 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 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 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 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 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 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) 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) 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: [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> X-Mailer: git-send-email 2.31.1 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 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 clxscore=1015 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109140100 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. 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 ();=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