From nobody Wed May 15 08:28:02 2024 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+89030+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+89030+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650328006; cv=none; d=zohomail.com; s=zohoarc; b=WpgFjO9qwfqw6+pz3bdNIkplOZJgaxi8rMAZcjouqShOJnEeoydWqsyPfwpoqTlAoiYeR4Gn9MC1nNB1zVyAlTBUxxoUxkcSP8X1StClLqs7lWVMuQgXYHB20bAkHFuxjUGljq9O+rgWCL6PFSZ1/A0wk8Ol+AjNk57Xt3hryF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650328006; h=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=DTrKbrbB+XL4vouvrVTUsXUmLrOj/w2lu9aRSZirXik=; b=fFVomJEaScdwBlQCuzxdrsNdzvkf1T3yvbMWYMOs5RJKiAYVM7TNTgHQMMqAvLH3c6gRJzCirWO7bmH6J+MZBraX5WEjfeCqZDM3En+1taZN+czbbpjaKKlnnLgntm8LAczkvWZ40hhBfiqzo749ik+Lr69/li4gWWZIkdziLaM= 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+89030+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 1650328006083524.9442197974233; Mon, 18 Apr 2022 17:26:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id HLcDYY1788612x4mnbaHhkCm; Mon, 18 Apr 2022 17:26:45 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.3858.1650328002343868729 for ; Mon, 18 Apr 2022 17:26:45 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="326540303" X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="326540303" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:44 -0700 X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="529079938" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.171.121]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:41 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , James Bottomley , Jiewen Yao , Gerd Hoffmann , Brijesh Singh , Erdem Aktas , Tom Lendacky Subject: [edk2-devel] [PATCH V4 1/7] MdePkg: Add CC_GUEST_TYPE in ConfidentialComputingGuestAttr.h Date: Tue, 19 Apr 2022 08:26:22 +0800 Message-Id: <004da33b7bd5923c91e72ae68912b3f660bae751.1650326140.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 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,min.m.xu@intel.com X-Gm-Message-State: asdy1jpHx8KJ6ZLUj3xTahbux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650328005; bh=jXnDBLxnRxSOVfsenG9DLhXAP0JKLaU4GSxHxr6vAa8=; h=Cc:Date:From:Reply-To:Subject:To; b=J+LSUqwG6J8QhRl/6QZFeDVixM+hi5a2wrMFi7tOauKFNgwsge77CDecWtXO5SGVCSP Mb/vbPDPdL72Q7MCv23OLsnP6+M3BASihDcLa9aHsJkDDA9RcluV73ROwscxnZsD/rJS1 0/mjXRAlpIEbnhRugncp+pYoM1dwg9wO3e0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650328006310100005 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3902 The confidential computing guest type (GUEST_TYPE) was defined in OvmfPkg/Include/WorkArea.h. Now it is to be moved to MdePkg/Include/ConfidentialComputingGuestAttr.h and renamed as CC_GUEST_TYPE. There are 2 reasons for this change. 1. CC_GUEST_TYPE is a generic definition and will be used in CcProbeLib which is defined in MdePkg. 2. Based on the latest edk2 coding style: - First character should be upper case - Must contain lower case characters - No white space characters - Global variable name must start with a 'g' As the first step CC_GUEST_TYPE is defined in this patch. In the next patch GUEST_TYPE will be deleted. This is to make sure the bisect work correctly. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Brijesh Singh Cc: Erdem Aktas Cc: Tom Lendacky Reviewed-by: Liming Gao Reviewed-by: Jiewen Yao Reviewed-by: Tom Lendacky Signed-off-by: Min Xu --- MdePkg/Include/ConfidentialComputingGuestAttr.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/ConfidentialComputingGuestAttr.h b/MdePkg/Inclu= de/ConfidentialComputingGuestAttr.h index dd2541c6dcdf..44e6df800207 100644 --- a/MdePkg/Include/ConfidentialComputingGuestAttr.h +++ b/MdePkg/Include/ConfidentialComputingGuestAttr.h @@ -1,5 +1,5 @@ /** @file -Definitions for Confidential Computing Attribute +Definitions for Confidential Computing Guest Attributes =20 Copyright (c) 2021 AMD Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -9,6 +9,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef CONFIDENTIAL_COMPUTING_GUEST_ATTR_H_ #define CONFIDENTIAL_COMPUTING_GUEST_ATTR_H_ =20 +// +// Confidential computing guest type +// +typedef enum { + CcGuestTypeNonEncrypted =3D 0, + CcGuestTypeAmdSev, + CcGuestTypeIntelTdx, +} CC_GUEST_TYPE; + typedef enum { /* The guest is running with memory encryption disabled. */ CCAttrNotEncrypted =3D 0, --=20 2.29.2.windows.2 -=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 (#89030): https://edk2.groups.io/g/devel/message/89030 Mute This Topic: https://groups.io/mt/90552651/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- From nobody Wed May 15 08:28:02 2024 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+89031+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+89031+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650328008; cv=none; d=zohomail.com; s=zohoarc; b=XyeUPHbQctys4ygCEvivn4E7S8TFNpkIShfFfuNY0LKZHmr1/fKj3DSLHLJ6Meef/o9rnuKrb4DNyQwaXNgeummH4TFWK4X2BB9/SiZm6epozJ3oG4SjHFC+Ha7zvKBfJK7WaXaGXf8vkfZXDZhpNV7vE3rcAP86F5wEz/sIQnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650328008; h=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=ol8ROYc3zcBQvP/mJoV4M6w8f6LxOX5N1/mxOnt9YOo=; b=i1XmtvkbaZWzGLZNFUIY60qPuLRsIeAQ50Yqx0fdb5+tOdmoBMup4DFLrw5eZZh2PKGrAKduKLPD6vwJ+Fk2sBSVRuTrWmzVZPNTxVgCJuhqEgpMrDnFpjF5sGJsgE/R6PceMqoyz8866Nos10sHC5hZtlfpnO8fyGZXrJ5kwjs= 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+89031+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 1650328008800735.4754322926684; Mon, 18 Apr 2022 17:26:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id uC6jYY1788612xVmCfFOMiqK; Mon, 18 Apr 2022 17:26:48 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.3858.1650328002343868729 for ; Mon, 18 Apr 2022 17:26:47 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="326540332" X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="326540332" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:47 -0700 X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="529079948" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.171.121]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:44 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , James Bottomley , Jiewen Yao , Gerd Hoffmann , Brijesh Singh , Erdem Aktas , Tom Lendacky Subject: [edk2-devel] [PATCH V4 2/7] OvmfPkg: Replace GUEST_TYPE with CC_GUEST_TYPE Date: Tue, 19 Apr 2022 08:26:23 +0800 Message-Id: <431ed9a322869e20fd6257eb68e6a286aff75757.1650326140.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 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,min.m.xu@intel.com X-Gm-Message-State: vhQRjTowzeUCcgTqNKGiBR8Ux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650328008; bh=xMbK3g43sBGXPjroMCu3vkMu4oqPCSF3egBLcbPAocU=; h=Cc:Date:From:Reply-To:Subject:To; b=ttvPQiRPNhY2CokM1GlnPxNP76K1Zaw7VHLXV/X4DBs+cfFnjW/Zuc64HpMFPXStgeR wGIZZy2ZlDTS+iGYRvl1qXNdWV2jq4qegJ5lTEHoh1jqQQ+HDOId5r52gioM0x2rL0Ef0 CrX7DFmGq/tlkaU/QMTMLIPpXzOpF7V/r5U= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650328010606100011 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3902 Replace GUEST_TYPE with CC_GUEST_TYPE which is defined in MdePkg/Include/ConfidentialComputingGuestAttr.h. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Brijesh Singh Cc: Erdem Aktas Cc: Tom Lendacky Reviewed-by: Jiewen Yao Reviewed-by: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/Include/WorkArea.h | 9 +-------- .../BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c | 2 +- .../BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c | 2 +- OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 2 +- OvmfPkg/Sec/AmdSev.c | 2 +- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/OvmfPkg/Include/WorkArea.h b/OvmfPkg/Include/WorkArea.h index b67edd14e79f..bf56fc4a6f65 100644 --- a/OvmfPkg/Include/WorkArea.h +++ b/OvmfPkg/Include/WorkArea.h @@ -10,14 +10,7 @@ #ifndef __OVMF_WORK_AREA_H__ #define __OVMF_WORK_AREA_H__ =20 -// -// Guest type for the work area -// -typedef enum { - GUEST_TYPE_NON_ENCRYPTED, - GUEST_TYPE_AMD_SEV, - GUEST_TYPE_INTEL_TDX, -} GUEST_TYPE; +#include =20 // // Confidential computing work area header definition. Any change diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibIntern= al.c b/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c index 3f8f91a5da12..41d1246a5b31 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c @@ -36,7 +36,7 @@ GetSevEsWorkArea ( // // If its not SEV guest then SevEsWorkArea is not valid. // - if ((WorkArea =3D=3D NULL) || (WorkArea->Header.GuestType !=3D GUEST_TYP= E_AMD_SEV)) { + if ((WorkArea =3D=3D NULL) || (WorkArea->Header.GuestType !=3D CcGuestTy= peAmdSev)) { return NULL; } =20 diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibIntern= al.c b/OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c index 80aceba01bcf..27148c7e337a 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c @@ -36,7 +36,7 @@ GetSevEsWorkArea ( // // If its not SEV guest then SevEsWorkArea is not valid. // - if ((WorkArea =3D=3D NULL) || (WorkArea->Header.GuestType !=3D GUEST_TYP= E_AMD_SEV)) { + if ((WorkArea =3D=3D NULL) || (WorkArea->Header.GuestType !=3D CcGuestTy= peAmdSev)) { return NULL; } =20 diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c b/OvmfPkg/Library/= QemuFwCfgLib/QemuFwCfgPei.c index b8230613dcea..7ab7027af168 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c @@ -35,7 +35,7 @@ QemuFwCfgIsTdxGuest ( CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER *CcWorkAreaHeader; =20 CcWorkAreaHeader =3D (CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER *)FixedPcd= Get32 (PcdOvmfWorkAreaBase); - return (CcWorkAreaHeader !=3D NULL && CcWorkAreaHeader->GuestType =3D=3D= GUEST_TYPE_INTEL_TDX); + return (CcWorkAreaHeader !=3D NULL && CcWorkAreaHeader->GuestType =3D=3D= CcGuestTypeIntelTdx); } =20 /** diff --git a/OvmfPkg/Sec/AmdSev.c b/OvmfPkg/Sec/AmdSev.c index d8fd35650d7d..6af38aaf46ee 100644 --- a/OvmfPkg/Sec/AmdSev.c +++ b/OvmfPkg/Sec/AmdSev.c @@ -251,7 +251,7 @@ IsSevGuest ( =20 WorkArea =3D (OVMF_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase); =20 - return ((WorkArea !=3D NULL) && (WorkArea->Header.GuestType =3D=3D GUEST= _TYPE_AMD_SEV)); + return ((WorkArea !=3D NULL) && (WorkArea->Header.GuestType =3D=3D CcGue= stTypeAmdSev)); } =20 /** --=20 2.29.2.windows.2 -=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 (#89031): https://edk2.groups.io/g/devel/message/89031 Mute This Topic: https://groups.io/mt/90552652/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- From nobody Wed May 15 08:28:02 2024 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+89032+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+89032+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650328011; cv=none; d=zohomail.com; s=zohoarc; b=BRmSoiJAt5xCR1A0HgISLdivJ9+SVRQbVKTvOkQj8nVPHJY+ZLtHPT/E23ovO01SpAxT8gOsonSXjCuFkCyOvpJO02PwkSy0+vqMF9Oc/97eaiS0ud+zAU4zP5tSIW0EGujp9zj3QbViUwwvyiJhRdWg1PWmUrEVaU7FO8caico= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650328011; h=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=RmbD3aM74CrVd7LUZKeipHKQDYgsFGD3ZCL/YRnYAPA=; b=YB7178R/OZ+8QTOWr3OS3Y0mY1K0YgtthpjS95IBp6eHyhVdkIjxnq8DJIP4C8polYz7Guy+wlkhFHGLXXaW8jflwAvgsYHBUUkegtNVAvYJTiSj9IM+R0genY4+bUfcA9Ob06bTw2sRglSHf5xg1oNZxzpeTTT+3YBciICV9gU= 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+89032+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 165032801121732.34147565287833; Mon, 18 Apr 2022 17:26:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id AHYvYY1788612xrvaewAxV8W; Mon, 18 Apr 2022 17:26:50 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.3858.1650328002343868729 for ; Mon, 18 Apr 2022 17:26:50 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="326540348" X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="326540348" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:49 -0700 X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="529079988" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.171.121]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:47 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky Subject: [edk2-devel] [PATCH V4 3/7] MdePkg: Add CcProbeLibNull Date: Tue, 19 Apr 2022 08:26:24 +0800 Message-Id: <90ad9eafb65e53d912d3f76a582a58e340bd7bda.1650326140.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 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,min.m.xu@intel.com X-Gm-Message-State: oU3NpaOeCFTJXJid5CMANT2ux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650328010; bh=0m6nSVITw1N+pPLTN2A21RL63n6P6eAU2bEK6SRGrwg=; h=Cc:Date:From:Reply-To:Subject:To; b=ALxs2ksm/9yZaBAFK4IyLaR3K4gmx69eGBxBTDNx0tNrGCBMuFsRv0/EFUxZgfaH8gz OTmZX7dM8DVbidPgVc+swZFutLcLsomUEeoc6950Zz+3bZrYOoVTknwMmaNaCOdW8ufKf N0NhzV0n8Y6zVuggb7DXlSV88139Wa8ddLw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650328012367100013 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3902 CcProbeLib is used to probe the Confidential Computing guest type. This library is designed to run on SEC / PEI / DXE phases. A null instance of the library always returns CCGuestTypeNonEncrypted. A platform specific CcProbeLib will be implemented, for example, in OvmfPkg. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Reviewed-by: Liming Gao Reviewed-by: Jiewen Yao Reviewed-by: Tom Lendacky Signed-off-by: Min Xu --- MdePkg/Include/Library/CcProbeLib.h | 26 +++++++++++++++++++ .../Library/CcProbeLibNull/CcProbeLibNull.c | 26 +++++++++++++++++++ .../Library/CcProbeLibNull/CcProbeLibNull.inf | 21 +++++++++++++++ MdePkg/MdePkg.dec | 5 ++++ MdePkg/MdePkg.dsc | 1 + 5 files changed, 79 insertions(+) create mode 100644 MdePkg/Include/Library/CcProbeLib.h create mode 100644 MdePkg/Library/CcProbeLibNull/CcProbeLibNull.c create mode 100644 MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf diff --git a/MdePkg/Include/Library/CcProbeLib.h b/MdePkg/Include/Library/C= cProbeLib.h new file mode 100644 index 000000000000..2857dddfb2d3 --- /dev/null +++ b/MdePkg/Include/Library/CcProbeLib.h @@ -0,0 +1,26 @@ +/** @file + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef CC_PROBE_LIB_H_ +#define CC_PROBE_LIB_H_ + +#include + +/** + Probe the ConfidentialComputing Guest type. See defition of + CC_GUEST_TYPE in . + + @return The guest type + +**/ +UINT8 +EFIAPI +CcProbe ( + VOID + ); + +#endif diff --git a/MdePkg/Library/CcProbeLibNull/CcProbeLibNull.c b/MdePkg/Librar= y/CcProbeLibNull/CcProbeLibNull.c new file mode 100644 index 000000000000..ca4111dc3077 --- /dev/null +++ b/MdePkg/Library/CcProbeLibNull/CcProbeLibNull.c @@ -0,0 +1,26 @@ +/** @file + + Null stub of CcProbeLib + + Copyright (c) 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + Probe the ConfidentialComputing Guest type. See defition of + CC_GUEST_TYPE in . + + @return The guest type + +**/ +UINT8 +EFIAPI +CcProbe ( + VOID + ) +{ + return CcGuestTypeNonEncrypted; +} diff --git a/MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf b/MdePkg/Libr= ary/CcProbeLibNull/CcProbeLibNull.inf new file mode 100644 index 000000000000..f37c25f73439 --- /dev/null +++ b/MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf @@ -0,0 +1,21 @@ +## @file +# CcProbeLib null instance. +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D CcProbeLibNull + FILE_GUID =3D B15D67FE-0DAC-4316-8E26-8A6b85E43782 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D CcProbeLib + +[Sources] + CcProbeLibNull.c + +[Packages] + MdePkg/MdePkg.dec diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 1934c9840423..faeb28c80cbd 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -267,6 +267,11 @@ # RegisterFilterLib|Include/Library/RegisterFilterLib.h =20 + ## @libraryclass This library provides interfances to probe Confidenti= alComputing guest type. + # + # + CcProbeLib|Include/Library/CcProbeLib.h + [LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64] ## @libraryclass Provides services to generate random number. # diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index d6a7af412be7..c8d282882ec1 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -130,6 +130,7 @@ MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib= .inf =20 MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf + MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf =20 [Components.IA32, Components.X64, Components.ARM, Components.AARCH64] # --=20 2.29.2.windows.2 -=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 (#89032): https://edk2.groups.io/g/devel/message/89032 Mute This Topic: https://groups.io/mt/90552653/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- From nobody Wed May 15 08:28:02 2024 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+89033+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+89033+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650328014; cv=none; d=zohomail.com; s=zohoarc; b=lgMsAlUJXrvkhfYKxm9r0hlBV97PT2eNj2T80dMws6KsxLKiR8/p7hSw8skhNPrT1Wb/ETHrEeoObj8qSOWfSbeoT6QVtsrpuN9J9mzpb+El59NP1bB2ldS2QHuY48KWpO63NX/DXvDPNzkg3bWnQtb87I8/jFkHeyL9ukui4+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650328014; h=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=4LCn3gdJOpxSYZqiXMXBdSmmS1zPW+KJQTl/9V5b5aU=; b=DXZBXKXOvQghwFS4IjMxV0zREFPJywmFFhD/2tXoFWs1ei1/K2+qIjZYh6ZeNJUqePHnOHdzzah8u2LsrHm3vTx8yaF6QW10O5Yg4mHegaHeOsuNtPsci/KXmiTnWLmY4IqC3eYTwNa7fPLLLKbMVFNOdiPhjAEsVRvLAvymcLQ= 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+89033+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 1650328014122376.1797890589337; Mon, 18 Apr 2022 17:26:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id L0ZMYY1788612xNLq1CH84Gn; Mon, 18 Apr 2022 17:26:53 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.3858.1650328002343868729 for ; Mon, 18 Apr 2022 17:26:53 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="326540366" X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="326540366" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:53 -0700 X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="529080031" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.171.121]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:49 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , James Bottomley , James Bottomley , Jiewen Yao , Gerd Hoffmann , Brijesh Singh , Erdem Aktas , Tom Lendacky Subject: [edk2-devel] [PATCH V4 4/7] OvmfPkg: Add CcProbeLib Date: Tue, 19 Apr 2022 08:26:25 +0800 Message-Id: In-Reply-To: References: MIME-Version: 1.0 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,min.m.xu@intel.com X-Gm-Message-State: scLpfVfYdoC4VQacqmhbIYb4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650328013; bh=KLc0hvwy/mdydYINIupddDy/P2p4ji8LNbYLXat9A8w=; h=Cc:Date:From:Reply-To:Subject:To; b=fgoupfafX5Ggs62M8W/pSymVk5RVJpleYbTi3NXmn4t59wrjtBaSb+VKm+e3ZzWKw26 GY9tiNpouLTo9+fp+XNMV7xpcZOiRMNbQl8t9tHnmxHdiBtGetRO6cxX8xN94AdSN9fvR 84xbTdY0OGG/z5RPgG/nsjEG5cYpWIvaRzQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650328014372100017 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3902 This is the OvmfPkg specific CcProbeLib. It checks the Ovmf WorkArea (PcdOvmfWorkAreaBase) to return the guest type. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: James Bottomley Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Brijesh Singh Cc: Erdem Aktas Cc: Tom Lendacky Reviewed-by: Jiewen Yao Reviewed-by: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/Library/CcProbeLib/CcProbeLib.c | 31 +++++++++++++++++++++++ OvmfPkg/Library/CcProbeLib/CcProbeLib.inf | 25 ++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 OvmfPkg/Library/CcProbeLib/CcProbeLib.c create mode 100644 OvmfPkg/Library/CcProbeLib/CcProbeLib.inf diff --git a/OvmfPkg/Library/CcProbeLib/CcProbeLib.c b/OvmfPkg/Library/CcPr= obeLib/CcProbeLib.c new file mode 100644 index 000000000000..d698e5c8d7f8 --- /dev/null +++ b/OvmfPkg/Library/CcProbeLib/CcProbeLib.c @@ -0,0 +1,31 @@ +/** @file + + CcProbeLib is used to probe the Confidential computing guest type. + + Copyright (c) 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +/** + Probe the ConfidentialComputing Guest type. See defition of + CC_GUEST_TYPE in . + + @return The guest type + +**/ +UINT8 +EFIAPI +CcProbe ( + VOID + ) +{ + OVMF_WORK_AREA *WorkArea; + + WorkArea =3D (OVMF_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase); + + return WorkArea !=3D NULL ? WorkArea->Header.GuestType : CcGuestTypeNonE= ncrypted; +} diff --git a/OvmfPkg/Library/CcProbeLib/CcProbeLib.inf b/OvmfPkg/Library/Cc= ProbeLib/CcProbeLib.inf new file mode 100644 index 000000000000..5300c9ba2644 --- /dev/null +++ b/OvmfPkg/Library/CcProbeLib/CcProbeLib.inf @@ -0,0 +1,25 @@ +## @file +# CcProbeLib is used to probe Confidential Computing guest type. +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D CcProbeLib + FILE_GUID =3D 05184ec9-abb0-4491-8584-e388639a7c48 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D CcProbeLib + +[Sources] + CcProbeLib.c + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase --=20 2.29.2.windows.2 -=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 (#89033): https://edk2.groups.io/g/devel/message/89033 Mute This Topic: https://groups.io/mt/90552654/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- From nobody Wed May 15 08:28:02 2024 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+89034+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+89034+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650328016; cv=none; d=zohomail.com; s=zohoarc; b=IrBiwXiP9y1QcS+yjMxy+PuH0wnZoN8kRPYbNlKSOxyjXEeC2/p1JfF+yaMXv727GAwGojb6cuDCSaDtbl1Ezi12cT4V1xz/w8x/J4AssSEV0H2uekOYES4Xsg7sJ5/c0wYssgzvfRUypOaZKWKuv+n4SUkuvJU3GvqLP2H8GqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650328016; h=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=X6AWEh/lYTsxmDB5fYUuVnt155F/Oqlsf6gWJKDvfQo=; b=Fye8FSyXwr3eHCnO2riggxEPk8CG+8s6v4WTOLViJ9hpatEtSQ6ZHbvyMlDN0+5QFNkU/EaK7NnmwuXY6se6srX6eSDiFiAAgsbmC6u0d5p+4fQpaphE83KG8A4AtrHmDiOYidg/AlqDsJybIOdcLrRzdf60sPbFsmBzD2piJAI= 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+89034+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 1650328016943861.4191101600181; Mon, 18 Apr 2022 17:26:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id W4vHYY1788612xl06eDrwzoX; Mon, 18 Apr 2022 17:26:56 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.3858.1650328002343868729 for ; Mon, 18 Apr 2022 17:26:56 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="326540388" X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="326540388" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:55 -0700 X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="529080053" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.171.121]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:53 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , James Bottomley , James Bottomley , Jiewen Yao , Gerd Hoffmann , Brijesh Singh , Erdem Aktas , Tom Lendacky Subject: [edk2-devel] [PATCH V4 5/7] OvmfPkg: Add CcProbeLib in *.dsc Date: Tue, 19 Apr 2022 08:26:26 +0800 Message-Id: In-Reply-To: References: MIME-Version: 1.0 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,min.m.xu@intel.com X-Gm-Message-State: McYyZIGylSRueLjzv1MpwyfJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650328016; bh=a9kJUTzpNLXnrNBqHcHOLgIKFCcgwDtSovwvEo+TIts=; h=Cc:Date:From:Reply-To:Subject:To; b=meDco2yO6Bn+K/0GheTg567WexTiSVRPA3GZtRRzht8HsJttyqtRLJxiEYhXiXklqXk R1acfLAiREqrrWvYGF5WfI1ox3mFfDqhxv5BC3reDGv513Ushea5RywdflcZ40DUMDMDB gUU5wF69QDdw9fOG+kFvFFGxE1rFrww5iPY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650328018579100023 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3902 CcProbeLib is imported in BaseIoLibIntrinsicSev. OvmfPkg/Library/CcProbeLib is the OvmfPkg version which checks OvmfWorkArea to return the Cc guest type. It is included in OvmfPkgX64.dsc and IntelTdx/IntelTdxX64.dsc. Other .dsc include the MdePkg/Library/CcProbeLibNull because Cc guest is not supported in those projects. Cc: James Bottomley Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Brijesh Singh Cc: Erdem Aktas Cc: Tom Lendacky Reviewed-by: Jiewen Yao Reviewed-by: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + OvmfPkg/Bhyve/BhyveX64.dsc | 1 + OvmfPkg/CloudHv/CloudHvX64.dsc | 1 + OvmfPkg/IntelTdx/IntelTdxX64.dsc | 1 + OvmfPkg/Microvm/MicrovmX64.dsc | 1 + OvmfPkg/OvmfPkgIa32.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + OvmfPkg/OvmfXen.dsc | 1 + 9 files changed, 9 insertions(+) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index fcdc3efab204..1c088f25fa4b 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -149,6 +149,7 @@ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPc= iSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf + CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc index e1b6b8e15f36..a8fa4d38ab60 100644 --- a/OvmfPkg/Bhyve/BhyveX64.dsc +++ b/OvmfPkg/Bhyve/BhyveX64.dsc @@ -146,6 +146,7 @@ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPc= iSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf + CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc index 20f3bc340807..d1c85f60c768 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.dsc +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc @@ -158,6 +158,7 @@ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPc= iSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf + CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX6= 4.dsc index 245155d41b30..73a6c30096a8 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -135,6 +135,7 @@ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPc= iSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf + CcProbeLib|OvmfPkg/Library/CcProbeLib/CcProbeLib.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc index 59580ccd4691..c9c843e116a9 100644 --- a/OvmfPkg/Microvm/MicrovmX64.dsc +++ b/OvmfPkg/Microvm/MicrovmX64.dsc @@ -156,6 +156,7 @@ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPc= iSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf + CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index e4218b01f0fc..9e4ecd21fb17 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -154,6 +154,7 @@ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPc= iSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf + CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index a80cdaacb8bc..75fb8095eec2 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -158,6 +158,7 @@ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPc= iSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf + CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index fb2899f8a1be..2e534d0d2478 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -165,6 +165,7 @@ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPc= iSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf + CcProbeLib|OvmfPkg/Library/CcProbeLib/CcProbeLib.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 7bd594c6e263..8d420cf54371 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -147,6 +147,7 @@ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPc= iSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf + CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf --=20 2.29.2.windows.2 -=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 (#89034): https://edk2.groups.io/g/devel/message/89034 Mute This Topic: https://groups.io/mt/90552656/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- From nobody Wed May 15 08:28:02 2024 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+89035+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+89035+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650328020; cv=none; d=zohomail.com; s=zohoarc; b=dJMIGN2R7gCifxDYFIcgdffAUsjIL3qTDRqPp7PPCkCGLR34VQ7Vf+3oQY67+Ax7jj9iIQ/+Ei0cyReYavSeJZm8p15B+GfzNpRRAL/8rE3rbDhzZT0BPDEDQ8piLrogupsFVKVrw0LMpLj/vFKXKazsofRjoNeNfMU9Pgpn1QI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650328019; h=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=iEz+JxnFjyS93QdvSaOIhIpAFVLbTw4C53oruI0BG5Y=; b=B3VIqhE440JPMvFVPihfX4ot9UYesgNxQIBZ1aknPbmfnsV7jJn2oKxHWo2eQYqufg8qK1XWOIp8Ddncq8EdWBRz36Y+qd6FVwg9SixRFPUIqqAySRyjaKfBAAyVlpdS57XTLm5nJbF7HxV6eQoLObmcDILOfYUzyH06P8SKZK8= 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+89035+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 1650328019995932.3152158579032; Mon, 18 Apr 2022 17:26:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id gJiWYY1788612x9vFx7i5g3j; Mon, 18 Apr 2022 17:26:59 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.3858.1650328002343868729 for ; Mon, 18 Apr 2022 17:26:58 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="326540411" X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="326540411" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:58 -0700 X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="529080074" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.171.121]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:55 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , James Bottomley , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky Subject: [edk2-devel] [PATCH V4 6/7] MdePkg: Probe Cc guest in BaseIoLibIntrinsicSev Date: Tue, 19 Apr 2022 08:26:27 +0800 Message-Id: <1cc7e25b9bd4ca58f3e6014324327a1dac5420b5.1650326140.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 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,min.m.xu@intel.com X-Gm-Message-State: PrhwPcr6bEK4EwffeOqFaFrex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650328019; bh=PuE2Mj+9MNLCkA+Fi7qzsJshSEF+u6qn7Z4p+RhFZC4=; h=Cc:Date:From:Reply-To:Subject:To; b=pzdzM2b49Z7WaZsKfFP02ZLo9O8X8hcI4fswoZ6pHdxlIH7djb/w1TVtpycC6xbvDR4 Yq3LGRjhpPWyAFRzz70W1AJNSLP2Cy3vUJnQOgiS+r/BoSXbpk2HaYgOhADuQVX5yfs7q DxD2tscguOncnTuvpHISwDMcxb6xTcuEdHY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650328020406100025 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3902 Bad IO performance in SEC phase is observed after TDX features was introduced. (after commit b6b2de884864 - "MdePkg: Support mmio for Tdx guest in BaseIoLibIntrinsic"). This is because IsTdxGuest() will be called in each MMIO operation. It is trying to cache the result of the probe in the efi data segment. However, that doesn't work in SEC, because the data segment is read only (so the write seems to succeed but a read will always return the original value), leading to us calling TdIsEnabled() check for every mmio we do, which is causing the slowdown because it's very expensive. This patch is to call CcProbe instead of TdIsEnabled in IsTdxGuest. Null instance of CcProbe always returns CCGuestTypeNonEncrypted. Its OvmfPkg version returns the guest type in Ovmf work area. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: James Bottomley Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Reviewed-by: Liming Gao Reviewed-by: Jiewen Yao Reviewed-by: Tom Lendacky Signed-off-by: Min Xu --- .../BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf | 1 + .../Library/BaseIoLibIntrinsic/IoLibInternalTdx.c | 13 ++----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf b/= MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf index 7fe1c60f046e..e1b8298ac451 100644 --- a/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf +++ b/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf @@ -55,6 +55,7 @@ DebugLib BaseLib RegisterFilterLib + CcProbeLib =20 [LibraryClasses.X64] TdxLib diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibInternalTdx.c b/MdePkg/= Library/BaseIoLibIntrinsic/IoLibInternalTdx.c index 1e539dbfbbad..ec837f5eb03e 100644 --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLibInternalTdx.c +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibInternalTdx.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "IoLibTdx.h" =20 // Size of TDVMCALL Access, including IO and MMIO @@ -22,9 +23,6 @@ #define TDVMCALL_ACCESS_READ 0 #define TDVMCALL_ACCESS_WRITE 1 =20 -BOOLEAN mTdxEnabled =3D FALSE; -BOOLEAN mTdxProbed =3D FALSE; - /** Check if it is Tdx guest. =20 @@ -38,14 +36,7 @@ IsTdxGuest ( VOID ) { - if (mTdxProbed) { - return mTdxEnabled; - } - - mTdxEnabled =3D TdIsEnabled (); - mTdxProbed =3D TRUE; - - return mTdxEnabled; + return CcProbe () =3D=3D CcGuestTypeIntelTdx; } =20 /** --=20 2.29.2.windows.2 -=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 (#89035): https://edk2.groups.io/g/devel/message/89035 Mute This Topic: https://groups.io/mt/90552658/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- From nobody Wed May 15 08:28:02 2024 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+89036+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+89036+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650328022; cv=none; d=zohomail.com; s=zohoarc; b=XH/Ghe73ex8aWTO2Z7M1KEaq/fmWMOlJEX3/Cf/qITB4FR/WrU3F1efWXAY6CgPURwOgM868J2d+wQXSs19/sOB+9f7xwBwhFtBlkes5llLvWICMOnmc8ZbljsV5vEv3YPQrE5imoRdQwZ0JPPh5tiTOk/vSBE9bgG9qgUb711c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650328022; h=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=/x/Dz7n6PuxDLBmuOO6rju8BiquYlw2gaBcMc1rJCcw=; b=bHsDgcTvguFd8i+6suF4MgiQQ2w2lTvmCQJIOU2k3E0VCLE8fKphrBKX/td7ZWmHbObSqpYJWY13rAyIzcw1PUlnoy/72lAWWs9Ms3x8RAgvYrAyQhZk5e2Of7+HdTWoPYW63/1cJRcFmLGqHh4Cc8Iaga7PcuORhkU0wWc3VGE= 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+89036+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 1650328022982303.04508455612756; Mon, 18 Apr 2022 17:27:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id gXESYY1788612xcm4ekcfRZj; Mon, 18 Apr 2022 17:27:02 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.3858.1650328002343868729 for ; Mon, 18 Apr 2022 17:27:01 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="326540418" X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="326540418" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:27:00 -0700 X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="529080087" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.171.121]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 17:26:58 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , James Bottomley , Jiewen Yao , Gerd Hoffmann , Brijesh Singh , Erdem Aktas , Tom Lendacky Subject: [edk2-devel] [PATCH V4 7/7] OvmfPkg: Call CcProbe in SecMain.c instead of TsIsEnabled Date: Tue, 19 Apr 2022 08:26:28 +0800 Message-Id: <2a282aa9da70db364044b51fe90d1ad7f5d42437.1650326140.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 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,min.m.xu@intel.com X-Gm-Message-State: ePGZJliuBM23a4KTV7ALvQtex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650328022; bh=13K2y8qIifjIcS3GxZeJPyRYSEiINNcRNz7qGh8SM6E=; h=Cc:Date:From:Reply-To:Subject:To; b=wAIqAOwvjV+P0kWLg9tnmXFWduep8n/tgHd7GFR3QVgcfZEqK8dMLd0OJ2KKxintG43 LldlX0KIJF/KNmRnii5jB5/d9XuMNeLO6bru2ALj0Gl80vFVe5kd0N/MVEY4blotbDuaJ +XDJGndSvW/UJtv+2l6IN0ZNJY2pb7ncSC8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650328024427100031 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3902 TdIsEnabled() uses the CPUID instruction. At this point, exception handling is not established and a CPUID instruction will generate a #VC and cause the booting guest to crash. CcProbe() checks Ovmf work area to return the guest type. So call of CcProbe() instead of TdIsEnabled() to fix the above issue. Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Brijesh Singh Cc: Erdem Aktas Cc: Tom Lendacky Reviewed-by: Jiewen Yao Reviewed-by: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/IntelTdx/Sec/SecMain.c | 6 +++--- OvmfPkg/IntelTdx/Sec/SecMain.inf | 1 + OvmfPkg/Sec/SecMain.c | 5 +++-- OvmfPkg/Sec/SecMain.inf | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/IntelTdx/Sec/SecMain.c b/OvmfPkg/IntelTdx/Sec/SecMain.c index 26d56be335e1..ab01ec9ab19c 100644 --- a/OvmfPkg/IntelTdx/Sec/SecMain.c +++ b/OvmfPkg/IntelTdx/Sec/SecMain.c @@ -25,7 +25,7 @@ #include #include #include - +#include #include =20 #define SEC_IDT_ENTRY_COUNT 34 @@ -61,7 +61,7 @@ SecCoreStartupWithStack ( UINT32 Index; volatile UINT8 *Table; =20 - if (TdIsEnabled ()) { + if (CcProbe () =3D=3D CcGuestTypeIntelTdx) { // // For Td guests, the memory map info is in TdHobLib. It should be pro= cessed // first so that the memory is accepted. Otherwise access to the unacc= epted @@ -119,7 +119,7 @@ SecCoreStartupWithStack ( // AsmWriteIdtr (&IdtDescriptor); =20 - if (TdIsEnabled ()) { + if (CcProbe () =3D=3D CcGuestTypeIntelTdx) { // // InitializeCpuExceptionHandlers () should be called in Td guests so = that // #VE exceptions can be handled correctly. diff --git a/OvmfPkg/IntelTdx/Sec/SecMain.inf b/OvmfPkg/IntelTdx/Sec/SecMai= n.inf index df2e749c3505..9cf1249d02e5 100644 --- a/OvmfPkg/IntelTdx/Sec/SecMain.inf +++ b/OvmfPkg/IntelTdx/Sec/SecMain.inf @@ -49,6 +49,7 @@ CpuExceptionHandlerLib PeilessStartupLib PlatformInitLib + CcProbeLib =20 [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index ca9717a7b526..8949d1015708 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "AmdSev.h" =20 #define SEC_IDT_ENTRY_COUNT 34 @@ -738,7 +739,7 @@ SecCoreStartupWithStack ( volatile UINT8 *Table; =20 #if defined (TDX_GUEST_SUPPORTED) - if (TdIsEnabled ()) { + if (CcProbe () =3D=3D CcGuestTypeIntelTdx) { // // For Td guests, the memory map info is in TdHobLib. It should be pro= cessed // first so that the memory is accepted. Otherwise access to the unacc= epted @@ -828,7 +829,7 @@ SecCoreStartupWithStack ( } =20 #if defined (TDX_GUEST_SUPPORTED) - if (TdIsEnabled ()) { + if (CcProbe () =3D=3D CcGuestTypeIntelTdx) { // // InitializeCpuExceptionHandlers () should be called in Td guests so = that // #VE exceptions can be handled correctly. diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf index 4b5b089ccd69..27100595aeca 100644 --- a/OvmfPkg/Sec/SecMain.inf +++ b/OvmfPkg/Sec/SecMain.inf @@ -54,6 +54,7 @@ LocalApicLib MemEncryptSevLib CpuExceptionHandlerLib + CcProbeLib =20 [Ppis] gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED --=20 2.29.2.windows.2 -=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 (#89036): https://edk2.groups.io/g/devel/message/89036 Mute This Topic: https://groups.io/mt/90552660/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-