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.web08.1713.1638387081644947653 for ; Wed, 01 Dec 2021 11:31:21 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hbyaA+d+; 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 1B1JLo5A004018 for ; Wed, 1 Dec 2021 19:31:20 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=hbyaA+d+5chMFPiVTp6+Sp0yiDEiLM2t1rMHHO8Qx1DuUGpkP6JM55j6PSE8Ekk9d/zj h3VcVEd6du7zdaxzTDItMOuAj3tH4Tbnr99CuunyHhDM/NKYlcOn+JvM0k045zR9ufzh exOPAdmeuF/u10j3mqA64Ci5Kl9Na+I7HT6LHpbQGXP0Oxw3ky4kB8E+2sQtLyglfGxH 2QxskOM0Ev3IFnQP6IFTVTjkTG8lNMd05rwpUhjfsZAw8AfAXE/w5QbDIMqk8tYOBc6O L5I6wFACMjswKjd9LrUj8ws4ua8sLEFDyZPMDywBTQLBTdXFC61DHm7a2vbwSYETupew oA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3cpdsaa0ff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 01 Dec 2021 19:31:20 +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 1B1JUBGC022260 for ; Wed, 1 Dec 2021 19:31:19 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 3cpdsaa0dm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Dec 2021 19:31:19 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1B1JCjmW021469; Wed, 1 Dec 2021 19:31:11 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma01dal.us.ibm.com with ESMTP id 3ckcacumju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Dec 2021 19:30:59 +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 1B1JUjn360883284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Dec 2021 19:30:45 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0DAE86E05E; Wed, 1 Dec 2021 19:30:45 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6AD086E056; Wed, 1 Dec 2021 19:30:44 +0000 (GMT) Received: from sbct-2.pok.ibm.com (unknown [9.47.158.152]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 1 Dec 2021 19:30:44 +0000 (GMT) From: "Stefan Berger" To: devel@edk2.groups.io, kraxel@redhat.com, marcandre.lureau@redhat.com Cc: Stefan Berger Subject: [PATCH v3 2/8] OvmfPkg: Check for TPM 2 early to leave function early Date: Wed, 1 Dec 2021 14:30:24 -0500 Message-Id: <20211201193030.3932074-3-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211201193030.3932074-1-stefanb@linux.ibm.com> References: <20211201193030.3932074-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: gp_FB0FHh7n8nO677J4tUDGYilWxTKBy X-Proofpoint-GUID: 3bsrzqerPShXY-wybhcML5hw1_YbLOKH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-30_10,2021-12-01_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 phishscore=0 spamscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112010104 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