From nobody Fri Nov 15 10:22:45 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+95794+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+95794+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279646; cv=none; d=zohomail.com; s=zohoarc; b=Xn8tqme+QKov6vv3LaCn9HD2qpxPTmj1iZHJ2AsBBGYkGFg9937FnJ1lkUL0hf3q/dXLC+kId8qJBQu50U9BkD+m8efR6Dyr3D3p/16EA7UDghg8WWS80PBa8DNYB0PxZN1xg7GVpAEI5RBDc4tFvBUTDekgemzELRwz8vwCEoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279646; 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=4jiC5Q+5g/UQmpMetGK5WI7xbxVdSWCZAt4hkPSxAdc=; b=JN8YZElLSVYW3Vo87zXnqWqjZMtfHWonbsRVuFAxyESd3v9ScSLY3kF5Sh3WoxKJ8ChbTM4iBJ16Vy42bRVXDEYaetwoAymEE4oGYp8NBhMJNkEIDwFAFFw5o22XUQFtaglZNl1AwVpVwAnSlI30r+9pZxGkQx+R0iuFFH/zRx0= 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+95794+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 1667279646152545.6211998484848; Mon, 31 Oct 2022 22:14:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Hx9cYY1788612xZ7OcjrLit8; Mon, 31 Oct 2022 22:14:05 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:05 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162627" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162627" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:05 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985431" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985431" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:02 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Jian J Wang , Liming Gao , Ray Ni , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V5 01/10] MdeModulePkg: Add PrePiHob.h Date: Tue, 1 Nov 2022 13:13:40 +0800 Message-Id: <20221101051349.13-2-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: ZZNSEmwMvpA0ovMnWZdMeF5Hx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279645; bh=kAwXuvulyDDHdc4fi3xvWG0arRqx74SU+h98cKVK/BE=; h=Cc:Date:From:Reply-To:Subject:To; b=PI3OOakkxou5BWnD4hFkhJC3IGEw8j579+u4lvW+YituXaeBjMFh/r2Is87HAsKSbKR 3qzD/nHUqHynmK1dM1nvbdAHj6tOf1RfK6MhlB/Fyo7hhpWu0/daU09r0/aIQFbFsWgTa llyWTJ+Nc8Oq1zt1Zie7aSzOMMFq8oqwXHM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279646404100002 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED is defined for unaccepted memory. But this defitinion has not been officially in the PI spec. Base on the code-first we define BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED at MdeModulePkg/Include/Pi/PrePiHob.h. Cc: Jian J Wang Cc: Liming Gao Cc: Ray Ni Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Reviewed-by: Liming Gao Signed-off-by: Min Xu --- MdeModulePkg/Include/Pi/PrePiHob.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 MdeModulePkg/Include/Pi/PrePiHob.h diff --git a/MdeModulePkg/Include/Pi/PrePiHob.h b/MdeModulePkg/Include/Pi/P= rePiHob.h new file mode 100644 index 000000000000..ac575e59721b --- /dev/null +++ b/MdeModulePkg/Include/Pi/PrePiHob.h @@ -0,0 +1,20 @@ +/** @file + HOB related definitions which has not been officially published in PI. + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MDE_MODULEPKG_PRE_PI_HOB_H_ +#define MDE_MODULEPKG_PRE_PI_HOB_H_ + +// +// BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED is defined for unaccepted memory. +// But this defitinion has not been officially in the PI spec. Base +// on the code-first we define BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED at +// MdeModulePkg/Include/Pi/PrePiHob.h. +// +#define BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED 0x00000007 + +#endif --=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 (#95794): https://edk2.groups.io/g/devel/message/95794 Mute This Topic: https://groups.io/mt/94703253/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 Fri Nov 15 10:22:45 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+95795+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+95795+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279649; cv=none; d=zohomail.com; s=zohoarc; b=NeRlbXqppvB+l4pSrCeChYxSX2HJnt6XBmzRCwjqydIHT3FIL8IurVj/iOHw+wOyRIynKX0ohAtJt+GbKuOIAQIEw77jYz2E+7nbulMq8I/k/delFVuOn6190+gYwJ3vGvL8ZCYtdxmAwyK9HMOHxU5UsBnUe87CAjCWItoT5Dw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279649; 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=WGG6dBPUpjsP7UUeCyhQoojCmXZAYi9cZtRjQOT52oY=; b=PGai/svGHd1d3UTexms0ZT7BR9zm6GkVkuhL5VsdIX8O5MnZj76C1Zgux4RnTZ6lYdMP816DssukyY6bdIY7d3qfc4U40oUT/HfOKR2FimQId8cYGwfEQNHe0zHz/KTWJNoBOsejPVp2ijcFiC6poFHoc6FYo0rzJldqmyU+bZk= 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+95795+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 1667279649718894.521683645859; Mon, 31 Oct 2022 22:14:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id yvesYY1788612x03QJndiaEq; Mon, 31 Oct 2022 22:14:09 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:08 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162655" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162655" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:07 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985437" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985437" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:05 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V5 02/10] MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE Date: Tue, 1 Nov 2022 13:13:41 +0800 Message-Id: <20221101051349.13-3-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: QXF8O4peBGIOwOMJxhe5WyQ3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279649; bh=tH2YhkSRPTvq1nMhxya00apzeGaDVvC4kqNopTT+1vI=; h=Cc:Date:From:Reply-To:Subject:To; b=vgfkeWFci+WwsESCUTkgf8oKil9192dw2c2gQLTyqeGcXfwhyI+BruqgNLNcA6VLbKF 6EW0TBC2Vkv2umhO/Jf/YcCKBVbzsV75Y7dewCCal/BWnLDJp3Tn443vcVr1Oznxl44RG hBwvnpnESluvGugq67HlncQ4J1feY8JMWao= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279650398100002 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED is defined for unaccepted memory. But this defitinion has not been officially in the PI spec. Base on the code-first we define EFI_RESOURCE_MEMORY_UNACCEPTED at MdeModulePkg/Include/Pi/PrePiHob.h and update EFI_RESOURCE_MAX_MEMORY_TYPE to 8. After BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED is officially published in PI spec, we will re-visit here. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Reviewed-by: Jiewen Yao Reviewed-by: Liming Gao Signed-off-by: Min Xu --- MdePkg/Include/Pi/PiHob.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Pi/PiHob.h b/MdePkg/Include/Pi/PiHob.h index e9f0ab4309d1..4605da56e247 100644 --- a/MdePkg/Include/Pi/PiHob.h +++ b/MdePkg/Include/Pi/PiHob.h @@ -232,7 +232,16 @@ typedef UINT32 EFI_RESOURCE_TYPE; #define EFI_RESOURCE_MEMORY_MAPPED_IO_PORT 0x00000004 #define EFI_RESOURCE_MEMORY_RESERVED 0x00000005 #define EFI_RESOURCE_IO_RESERVED 0x00000006 -#define EFI_RESOURCE_MAX_MEMORY_TYPE 0x00000007 +// +// BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED is defined for unaccepted memory. +// But this defitinion has not been officially in the PI spec. Base +// on the code-first we define BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED at +// MdeModulePkg/Include/Pi/PrePiHob.h and update EFI_RESOURCE_MAX_MEMORY_T= YPE +// to 8. After BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED is officially publish= ed +// in PI spec, we will re-visit here. +// +// #define BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED 0x00000007 +#define EFI_RESOURCE_MAX_MEMORY_TYPE 0x00000008 =20 /// /// A type of recount attribute type. --=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 (#95795): https://edk2.groups.io/g/devel/message/95795 Mute This Topic: https://groups.io/mt/94703254/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 Fri Nov 15 10:22:45 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+95796+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+95796+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279650; cv=none; d=zohomail.com; s=zohoarc; b=eMc7yYQ2j7Mt0GGSEKJXrPm1Vm6wfUs9IXB51UZ1byLIEupQ8nAz/w9MHTIU2YIu/y3tH8M5/vL5/uu57p/ttB+xIBM27yeWWurXtYlmkNYVRyuCNX+zrLYKUj/4oihSG1zdR2zal0XbepLnGflc1Y/hG7wv0GE3wHhS48/F7LY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279650; 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=wSHhdfdDc987edeUm/3GwvpXbEWK9YwrrGkfRQRHiG0=; b=RnusYORGQeFGS5nA/+v7xMisW3yBNQP8miRSP705UTOnCJ5UKacpB1r0LPKg9g7jRSY+so1jzOuxLOec8rU/ouzqE22nQhaAARu8Myzl1jRa0ObX2taFXhFRgXetHKk3IOVEQAqF5TdmrutJ2E358OWiICpYe37GA/EoJ21pfOk= 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+95796+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 1667279650650880.4841176311551; Mon, 31 Oct 2022 22:14:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qXR6YY1788612xJOMQgNjOtm; Mon, 31 Oct 2022 22:14:10 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:09 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162669" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162669" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:09 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985473" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985473" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:07 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V5 03/10] OvmfPkg: Use BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED defined in MdeModulePkg Date: Tue, 1 Nov 2022 13:13:42 +0800 Message-Id: <20221101051349.13-4-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: 3eyxIaYyZ9QkVosG10q0ohYex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279650; bh=Aa7g5yQF4sjul6FhAY6ZJ8BZBN7cTmAvcHWlMN3+fzs=; h=Cc:Date:From:Reply-To:Subject:To; b=mhvQh+Nas+rsghm+D4HyGOecBs1vU+0kLILySPB8VUrCA2RKbAX/cceGNd58vH4VIjH YJU/16r189Nz37arcv0Vi+PZBXM8cUKvCzRT+I+mm6VXVMOqch2ATXT/haKsDs4t70EsV IXANnxdFolrCEmDBs++zCD3258xMm24F+4c= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279652412100006 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED is defined in MdeModulePkg. The files which use the definition are updated as well. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/Library/PeilessStartupLib/Hob.c | 5 ++--- OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/Library/PeilessStartupLib/Hob.c b/OvmfPkg/Library/Peil= essStartupLib/Hob.c index 5fc84a809025..630ce445ebec 100644 --- a/OvmfPkg/Library/PeilessStartupLib/Hob.c +++ b/OvmfPkg/Library/PeilessStartupLib/Hob.c @@ -20,10 +20,9 @@ #include #include #include +#include #include "PeilessStartupInternal.h" =20 -#define EFI_RESOURCE_MEMORY_UNACCEPTED 7 - /** * Construct the HobList in SEC phase. * @@ -92,7 +91,7 @@ ConstructFwHobList ( // while (!END_OF_HOB_LIST (Hob)) { if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { - if (Hob.ResourceDescriptor->ResourceType =3D=3D EFI_RESOURCE_MEMORY_= UNACCEPTED) { + if (Hob.ResourceDescriptor->ResourceType =3D=3D BZ3937_EFI_RESOURCE_= MEMORY_UNACCEPTED) { PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Hob.Res= ourceDescriptor->ResourceLength; ResourceLength =3D Hob.ResourceDescriptor->ResourceLength; =20 diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c b/OvmfPkg/Library/P= latformInitLib/IntelTdx.c index c6d7c8bb6e0e..797f880df035 100644 --- a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c +++ b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c @@ -20,11 +20,11 @@ #include #include #include +#include #include #include =20 -#define ALIGNED_2MB_MASK 0x1fffff -#define EFI_RESOURCE_MEMORY_UNACCEPTED 7 +#define ALIGNED_2MB_MASK 0x1fffff =20 /** This function will be called to accept pages. Only BSP accepts pages. @@ -211,7 +211,7 @@ ValidateHobList ( EFI_RESOURCE_MEMORY_MAPPED_IO_PORT, EFI_RESOURCE_MEMORY_RESERVED, EFI_RESOURCE_IO_RESERVED, - EFI_RESOURCE_MEMORY_UNACCEPTED + BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED }; =20 if (VmmHobList =3D=3D NULL) { @@ -387,7 +387,7 @@ ProcessHobList ( if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { DEBUG ((DEBUG_INFO, "\nResourceType: 0x%x\n", Hob.ResourceDescriptor= ->ResourceType)); =20 - if (Hob.ResourceDescriptor->ResourceType =3D=3D EFI_RESOURCE_MEMORY_= UNACCEPTED) { + if (Hob.ResourceDescriptor->ResourceType =3D=3D BZ3937_EFI_RESOURCE_= MEMORY_UNACCEPTED) { DEBUG ((DEBUG_INFO, "ResourceAttribute: 0x%x\n", Hob.ResourceDescr= iptor->ResourceAttribute)); DEBUG ((DEBUG_INFO, "PhysicalStart: 0x%llx\n", Hob.ResourceDescrip= tor->PhysicalStart)); DEBUG ((DEBUG_INFO, "ResourceLength: 0x%llx\n", Hob.ResourceDescri= ptor->ResourceLength)); @@ -488,7 +488,7 @@ TransferTdxHobList ( ResourceType =3D Hob.ResourceDescriptor->ResourceType; ResourceAttribute =3D Hob.ResourceDescriptor->ResourceAttribute; =20 - if (ResourceType =3D=3D EFI_RESOURCE_MEMORY_UNACCEPTED) { + if (ResourceType =3D=3D BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED) { ResourceType =3D EFI_RESOURCE_SYSTEM_MEMORY; ResourceAttribute |=3D (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RES= OURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED); } --=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 (#95796): https://edk2.groups.io/g/devel/message/95796 Mute This Topic: https://groups.io/mt/94703255/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 Fri Nov 15 10:22:45 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+95797+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+95797+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279652; cv=none; d=zohomail.com; s=zohoarc; b=jQSkLexU1Fxj5g6MxqnKpewvyOQ7PZoEgq/pUUBzrXJF4b16rgOESKKRDlf2Neh9lieZ8TuOmQiuInsZMdj5DbwHxt11FdypJRbd2k1PMfW/hyWbyD4npxZvI0LoMmAp39neO/B6tWEWhJCWLcMQzFitY5JQfOCt6WvZVaWnnu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279652; 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=5uUR8+zK8e4sQqNumi7zQXH25G31NrAnBlZ0xL/Kd50=; b=nudg+ZZPoEZrQD7ffdNbhzKLnY3Moci/wnlEzaiSElZapKjM7PU7Q8ARtXVFHBJt5e1MX55OSvrB0jvO+7TVfD0r6wEGsWrl6C5RsfahKRQ9ekisVWU4DvWVgHXXLm9Jr8AJlvz4Vd+ea2LwgIw0+2v0y/vEE54oXkgijQxRKNI= 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+95797+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 1667279652865306.09261419634913; Mon, 31 Oct 2022 22:14:12 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id oeX3YY1788612x8ysPSiaFMm; Mon, 31 Oct 2022 22:14:12 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:12 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162707" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162707" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:11 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985488" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985488" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:09 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V5 04/10] MdePkg: Add UEFI Unaccepted memory definition Date: Tue, 1 Nov 2022 13:13:43 +0800 Message-Id: <20221101051349.13-5-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: 9QJyE1AhsaOWX1EK60Dc7ubHx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279652; bh=Hhr22QvTxvhzjgDRO7w0Fioq9ABabHP1yqfZRjx6GKU=; h=Cc:Date:From:Reply-To:Subject:To; b=QbiE4J0/peFHQ590xGKLcKy2R6ot/+Ss75eKSB0Y6HjNJ2U/F2b/O1SGTDq7Y9G9K4z zNzoQ7PgafkEamlbwsp3AlQRzN7YdSx/NdimTCirgbV1CuQGUYWmn0Q8tqfOVk5CrSYq8 V+thkUMIcCNl/6jrKAEDf0wmTXX3cEVFbac= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279654547100001 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 Plase refer to: UEFI Spec v2.9 Table 7-5 Memory Type Usage before ExitBootServices() Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Reviewed-by: Jiewen Yao Acked-by: Gerd Hoffmann Reviewed-by: Liming Gao Signed-off-by: Min Xu --- MdeModulePkg/Include/Pi/PrePiDxeCis.h | 25 +++++++++++++++++++++++++ MdePkg/Include/Pi/PiDxeCis.h | 10 +++++++++- MdePkg/Include/Uefi/UefiMultiPhase.h | 5 +++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 MdeModulePkg/Include/Pi/PrePiDxeCis.h diff --git a/MdeModulePkg/Include/Pi/PrePiDxeCis.h b/MdeModulePkg/Include/P= i/PrePiDxeCis.h new file mode 100644 index 000000000000..113ac37924cc --- /dev/null +++ b/MdeModulePkg/Include/Pi/PrePiDxeCis.h @@ -0,0 +1,25 @@ +/** @file + Include file matches things in PI. + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MDE_MODULEPKG_PRE_PI_DXE_CIS_H_ +#define MDE_MODULEPKG_PRE_PI_DXE_CIS_H_ + +/// +/// A memory region that describes system memory that has not been accepted +/// by a corresponding call to the underlying isolation architecture. +/// +/// This memory region has not been defined in PI spec, so it is defined in +/// PrePiDxeCis.h. And it is defined in the format of captial letters +/// because only capital letters are allowed to be used for #define declar= ations. +/// +/// After this memory region is defined in PI spec, it should be a value in +/// EFI_GCD_MEMORY_TYPE in PiDxeCis.h. +/// +#define EFI_GCD_MEMORY_TYPE_UNACCEPTED 7 + +#endif diff --git a/MdePkg/Include/Pi/PiDxeCis.h b/MdePkg/Include/Pi/PiDxeCis.h index d0f2ed0e58df..27b219aa3ffa 100644 --- a/MdePkg/Include/Pi/PiDxeCis.h +++ b/MdePkg/Include/Pi/PiDxeCis.h @@ -56,7 +56,15 @@ typedef enum { /// system. If all memory has the same reliability, then this bit is not= used. /// EfiGcdMemoryTypeMoreReliable, - EfiGcdMemoryTypeMaximum + // /// + // /// A memory region that describes system memory that has not been ac= cepted + // /// by a corresponding call to the underlying isolation architecture. + // /// + // /// Please be noted: + // /// EfiGcdMemoryTypeUnaccepted is defined in PrePiDxeCis.h because it= has not been + // /// defined in PI spec. + // EfiGcdMemoryTypeUnaccepted, + EfiGcdMemoryTypeMaximum =3D 8 } EFI_GCD_MEMORY_TYPE; =20 /// diff --git a/MdePkg/Include/Uefi/UefiMultiPhase.h b/MdePkg/Include/Uefi/Uef= iMultiPhase.h index 22bae43e36e8..7884913371a9 100644 --- a/MdePkg/Include/Uefi/UefiMultiPhase.h +++ b/MdePkg/Include/Uefi/UefiMultiPhase.h @@ -103,6 +103,11 @@ typedef enum { /// however it happens to also support byte-addressable non-volatility. /// EfiPersistentMemory, + /// + /// A memory region that describes system memory that has not been accep= ted + /// by a corresponding call to the underlying isolation architecture. + /// + EfiUnacceptedMemoryType, EfiMaxMemoryType } EFI_MEMORY_TYPE; =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 (#95797): https://edk2.groups.io/g/devel/message/95797 Mute This Topic: https://groups.io/mt/94703259/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 Fri Nov 15 10:22:45 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+95798+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+95798+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279655; cv=none; d=zohomail.com; s=zohoarc; b=Oh/hqaiBUJ/ysZEySLyBZ+JvjakfVxRNydJNq9SUYmNJ9rHtZc5nbyieXednep7MUsfwD42kY97hF7ogTpDW7g4yLkcXKpnhjdhH2s3QAQLC1XOgBAmRiJLETkxQ7vf5e6R1e7KSXe5zrC6vbyVvs/YHoSvy0ABcRfdZGnhMh88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279655; 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=P8wd/cDL8Bf+LtvpWb16SIKmsi7Tet5ZbDPX8NddCPE=; b=b5swKT0v58I49DsavPTkI2PDb7ZkLCY7M7CDq7lfsd8W2Bo+4/OYSUTvdCpmWCse+rK7xFHGkoQBsImcm0w66JNsZw6ZnvBK2o85hhb5EwTLQlHx43e6zQuXYkOW0Bnw8at/av3+pbEeQ5kvqOUBH2ilrymJDHMmO4Z2SZ7OoHI= 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+95798+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 1667279655405694.2313497428362; Mon, 31 Oct 2022 22:14:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5uwGYY1788612x7jl5DnzqYV; Mon, 31 Oct 2022 22:14:15 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:14 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162726" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162726" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:14 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985513" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985513" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:11 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Jian J Wang , Liming Gao , Ray Ni , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V5 05/10] MdeModulePkg: Update Dxe to handle unaccepted memory type Date: Tue, 1 Nov 2022 13:13:44 +0800 Message-Id: <20221101051349.13-6-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: aYGgqfMuXcMSWOSL81o37Sp7x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279655; bh=ZGIo27+iQKuvLS+RUJhgX+Aa0ciVx8aKfp6sb93nFrM=; h=Cc:Date:From:Reply-To:Subject:To; b=g3eRTkbYNeB15OkPZ7QR1a7S1lHoFQpuuEc5ASldz8s802FHS8h+8dagu1uX0iyxjF0 BgCO3DWsG6DhtA1YOUay1l9H9WW+KxS59KFVhOHGAHCx4XM8Kt8qmOS7Bc2x/2dRZQCRp KN4YEOnpoMSPlsk/sV92ydqIlBgoxI8bK2Q= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279656471100005 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 Unaccepted memory is a kind of new memory type, CoreInitializeGcdServices() and CoreGetMemoryMap() are updated to handle the unaccepted memory type. Ref: microsoft/mu_basecore@97e9c31 Cc: Jian J Wang Cc: Liming Gao Cc: Ray Ni Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Reviewed-by: Liming Gao Signed-off-by: Min Xu --- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 6 +++ MdeModulePkg/Core/Dxe/Mem/Page.c | 63 +++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gc= d.c index 3763467bdbc0..792cd2e0af23 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -8,6 +8,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 +#include +#include #include "DxeMain.h" #include "Gcd.h" #include "Mem/HeapGuard.h" @@ -103,6 +105,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdMemoryT= ypeNames[] =3D { "MMIO ", // EfiGcdMemoryTypeMemoryMappedIo "PersisMem", // EfiGcdMemoryTypePersistent "MoreRelia", // EfiGcdMemoryTypeMoreReliable + "Unaccepte", // EFI_GCD_MEMORY_TYPE_UNACCEPTED "Unknown " // EfiGcdMemoryTypeMaximum }; =20 @@ -2600,6 +2603,9 @@ CoreInitializeGcdServices ( case EFI_RESOURCE_MEMORY_RESERVED: GcdMemoryType =3D EfiGcdMemoryTypeReserved; break; + case BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED: + GcdMemoryType =3D EFI_GCD_MEMORY_TYPE_UNACCEPTED; + break; case EFI_RESOURCE_IO: GcdIoType =3D EfiGcdIoTypeIo; break; diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c index cc0b90ac0df5..160289c1f9ec 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -9,6 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "DxeMain.h" #include "Imem.h" #include "HeapGuard.h" +#include =20 // // Entry for tracking the memory regions for each memory type to coalesce = similar memory types @@ -61,6 +62,7 @@ EFI_MEMORY_TYPE_STATISTICS mMemoryTypeStatistics[EfiMaxM= emoryType + 1] =3D { { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiM= emoryMappedIOPortSpace { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiP= alCode { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiP= ersistentMemory + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiU= nacceptedMemoryType { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // EfiM= axMemoryType }; =20 @@ -68,22 +70,23 @@ EFI_PHYSICAL_ADDRESS mDefaultMaximumAddress =3D MAX_AL= LOC_ADDRESS; EFI_PHYSICAL_ADDRESS mDefaultBaseAddress =3D MAX_ALLOC_ADDRESS; =20 EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = =3D { - { EfiReservedMemoryType, 0 }, - { EfiLoaderCode, 0 }, - { EfiLoaderData, 0 }, - { EfiBootServicesCode, 0 }, - { EfiBootServicesData, 0 }, - { EfiRuntimeServicesCode, 0 }, - { EfiRuntimeServicesData, 0 }, - { EfiConventionalMemory, 0 }, - { EfiUnusableMemory, 0 }, - { EfiACPIReclaimMemory, 0 }, - { EfiACPIMemoryNVS, 0 }, - { EfiMemoryMappedIO, 0 }, - { EfiMemoryMappedIOPortSpace, 0 }, - { EfiPalCode, 0 }, - { EfiPersistentMemory, 0 }, - { EfiMaxMemoryType, 0 } + { EfiReservedMemoryType, 0 }, + { EfiLoaderCode, 0 }, + { EfiLoaderData, 0 }, + { EfiBootServicesCode, 0 }, + { EfiBootServicesData, 0 }, + { EfiRuntimeServicesCode, 0 }, + { EfiRuntimeServicesData, 0 }, + { EfiConventionalMemory, 0 }, + { EfiUnusableMemory, 0 }, + { EfiACPIReclaimMemory, 0 }, + { EfiACPIMemoryNVS, 0 }, + { EfiMemoryMappedIO, 0 }, + { EfiMemoryMappedIOPortSpace, 0 }, + { EfiPalCode, 0 }, + { EfiPersistentMemory, 0 }, + { EFI_GCD_MEMORY_TYPE_UNACCEPTED, 0 }, + { EfiMaxMemoryType, 0 } }; // // Only used when load module at fixed address feature is enabled. True me= ans the memory is alreay successfully allocated @@ -1286,7 +1289,7 @@ CoreInternalAllocatePages ( } =20 if (((MemoryType >=3D EfiMaxMemoryType) && (MemoryType < MEMORY_TYPE_OEM= _RESERVED_MIN)) || - (MemoryType =3D=3D EfiConventionalMemory) || (MemoryType =3D=3D EfiP= ersistentMemory)) + (MemoryType =3D=3D EfiConventionalMemory) || (MemoryType =3D=3D EfiP= ersistentMemory) || (MemoryType =3D=3D EfiUnacceptedMemoryType)) { return EFI_INVALID_PARAMETER; } @@ -1961,6 +1964,32 @@ CoreGetMemoryMap ( MemoryMap =3D MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, S= ize); } =20 + if (MergeGcdMapEntry.GcdMemoryType =3D=3D EFI_GCD_MEMORY_TYPE_UNACCEPT= ED) { + // + // Page Align GCD range is required. When it is converted to EFI_MEM= ORY_DESCRIPTOR, + // it will be recorded as page PhysicalStart and NumberOfPages. + // + ASSERT ((MergeGcdMapEntry.BaseAddress & EFI_PAGE_MASK) =3D=3D 0); + ASSERT (((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress= + 1) & EFI_PAGE_MASK) =3D=3D 0); + + // + // Create EFI_MEMORY_DESCRIPTOR for every Unaccepted GCD entries + // + MemoryMap->PhysicalStart =3D MergeGcdMapEntry.BaseAddress; + MemoryMap->VirtualStart =3D 0; + MemoryMap->NumberOfPages =3D RShiftU64 ((MergeGcdMapEntry.EndAddress= - MergeGcdMapEntry.BaseAddress + 1), EFI_PAGE_SHIFT); + MemoryMap->Attribute =3D MergeGcdMapEntry.Attributes | + (MergeGcdMapEntry.Capabilities & (EFI_MEM= ORY_RP | EFI_MEMORY_WP | EFI_MEMORY_XP | EFI_MEMORY_RO | + EFI_MEM= ORY_UC | EFI_MEMORY_UCE | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB)); + MemoryMap->Type =3D EfiUnacceptedMemoryType; + + // + // Check to see if the new Memory Map Descriptor can be merged with = an + // existing descriptor if they are adjacent and have the same attrib= utes + // + MemoryMap =3D MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, S= ize); + } + if (Link =3D=3D &mGcdMemorySpaceMap) { // // break loop when arrive at head. --=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 (#95798): https://edk2.groups.io/g/devel/message/95798 Mute This Topic: https://groups.io/mt/94703260/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 Fri Nov 15 10:22:45 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+95799+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+95799+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279657; cv=none; d=zohomail.com; s=zohoarc; b=BCx8nuiBi59LNHW5dN//FRIS6SrnvcYAr1qshCpHpIJ0nFd1K34W0ysR5Sjb0k3KxI0qTtF/ezjyR5SBk/ZpXN0wH2Rlprfn5iYgR6mBrHtPNW4fk2R3KXG/Ao+xt5vCI0FDs+gq1iO7dzk3FZH1aowFm4kSPihQZNgkZNYwk2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279657; 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=WyizsL0LEIO/TzqkJzY01P8pDEYMZj3DuIp6G9IHWqg=; b=MexaSfyd6v9bHz7iVxqsrDU9wF5HxTTp2OqA52ZjZ0MWo7e656YgMMBQHwAcAcTaHTGlbm9wal8TbsErNKzTkcJNusUm3ZTMgif8Qka0lR+uVA0+JAD/+B0nRv8IqEn1JbY22qkg+mEANNOWPHHUjo16hSNNEG24voLDrFQLckQ= 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+95799+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 1667279657598437.589115387918; Mon, 31 Oct 2022 22:14:17 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TsLQYY1788612xyiF3Z3Xi4Y; Mon, 31 Oct 2022 22:14:17 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:16 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162741" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162741" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:16 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985527" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985527" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:14 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Ray Ni , Zhichao Gao , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V5 06/10] ShellPkg: Update shell command memmap to show unaccepted memory Date: Tue, 1 Nov 2022 13:13:45 +0800 Message-Id: <20221101051349.13-7-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: B5x7WKYMDWsmCPI2mdcRr4INx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279657; bh=quDzizvuXs8FjrH2o1fe/X9rF7BZBY5HNTxPj60NeCA=; h=Cc:Date:From:Reply-To:Subject:To; b=Nx59v7ptB9Q0So1lDY51t/t+SEXSQQ4Im6u82Qezrlyjs3V3XBGMf7jpEhZqYnV1SJn 14kQ4Ft/zzw/Vt1sOS+JxWP3GyhncwbGwgjVAmtHxu9GQJsL0wCop9A0ZZaE8IzN3ejh6 arExz3cOC8TzChVa7owHXsyVFc7OwkqVzMw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279658469100010 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 ShellCommandRunMemMap() is updated to handle the case of unaccepted memory type. Cc: Ray Ni Cc: Zhichao Gao Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Acked-by: Zhichao Gao Signed-off-by: Min Xu --- .../Library/UefiShellDebug1CommandsLib/MemMap.c | 13 +++++++++++++ .../UefiShellDebug1CommandsLib.uni | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c b/ShellPk= g/Library/UefiShellDebug1CommandsLib/MemMap.c index 72f3c58b0970..a089953b286f 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c @@ -26,6 +26,7 @@ STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] =3D= L"ACPIMemoryNVS"; STATIC CONST CHAR16 NameEfiMemoryMappedIO[] =3D L"MemoryMappedIO= "; STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] =3D L"MemoryMappedIO= PortSpace"; STATIC CONST CHAR16 NameEfiPalCode[] =3D L"PalCode"; +STATIC CONST CHAR16 NameEfiUnacceptedMemoryType[] =3D L"Unaccepted"; =20 // // Need short names for some memory types @@ -151,6 +152,8 @@ ShellCommandRunMemMap ( UINT64 UnusableMemoryPagesSize; UINT64 PalCodePages; UINT64 PalCodePagesSize; + UINT64 UnacceptedPages; + UINT64 UnacceptedPagesSize; UINT64 PersistentPages; UINT64 PersistentPagesSize; BOOLEAN Sfo; @@ -175,6 +178,7 @@ ShellCommandRunMemMap ( PalCodePages =3D 0; PersistentPages =3D 0; Size =3D 0; + UnacceptedPages =3D 0; Descriptors =3D NULL; ShellStatus =3D SHELL_SUCCESS; Status =3D EFI_SUCCESS; @@ -303,6 +307,11 @@ ShellCommandRunMemMap ( TotalPages +=3D Walker->NumberOfPages; PalCodePages +=3D Walker->NumberOfPages; break; + case EfiUnacceptedMemoryType: + ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING= _TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), g= ShellDebug1HiiHandle, NameEfiUnacceptedMemoryType, Walker->PhysicalStart, W= alker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker= ->NumberOfPages, Walker->Attribute); + TotalPages +=3D Walker->NumberOfPages; + UnacceptedPages +=3D Walker->NumberOfPages; + break; default: // // Shell Spec defines the SFO format. @@ -335,6 +344,7 @@ ShellCommandRunMemMap ( MmioSpacePagesSize =3D MultU64x64 (SIZE_4KB, MmioSpacePages); MmioPortPagesSize =3D MultU64x64 (SIZE_4KB, MmioPortPages); PalCodePagesSize =3D MultU64x64 (SIZE_4KB, PalCodePages); + UnacceptedPagesSize =3D MultU64x64 (SIZE_4KB, UnacceptedPages); PersistentPagesSize =3D MultU64x64 (SIZE_4KB, PersistentPages); UnusableMemoryPagesSize =3D MultU64x64 (SIZE_4KB, UnusableMemoryPa= ges); if (!Sfo) { @@ -368,6 +378,8 @@ ShellCommandRunMemMap ( MmioPortPagesSize, PalCodePages, PalCodePagesSize, + UnacceptedPages, + UnacceptedPagesSize, AvailPages, AvailPagesSize, PersistentPages, @@ -422,6 +434,7 @@ ShellCommandRunMemMap ( AcpiReclaimPagesSize, AcpiNvsPagesSize, PalCodePagesSize, + UnacceptedPagesSize, PersistentPagesSize ); } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Com= mandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1C= ommandsLib.uni index 6693be26e699..b1d239ed37ea 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.uni @@ -88,13 +88,14 @@ " MMIO : %,14ld Pa= ges (%,ld Bytes)\r\n" " MMIO_Port : %,14ld Pa= ges (%,ld Bytes)\r\n" " PalCode : %,14ld Pa= ges (%,ld Bytes)\r\n" + " Unaccepted: %,14ld Pa= ges (%,ld Bytes)\r\n" " Available : %,14ld Pa= ges (%,ld Bytes)\r\n" " Persistent: %,14ld Pa= ges (%,ld Bytes)\r\n" #string STR_MEMMAP_LIST_SUMM_OTHER #language en-US " %08x : %,14ld Pa= ges (%,ld Bytes)\r\n" #string STR_MEMMAP_LIST_SUMM2 #language en-US " ---------= ----- \r\n" "Total Memory: %,14ld MB= (%,ld Bytes)\r\n" #string STR_MEMMAP_LIST_ITEM_SFO #language en-US "MemoryMap,"%s","%LX","%= LX","%LX","%LX"\r\n" -#string STR_MEMMAP_LIST_SUMM_SFO #language en-US "MemoryMapSummary,"%Ld",= "%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%L= d","%Ld","%Ld"\r\n" +#string STR_MEMMAP_LIST_SUMM_SFO #language en-US "MemoryMapSummary,"%Ld",= "%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%L= d","%Ld","%Ld", "%Ld"\r\n" =20 #string STR_EFI_COMPRESS_FAIL #language en-US "Unable to compress: %r.= \r\n" #string STR_EFI_DECOMPRESS_FAIL #language en-US "Unable to decompress: %= r.\r\n" --=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 (#95799): https://edk2.groups.io/g/devel/message/95799 Mute This Topic: https://groups.io/mt/94703262/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 Fri Nov 15 10:22:45 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+95800+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+95800+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279659; cv=none; d=zohomail.com; s=zohoarc; b=PtAVuKVEU04Oiznwf4rxl4BOmWfOfyg47yTyCF9d2XyeS5x2NZBubS1LO50Iidgi8O8qSgwHG9v+OwRWFV38RwLI3B8P/qN5t30S+a9kMgRQg8Z0UpDWwmhnCPrKa4fqEbouexE/m/39tQVzbv8Cp1isJ5rTZLWSEYeNV50q+sY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279659; 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=aZLBpEBVQGgGq9AUtsw48/NpHecn5NuaAGIwCcC+IZI=; b=V4yiU+FMPf76nQ32S15eU9cfx03+lX0M86zwe+ycy6ulPOG/EDr7TsTP8+It2sdQXC6SaTaCfQDxKjbY/XVFBQqzfw/O2mpQsrzAsk2jnd38Vl0IkSdwJ3q+xUYZeIHJJOInQXQQ/io2lhNDl5o6R7gJjkSQ7qRg/b7vgJBCFuk= 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+95800+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 166727965955389.70305423875345; Mon, 31 Oct 2022 22:14:19 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5rdmYY1788612xryvoFiSxKa; Mon, 31 Oct 2022 22:14:19 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:18 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162759" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162759" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:18 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985532" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985532" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:16 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V5 07/10] OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei Date: Tue, 1 Nov 2022 13:13:46 +0800 Message-Id: <20221101051349.13-8-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: 28uHJLmWgsyi9mpAGyjWtZCfx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279659; bh=uJNjFoxG/KOgpeP6NhcJBEEUx1eWqra4/JXPmLALfBA=; h=Cc:Date:From:Reply-To:Subject:To; b=TFun5g14B7VoAFzRpCu7PNjYYlhiEGiFYOVhxWPylnQ+2bE6iObUKfevkNp8yFFS0dt DJyqGfkZwW8hYSBfUwBxofq42TauI+FE9jEAnR3yZKc+uz0Q5g7M52BX1kmhsIdal3XY6 sCaeMpVjgdzkNxBwLLv10++mu5ozfb2esFU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279660487100014 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 There are below major changes in PlatformInitLib/PlatformPei 1. ProcessHobList The unaccepted memory is accepted if it is under 4G address. Please be noted: in current stage, we only accept the memory under 4G. We will re-visit here in the future when on-demand accept memory is required. 2. TransferTdxHobList Transfer the unaccepted memory hob to EFI_RESOURCE_SYSTEM_MEMORY hob if it is accepted. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 88 ++++++++++++++++++--- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 2 + 2 files changed, 81 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c b/OvmfPkg/Library/P= latformInitLib/IntelTdx.c index 797f880df035..acd114e38e46 100644 --- a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c +++ b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c @@ -7,6 +7,7 @@ =20 **/ =20 +#include #include #include #include @@ -25,6 +26,7 @@ #include =20 #define ALIGNED_2MB_MASK 0x1fffff +#define MEGABYTE_SHIFT 20 =20 /** This function will be called to accept pages. Only BSP accepts pages. @@ -375,11 +377,15 @@ ProcessHobList ( EFI_STATUS Status; EFI_PEI_HOB_POINTERS Hob; EFI_PHYSICAL_ADDRESS PhysicalEnd; + UINT64 ResourceLength; + UINT64 AccumulateAcceptedMemory; =20 Status =3D EFI_SUCCESS; ASSERT (VmmHobList !=3D NULL); Hob.Raw =3D (UINT8 *)VmmHobList; =20 + AccumulateAcceptedMemory =3D 0; + // // Parse the HOB list until end of list or matching type is found. // @@ -393,7 +399,15 @@ ProcessHobList ( DEBUG ((DEBUG_INFO, "ResourceLength: 0x%llx\n", Hob.ResourceDescri= ptor->ResourceLength)); DEBUG ((DEBUG_INFO, "Owner: %g\n\n", &Hob.ResourceDescriptor->Owne= r)); =20 - PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Hob.Resour= ceDescriptor->ResourceLength; + PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Hob.Res= ourceDescriptor->ResourceLength; + ResourceLength =3D Hob.ResourceDescriptor->ResourceLength; + + if (Hob.ResourceDescriptor->PhysicalStart >=3D BASE_4GB) { + // + // In current stage, we only accept the memory under 4G + // + break; + } =20 Status =3D BspAcceptMemoryResourceRange ( Hob.ResourceDescriptor->PhysicalStart, @@ -402,6 +416,8 @@ ProcessHobList ( if (EFI_ERROR (Status)) { break; } + + AccumulateAcceptedMemory +=3D ResourceLength; } } =20 @@ -460,6 +476,60 @@ ProcessTdxHobList ( return Status; } =20 +/** + * Build ResourceDescriptorHob for the unaccepted memory region. + * This memory region may be splitted into 2 parts because of lazy accept. + * + * @param Hob Point to the EFI_HOB_RESOURCE_DESCRIPTOR + * @return VOID + */ +VOID +BuildResourceDescriptorHobForUnacceptedMemory ( + IN EFI_HOB_RESOURCE_DESCRIPTOR *Hob + ) +{ + EFI_PHYSICAL_ADDRESS PhysicalStart; + EFI_PHYSICAL_ADDRESS PhysicalEnd; + UINT64 ResourceLength; + EFI_RESOURCE_TYPE ResourceType; + EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute; + UINT64 MaxAcceptedMemoryAddress; + + ASSERT (Hob->ResourceType =3D=3D BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED); + + ResourceType =3D BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED; + ResourceAttribute =3D Hob->ResourceAttribute; + PhysicalStart =3D Hob->PhysicalStart; + ResourceLength =3D Hob->ResourceLength; + PhysicalEnd =3D PhysicalStart + ResourceLength; + + // + // In the first stage of lazy-accept, all the memory under 4G will be ac= cepted. + // The memory above 4G will not be accepted. + // + MaxAcceptedMemoryAddress =3D BASE_4GB; + + if (PhysicalEnd <=3D MaxAcceptedMemoryAddress) { + // + // This memory region has been accepted. + // + ResourceType =3D EFI_RESOURCE_SYSTEM_MEMORY; + ResourceAttribute |=3D (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_= ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED); + } else if (PhysicalStart >=3D MaxAcceptedMemoryAddress) { + // + // This memory region hasn't been accepted. + // So keep the ResourceType and ResourceAttribute unchange. + // + } + + BuildResourceDescriptorHob ( + ResourceType, + ResourceAttribute, + PhysicalStart, + ResourceLength + ); +} + /** Transfer the incoming HobList for the TD to the final HobList for Dxe. The Hobs transferred in this function are ResourceDescriptor hob and @@ -489,16 +559,16 @@ TransferTdxHobList ( ResourceAttribute =3D Hob.ResourceDescriptor->ResourceAttribute; =20 if (ResourceType =3D=3D BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED) { - ResourceType =3D EFI_RESOURCE_SYSTEM_MEMORY; - ResourceAttribute |=3D (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RES= OURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED); + BuildResourceDescriptorHobForUnacceptedMemory (Hob.ResourceDescr= iptor); + } else { + BuildResourceDescriptorHob ( + ResourceType, + ResourceAttribute, + Hob.ResourceDescriptor->PhysicalStart, + Hob.ResourceDescriptor->ResourceLength + ); } =20 - BuildResourceDescriptorHob ( - ResourceType, - ResourceAttribute, - Hob.ResourceDescriptor->PhysicalStart, - Hob.ResourceDescriptor->ResourceLength - ); break; case EFI_HOB_TYPE_MEMORY_ALLOCATION: BuildMemoryAllocationHob ( diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/= PlatformInitLib/MemDetect.c index ae217d0242ed..b8feae4309de 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -42,6 +42,8 @@ Module Name: =20 #include =20 +#define MEGABYTE_SHIFT 20 + VOID EFIAPI PlatformQemuUc32BaseInitialization ( --=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 (#95800): https://edk2.groups.io/g/devel/message/95800 Mute This Topic: https://groups.io/mt/94703263/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 Fri Nov 15 10:22:45 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+95801+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+95801+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279662; cv=none; d=zohomail.com; s=zohoarc; b=Y64bZd1tn5QMOaO693VwIXjDpiA9hkFlLSBHFQv18Ea8PoGmRr88GK7WDi4brbP413xO3zWJLT18+utj/M2BN+gMlx2W2o8ZA2VPeRG7BGenj3iGQwSUDec90YTpnTezxq9CxjyapKpqN+H/Z77bbxF0PkYMpVUGfwm5r2fg7sc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279662; 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=mYycgEYcdUyH8RMuvs9DhMwhvouz4VYNedhWbZ5m1do=; b=AXiqoMDW/eZC2WIx7mEbq+wsGcMs78fc+XEcgpOEC+EnWA6teD7xVBNpctDnvJvfNZZcHVJmsj/G8ZSkHVl2f4j3o96peDQE9DNBlzEe/TSOGGBZ2P/B1ZlxPzDRRzALCzrGca2xYKFVlsi030E4AsMj4tDtRIb5BqLvPXatnAg= 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+95801+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 1667279662732206.70101121461937; Mon, 31 Oct 2022 22:14:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Kv5rYY1788612xL6iSLZPMy8; Mon, 31 Oct 2022 22:14:22 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:21 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162793" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162793" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:20 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985546" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985546" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:18 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Jiaqi Gao , Michael D Kinney , Liming Gao , Zhiguang Liu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky , Min Xu Subject: [edk2-devel] [PATCH V5 08/10] MdePkg: The prototype definition of EdkiiMemoryAcceptProtocol Date: Tue, 1 Nov 2022 13:13:47 +0800 Message-Id: <20221101051349.13-9-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: wlxmWj1eWanY28NtXAEaJAMQx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279662; bh=1qUbnpq9I3uo0N57XNRCVQwpcZrT2Huqt+uoM/cF1HU=; h=Cc:Date:From:Reply-To:Subject:To; b=M21Twtu5JG0rdXp7fWDaWtn1kX4gV95ffdFyW3FLW0MC2LFNwPS9NoeHUPsA74200iW iG6QwxXSJSJI9fSZp/svTDywtq28XvUVu34QI7JwpafgbZrA+3wSw1as9N/GSYEI0pv3h 4lcvpQKzlUZu4goXLVg8jSwSMl9xfEoT3Pc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279664507100001 Content-Type: text/plain; charset="utf-8" From: Jiaqi Gao RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 EdkiiMemoryAcceptProtocol is defined in MdePkg, the method AcceptMemory() can be called when memory needs to be accepted. EdkiiMemoryAcceptProtocol can be installed by architecture-specific drivers such as TdxDxe. This allows different isolation architectures to realize their own low-level methods to accept memory. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Reviewed-by: Liming Gao Signed-off-by: Jiaqi Gao Signed-off-by: Min Xu --- MdePkg/Include/Protocol/MemoryAccept.h | 37 ++++++++++++++++++++++++++ MdePkg/MdePkg.dec | 3 +++ 2 files changed, 40 insertions(+) create mode 100644 MdePkg/Include/Protocol/MemoryAccept.h diff --git a/MdePkg/Include/Protocol/MemoryAccept.h b/MdePkg/Include/Protoc= ol/MemoryAccept.h new file mode 100644 index 000000000000..f7646e04d8a1 --- /dev/null +++ b/MdePkg/Include/Protocol/MemoryAccept.h @@ -0,0 +1,37 @@ +/** @file + The file provides the protocol to provide interface to accept memory. + + Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MEMORY_ACCEPT_H_ +#define MEMORY_ACCEPT_H_ + +#define EDKII_MEMORY_ACCEPT_PROTOCOL_GUID \ + { 0x38c74800, 0x5590, 0x4db4, { 0xa0, 0xf3, 0x67, 0x5d, 0x9b, 0x8e, 0x80= , 0x26 } }; + +typedef struct _EDKII_MEMORY_ACCEPT_PROTOCOL EDKII_MEMORY_ACCEPT_PROTOCOL; + +/** + @param This A pointer to a EDKII_MEMORY_ACCEPT_PROTOCO= L. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_ACCEPT_MEMORY)( + IN EDKII_MEMORY_ACCEPT_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS StartAddress, + IN UINTN Size + ); + +/// +/// The EDKII_MEMORY_ACCEPT_PROTOCOL provides the ability for memory servi= ces +/// to accept memory. +/// +struct _EDKII_MEMORY_ACCEPT_PROTOCOL { + EDKII_ACCEPT_MEMORY AcceptMemory; +}; + +extern EFI_GUID gEdkiiMemoryAcceptProtocolGuid; + +#endif diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 4c81cbd75ab2..ba287d9b3cfc 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -1023,6 +1023,9 @@ gEfiPeiDelayedDispatchPpiGuid =3D { 0x869c711d, 0x649c, 0x44fe, { 0x8b,= 0x9e, 0x2c, 0xbb, 0x29, 0x11, 0xc3, 0xe6 }} =20 [Protocols] + ## Include/Protocol/MemoryAccept.h + gEdkiiMemoryAcceptProtocolGuid =3D { 0x38c74800, 0x5590, 0x4db4, { 0xa0,= 0xf3, 0x67, 0x5d, 0x9b, 0x8e, 0x80, 0x26 }} + ## Include/Protocol/Pcd.h gPcdProtocolGuid =3D { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2,= 0x90, 0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }} =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 (#95801): https://edk2.groups.io/g/devel/message/95801 Mute This Topic: https://groups.io/mt/94703264/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 Fri Nov 15 10:22:45 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+95802+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+95802+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279665; cv=none; d=zohomail.com; s=zohoarc; b=lk/VhYDTzshAOuposIqCyd94BgbA5wl/YbH5lYhfSEQsIFv+0rt3RBA9TzqwKOv14/gbijj7djyVy0huX6QjRQkLb8PI1ZDTNIkVrlLM+ldIXTgvV2UQKf+UVdY200+3+9GxuwoyoUajf1rjf8Ubw/dyr/8xLMPZYNg4PpQWODE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279665; 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=eUtW5vWPPd1x4qMvAJEnM1mSu+kX6rzAs0yul762ex8=; b=QRTADMlGTd/z8MPcZAjkxBdRNupCmMkvTCTobWXRcrc/HKuPTnnRQNkSLCbSbDGcVtCSsed7ybjUtE6N96fw/NRBObjwka7GDOE+8qq80KaPuK8h3RG56B9/LssvtH8aD2/d/3/JYmroGjD5Rz8tVj4sYLVCjsxYIIAVNigbBTA= 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+95802+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 1667279665248454.48436427037984; Mon, 31 Oct 2022 22:14:25 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 60YLYY1788612x1lsW94bpsC; Mon, 31 Oct 2022 22:14:24 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:24 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162816" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162816" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:23 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985564" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985564" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:20 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V5 09/10] OvmfPkg: Realize EdkiiMemoryAcceptProtocol in TdxDxe Date: Tue, 1 Nov 2022 13:13:48 +0800 Message-Id: <20221101051349.13-10-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: fL8mTfENe2F0Tysalr4PVD9Hx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279664; bh=3578AmV4HfEjd9jpa7HHL62FbhoqNYSyJO5827AHRc8=; h=Cc:Date:From:Reply-To:Subject:To; b=b78Pc69qGphstEa5lf6NrqyLmsm6iRxFdWlxH+XXGsaYOLHG7eoyaqqa5DTdYaACXE2 fz+vFKqMcWClweD3VsUdjR6RThFClEes00jdAQFOltZcy2h8tez+bx4x3TwQyzbgbO51z 4olTlqh/1aPgmfUhZAFVgC+5FiT9Yw7Z+RU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279666523100006 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 Memory usage may exceed the amount accepted at the begining (SEC), TDVF needs to accept memory dynamically when OUT_OF_RESOURCE occurs. Another usage is in SetOrClearSharedBit. If a memory region is changed from shared to private, it must be accepted again. EdkiiMemoryAcceptProtocol is defined in MdePkg and is implementated / installed in TdxDxe for Intel TDX memory acceptance. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/TdxDxe/TdxDxe.c | 103 ++++++++++++++++++++++++++++++++++++++ OvmfPkg/TdxDxe/TdxDxe.inf | 2 + 2 files changed, 105 insertions(+) diff --git a/OvmfPkg/TdxDxe/TdxDxe.c b/OvmfPkg/TdxDxe/TdxDxe.c index 05cfb597dc64..30732f421bb6 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.c +++ b/OvmfPkg/TdxDxe/TdxDxe.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,95 @@ #include #include =20 +#define ALIGNED_2MB_MASK 0x1fffff +EFI_HANDLE mTdxDxeHandle =3D NULL; + +EFI_STATUS +EFIAPI +TdxMemoryAccept ( + IN EDKII_MEMORY_ACCEPT_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS StartAddress, + IN UINTN Size + ) +{ + EFI_STATUS Status; + UINT32 AcceptPageSize; + UINT64 StartAddress1; + UINT64 StartAddress2; + UINT64 StartAddress3; + UINT64 Length1; + UINT64 Length2; + UINT64 Length3; + UINT64 Pages; + + AcceptPageSize =3D FixedPcdGet32 (PcdTdxAcceptPageSize); + StartAddress1 =3D 0; + StartAddress2 =3D 0; + StartAddress3 =3D 0; + Length1 =3D 0; + Length2 =3D 0; + Length3 =3D 0; + + if (Size =3D=3D 0) { + return EFI_SUCCESS; + } + + if (ALIGN_VALUE (StartAddress, SIZE_2MB) !=3D StartAddress) { + StartAddress1 =3D StartAddress; + Length1 =3D ALIGN_VALUE (StartAddress, SIZE_2MB) - StartAddress; + if (Length1 >=3D Size) { + Length1 =3D Size; + } + + StartAddress +=3D Length1; + Size -=3D Length1; + } + + if (Size > SIZE_2MB) { + StartAddress2 =3D StartAddress; + Length2 =3D Size & ~(UINT64)ALIGNED_2MB_MASK; + StartAddress +=3D Length2; + Size -=3D Length2; + } + + if (Size) { + StartAddress3 =3D StartAddress; + Length3 =3D Size; + } + + Status =3D EFI_SUCCESS; + if (Length1 > 0) { + Pages =3D Length1 / SIZE_4KB; + Status =3D TdAcceptPages (StartAddress1, Pages, SIZE_4KB); + if (EFI_ERROR (Status)) { + return Status; + } + } + + if (Length2 > 0) { + Pages =3D Length2 / AcceptPageSize; + Status =3D TdAcceptPages (StartAddress2, Pages, AcceptPageSize); + if (EFI_ERROR (Status)) { + return Status; + } + } + + if (Length3 > 0) { + Pages =3D Length3 / SIZE_4KB; + Status =3D TdAcceptPages (StartAddress3, Pages, SIZE_4KB); + ASSERT (!EFI_ERROR (Status)); + if (EFI_ERROR (Status)) { + return Status; + } + } + + return Status; +} + +EDKII_MEMORY_ACCEPT_PROTOCOL mMemoryAcceptProtocol =3D { + TdxMemoryAccept +}; + VOID SetPcdSettings ( EFI_HOB_PLATFORM_INFO *PlatformInfoHob @@ -279,6 +369,19 @@ TdxDxeEntryPoint ( NULL ); =20 + // + // Install MemoryAccept protocol for TDX + // + Status =3D gBS->InstallProtocolInterface ( + &mTdxDxeHandle, + &gEdkiiMemoryAcceptProtocolGuid, + EFI_NATIVE_INTERFACE, + &mMemoryAcceptProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Install EdkiiMemoryAcceptProtocol failed.\n")); + } + // // Call TDINFO to get actual number of cpus in domain // diff --git a/OvmfPkg/TdxDxe/TdxDxe.inf b/OvmfPkg/TdxDxe/TdxDxe.inf index 3ce8a5c32c98..9793562884c7 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.inf +++ b/OvmfPkg/TdxDxe/TdxDxe.inf @@ -52,6 +52,7 @@ gEfiAcpiTableProtocolGuid ## CONSUMES gEfiMpInitLibMpDepProtocolGuid gEfiMpInitLibUpDepProtocolGuid + gEdkiiMemoryAcceptProtocolGuid =20 [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase @@ -69,3 +70,4 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved + gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageSize --=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 (#95802): https://edk2.groups.io/g/devel/message/95802 Mute This Topic: https://groups.io/mt/94703266/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 Fri Nov 15 10:22:45 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+95803+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+95803+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667279666; cv=none; d=zohomail.com; s=zohoarc; b=AHEVawwpLIvuDPpa+xm+ffv1SKFwFTOhgUNqTO+SO2x5sUxm6nvYksNZmADP8aV1pDInWHZYYVKFXuXzFSk/lR+HQWCoz5iTcP62ZN4n1uHtXFgVBp1Y2as3uiC9nBqXiVkvW8uvFXoadps8XMuUhbPbBhqQvhWESxFHnKvGa/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667279666; 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=plqsQor2yTyoJbPpDRPMCt7esIAXybutVsAii5QiJ2g=; b=ncNcmbr3l9ryabwt0YIOpIx/VxNDe3ToXAT2miWQ1zdKCZU4k6Y/MVOjeKQ/0zyUEc381FrrgDVn2JFDRvhFTKey/+ZfkG1BYrGIqYpdfDqYlT1BUREHubJ26bt75SZTTGTFV6wM42YCepRoiU83nOvJHdbvcMZBz8sjvZn+IvQ= 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+95803+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 1667279666354741.3290876774531; Mon, 31 Oct 2022 22:14:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id hXHUYY1788612xdPBMKDDHAv; Mon, 31 Oct 2022 22:14:26 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.2818.1667279643333273629 for ; Mon, 31 Oct 2022 22:14:25 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310162827" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310162827" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:24 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878985579" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878985579" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.119]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 22:14:22 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky Subject: [edk2-devel] [PATCH V5 10/10] OvmfPkg: Call gEdkiiMemoryAcceptProtocolGuid to accept pages Date: Tue, 1 Nov 2022 13:13:49 +0800 Message-Id: <20221101051349.13-11-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> References: <20221101051349.13-1-min.m.xu@intel.com> 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: cQJNLVoR2rQ3nXyTUwZCkMA0x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667279666; bh=WrP3/Yn24MPE5X5gSnjSG3QPm+amIYR8pTgCLl+YwuU=; h=Cc:Date:From:Reply-To:Subject:To; b=Z65LYnxd8OpQNyb+ovuMCX5xEUZV3lC6ylR3uCsC6xt8mXJo4gTfbKSNKSF2ZfGhpN7 OFI+GdyApORzfbWDnmh93OiyNAvtuZZrwzfCyPCvp0K8nQ3rVPO1/A746HWbpvuJvb6vW gA8x3pfFSncvEbFINGws0gjsC6SzCaHENv8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667279666517100005 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 After EdkiiMemoryAcceptProtocol is implemented in TdxDxe driver, we can call it to accept pages in DXE phase. Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- .../BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf | 3 +++ .../Library/BaseMemEncryptTdxLib/MemoryEncryption.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf = b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf index a8abfec12fa3..11768825f8ca 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf @@ -42,3 +42,6 @@ =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr + +[Protocols] + gEdkiiMemoryAcceptProtocolGuid diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c b/Ovmf= Pkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c index 9d11c6e4df72..503f626d75c6 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c @@ -27,6 +27,8 @@ #include "VirtualMemory.h" #include #include +#include +#include #include =20 typedef enum { @@ -517,8 +519,9 @@ SetOrClearSharedBit ( IN UINT64 Length ) { - UINT64 AddressEncMask; - UINT64 Status; + UINT64 AddressEncMask; + UINT64 Status; + EDKII_MEMORY_ACCEPT_PROTOCOL *MemoryAcceptProtocol; =20 AddressEncMask =3D GetMemEncryptionAddressMask (); =20 @@ -539,7 +542,10 @@ SetOrClearSharedBit ( // If changing shared to private, must accept-page again // if (Mode =3D=3D ClearSharedBit) { - TdAcceptPages (PhysicalAddress, Length / EFI_PAGE_SIZE, EFI_PAGE_SIZE); + Status =3D gBS->LocateProtocol (&gEdkiiMemoryAcceptProtocolGuid, NULL,= (VOID **)&MemoryAcceptProtocol); + ASSERT (!EFI_ERROR (Status)); + Status =3D MemoryAcceptProtocol->AcceptMemory (MemoryAcceptProtocol, P= hysicalAddress, Length); + ASSERT (!EFI_ERROR (Status)); } =20 DEBUG (( --=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 (#95803): https://edk2.groups.io/g/devel/message/95803 Mute This Topic: https://groups.io/mt/94703267/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-