From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by mx.groups.io with SMTP id smtpd.web12.471.1635269951509426164 for ; Tue, 26 Oct 2021 10:39:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Z4fu6hj+; spf=pass (domain: linux.ibm.com, ip: 148.163.158.5, mailfrom: stefanb@linux.ibm.com) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19QFhTjl009581 for ; Tue, 26 Oct 2021 17:39:10 GMT 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-type : content-transfer-encoding; s=pp1; bh=1tQP4oXhKesEFWA1/5hBkKFhNzKIxTb+YoVmcHatdWY=; b=Z4fu6hj+P0/VesUOBE/qcPin7AehYDGh7sFgVKAZ4IvWclL/vACblvEL3PDog0ZFNTGM fQpEegOraAhJ7mDWRmjIVKV1pwgiTPqxFOsiwklQ/VXhfDQWJrRJ74+K0nJCsLkuZtCx 40DknlUmHGqoLK45LjlADuTCx+kavCDV0mo/7TuEJ6gmKLWO0+TW4mzZ7WPAnf2FDyt9 V3HmwGyqD1VhxJhZKx6ZjoQ3J48eSnQ6tf0smvsdGuEKRxmzAmFeFcjkT3fn3vnNtFqH ZpteQ/ME8SeOvCfWv33k0DsjX7BiRtnsuEc+0AxnW4HdpJ1cMQTNq3UtZx3DDC9tQ8t+ TA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bx4k8rx7q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 26 Oct 2021 17:39:10 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 19QGUdkU028413 for ; Tue, 26 Oct 2021 17:39:09 GMT 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 3bx4k8rx7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Oct 2021 17:39:09 +0000 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 19QHbMOZ010026; Tue, 26 Oct 2021 17:39:09 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma04dal.us.ibm.com with ESMTP id 3bx4f7drqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Oct 2021 17:39:09 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19QHd7WZ52101474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Oct 2021 17:39:07 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C2D206E05B; Tue, 26 Oct 2021 17:39:07 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 24C1C6E058; Tue, 26 Oct 2021 17:39:07 +0000 (GMT) Received: from sbct-2.pok.ibm.com (unknown [9.47.158.152]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 26 Oct 2021 17:39:07 +0000 (GMT) From: "Stefan Berger" To: devel@edk2.groups.io, kraxel@redhat.com, marcandre.lureau@redhat.com Cc: Stefan Berger Subject: [PATCH 1/4] OvmfPkg: Check for TPM 2 early to leave function early Date: Tue, 26 Oct 2021 13:38:57 -0400 Message-Id: <20211026173900.1695306-2-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211026173900.1695306-1-stefanb@linux.ibm.com> References: <20211026173900.1695306-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 74yC7RL7vMjMx2Tnd_4-b5ndoTTr4WaI X-Proofpoint-ORIG-GUID: POnhdjlo8SYG4Py9gqLtZ_VBlwiZcdwB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-26_05,2021-10-26_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 malwarescore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110260096 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable TPM 1.2 and TPM 2 share QEMU's PPI memory/device and for the TPM 2 code not to initilize over the TPM 1.2 initilization, leave the init function early without touching that memory. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Stefan Berger --- .../DxeTcg2PhysicalPresenceLib.c | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPre= senceLib.c b/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPre= senceLib.c index 33a470f6d8..f46a047235 100644 --- a/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLi= b.c +++ b/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLi= b.c @@ -94,7 +94,6 @@ QemuTpmInitPPI ( QEMU_FWCFG_TPM_CONFIG Config;=0D EFI_PHYSICAL_ADDRESS PpiAddress64;=0D EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;=0D - UINTN Idx;=0D =0D if (mPpi !=3D NULL) {=0D return EFI_SUCCESS;=0D @@ -105,6 +104,11 @@ QemuTpmInitPPI ( return Status;=0D }=0D =0D + if (Config.TpmVersion !=3D QEMU_TPM_VERSION_2) {=0D + DEBUG ((DEBUG_ERROR, "[TPM2PP] Not setting up PPI. This is not a TPM 2= .\n"));=0D + return EFI_PROTOCOL_ERROR;=0D + }=0D +=0D mPpi =3D (QEMU_TPM_PPI *)(UINTN)Config.PpiAddress;=0D if (mPpi =3D=3D NULL) {=0D return EFI_PROTOCOL_ERROR;=0D @@ -131,21 +135,18 @@ QemuTpmInitPPI ( goto InvalidPpiAddress;=0D }=0D =0D - for (Idx =3D 0; Idx < ARRAY_SIZE (mPpi->Func); Idx++) {=0D - mPpi->Func[Idx] =3D 0;=0D - }=0D - if (Config.TpmVersion =3D=3D QEMU_TPM_VERSION_2) {=0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_NO_ACTION] =3D TPM_PPI_FLAGS;=0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_CLEAR] =3D TPM_PPI_FLAGS;=0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR] =3D TPM_PPI_FLAGS;=0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2] =3D TPM_PPI_FLAGS;=0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3] =3D TPM_PPI_FLAGS;=0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS] =3D TPM_PPI_FLAGS;=0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_CHANGE_EPS] =3D TPM_PPI_FLAGS;=0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS] =3D TPM_PPI_FLAGS;= =0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID] =3D TPM_PPI_FLAGS;= =0D - mPpi->Func[TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID] =3D TPM_PPI_FLAGS= ;=0D - }=0D + ZeroMem ((void *)mPpi->Func, sizeof(mPpi->Func));=0D +=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_NO_ACTION] =3D TPM_PPI_FLAGS;=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_CLEAR] =3D TPM_PPI_FLAGS;=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR] =3D TPM_PPI_FLAGS;=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2] =3D TPM_PPI_FLAGS;=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3] =3D TPM_PPI_FLAGS;=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS] =3D TPM_PPI_FLAGS;=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_CHANGE_EPS] =3D TPM_PPI_FLAGS;=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS] =3D TPM_PPI_FLAGS;=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID] =3D TPM_PPI_FLAGS;=0D + mPpi->Func[TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID] =3D TPM_PPI_FLAGS;= =0D =0D if (mPpi->In =3D=3D 0) {=0D mPpi->In =3D 1;=0D @@ -833,10 +834,11 @@ Tcg2PhysicalPresenceLibProcessRequest ( =0D Status =3D QemuTpmInitPPI ();=0D if (EFI_ERROR (Status)) {=0D - DEBUG ((DEBUG_INFO, "[TPM2PP] no PPI\n"));=0D return ;=0D }=0D =0D + DEBUG ((DEBUG_INFO, "[TPM2PP] Detected a TPM 2\n"));=0D +=0D //=0D // Check S4 resume=0D //=0D --=20 2.31.1