From nobody Mon Feb 9 04:03:29 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+82713+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+82713+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1635269952; cv=none; d=zohomail.com; s=zohoarc; b=EpAPOvwKZvj8aFyfegvkjeMmATCKrBOndwjoPXl6iQ6Kjq/cM7LH5stg6FLpya7/IyYfAWfFYODh5peunvxrvXx4Aa1CoXMavlH0izNrHroJslJi0Xmlnnr+q5F7m4nGIzKjZ8GY6YfghNCTPTPv7G6HaIv9ZyqXn8vVZE2UACA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635269952; h=Content-Type: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=AOOFXPRbyYCPh8vxb/ve08Ofa/dM3d3j4OU4deSyrw8=; b=deLWkLEOvXHrynFmAg1XkdCjufwIiq2bU+FlNcgmDeOEhtshc/dEhWBNgKNUkr1iz6QHoUU8nJPpYMke+rbWs9KR2DT5Hrlyi0/+Mt1yR/ekYkWHrM0XWCMv0e+s9p8pDnoCVDOxw/cWXW3Bm9/KFDGXMQ32gyeohaYULNCiyBE= 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+82713+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 1635269952774192.28284047796285; Tue, 26 Oct 2021 10:39:12 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ktaUYY1788612xWYqdJwuozU; Tue, 26 Oct 2021 10:39:12 -0700 X-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 X-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 X-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 X-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 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 3bx4k8rx7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Oct 2021 17:39:09 +0000 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 19QHbMOZ010026; Tue, 26 Oct 2021 17:39:09 GMT X-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 X-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 X-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) X-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) X-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: [edk2-devel] [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> 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 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: N3xinP0CoriXFgImio8fZuo6x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1635269952; bh=7gygxOyol2jeemlgNLWWUns1wfQPwNpJeBd5RU66UMQ=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Y2hRTC1b5/7ekoF9/p8p/uhQHNRvfGbCZFy0jjwNw4K5Y1qJhvgvPRmiB/xFqg7hGC6 o4jYRkQityTOw5+Pg0W4FZUYOUX6fNk/BRqHvJtitnGQWvCNGf62TYpvJcwJZX5gwPxzu blbMXo1o/FaXSKe9X4EMAB4nI1zRMZpHd5c= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1635269954729100008 Content-Type: text/plain; charset="utf-8" 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; EFI_PHYSICAL_ADDRESS PpiAddress64; EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; - UINTN Idx; =20 if (mPpi !=3D NULL) { return EFI_SUCCESS; @@ -105,6 +104,11 @@ QemuTpmInitPPI ( return Status; } =20 + if (Config.TpmVersion !=3D QEMU_TPM_VERSION_2) { + DEBUG ((DEBUG_ERROR, "[TPM2PP] Not setting up PPI. This is not a TPM 2= .\n")); + return EFI_PROTOCOL_ERROR; + } + mPpi =3D (QEMU_TPM_PPI *)(UINTN)Config.PpiAddress; if (mPpi =3D=3D NULL) { return EFI_PROTOCOL_ERROR; @@ -131,21 +135,18 @@ QemuTpmInitPPI ( goto InvalidPpiAddress; } =20 - for (Idx =3D 0; Idx < ARRAY_SIZE (mPpi->Func); Idx++) { - mPpi->Func[Idx] =3D 0; - } - if (Config.TpmVersion =3D=3D QEMU_TPM_VERSION_2) { - mPpi->Func[TCG2_PHYSICAL_PRESENCE_NO_ACTION] =3D TPM_PPI_FLAGS; - mPpi->Func[TCG2_PHYSICAL_PRESENCE_CLEAR] =3D TPM_PPI_FLAGS; - mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR] =3D TPM_PPI_FLAGS; - mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2] =3D TPM_PPI_FLAGS; - mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3] =3D TPM_PPI_FLAGS; - mPpi->Func[TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS] =3D TPM_PPI_FLAGS; - mPpi->Func[TCG2_PHYSICAL_PRESENCE_CHANGE_EPS] =3D TPM_PPI_FLAGS; - mPpi->Func[TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS] =3D TPM_PPI_FLAGS; - mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID] =3D TPM_PPI_FLAGS; - mPpi->Func[TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID] =3D TPM_PPI_FLAGS; - } + ZeroMem ((void *)mPpi->Func, sizeof(mPpi->Func)); + + mPpi->Func[TCG2_PHYSICAL_PRESENCE_NO_ACTION] =3D TPM_PPI_FLAGS; + mPpi->Func[TCG2_PHYSICAL_PRESENCE_CLEAR] =3D TPM_PPI_FLAGS; + mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR] =3D TPM_PPI_FLAGS; + mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2] =3D TPM_PPI_FLAGS; + mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3] =3D TPM_PPI_FLAGS; + mPpi->Func[TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS] =3D TPM_PPI_FLAGS; + mPpi->Func[TCG2_PHYSICAL_PRESENCE_CHANGE_EPS] =3D TPM_PPI_FLAGS; + mPpi->Func[TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS] =3D TPM_PPI_FLAGS; + mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID] =3D TPM_PPI_FLAGS; + mPpi->Func[TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID] =3D TPM_PPI_FLAGS; =20 if (mPpi->In =3D=3D 0) { mPpi->In =3D 1; @@ -833,10 +834,11 @@ Tcg2PhysicalPresenceLibProcessRequest ( =20 Status =3D QemuTpmInitPPI (); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "[TPM2PP] no PPI\n")); return ; } =20 + DEBUG ((DEBUG_INFO, "[TPM2PP] Detected a TPM 2\n")); + // // Check S4 resume // --=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 (#82713): https://edk2.groups.io/g/devel/message/82713 Mute This Topic: https://groups.io/mt/86608979/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-