From nobody Mon Feb 9 23:39:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97754+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+97754+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1672018444; cv=none; d=zohomail.com; s=zohoarc; b=jzF8uI4ZzyKpCvc1FRZ4xD2ndmv7/4mlpMEXP249wBDxIZ1PJZetF6vPtyQwJykS50zRDMd0guOct9ILarwPlGmZXvyQSysjv5oii6EMCr0V0Cj1LMbQMr/0nb4RjJCWuIlpcTfCAXzkAsxDGUNTvdqbOnasdB4dgerkRXk/hy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672018444; 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=iszdW/idhrOBJTZmAeHYmOTem9iiNxNUBZt6jVaoUpk=; b=UWZD4wmErOW344MKhSfHxPfcq3i768HOLZ0Q1yGDALuKxHu44LrFHZc3u4OhAkS9RWZb2M+nBGBhOibqgHS66c/4XB7Gsc7/SldhR20V2R/nTP085W8pLaKs4eckx5JtsJXo8HAEvQcZt7XtzO143CjUJhI5MWwxNbgGNlyKOaQ= 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+97754+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 1672018444689768.9988802274366; Sun, 25 Dec 2022 17:34:04 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id GhPPYY1788612xQ9XzcYtIQx; Sun, 25 Dec 2022 17:34:04 -0800 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.129091.1672018441335739938 for ; Sun, 25 Dec 2022 17:34:01 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10571"; a="347697084" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="347697084" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Dec 2022 17:34:01 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10571"; a="826755456" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="826755456" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.169.98]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Dec 2022 17:33:50 -0800 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 V1 1/3] OvmfPkg: Customize lazy-accept's end address Date: Mon, 26 Dec 2022 09:33:36 +0800 Message-Id: <20221226013338.1924-2-min.m.xu@intel.com> In-Reply-To: <20221226013338.1924-1-min.m.xu@intel.com> References: <20221226013338.1924-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: 91gp1ghL5M4ThU9wTiC3lqTXx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1672018444; bh=ux5O7C+P789G6ge/6OhWNqrHLv4tXfOFIcFDOZUjC4M=; h=Cc:Date:From:Reply-To:Subject:To; b=VAI+aaPWK+w90idGeiOm6N6XJKug3G+0mfmYJ4NKQdcIR3gn0aUl5rWhDg2WNPeSrTN rAQ9PKBirZgHgK4iB1CWsiUxLDBBY31YI7YOuo5k7qFRpc1huyNSwh/Mcjs02AR+8qWNu OWyikWShc25PO6QFdoRDeCC2rYuFfbZgq1U= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1672018445156000013 Content-Type: text/plain; charset="utf-8" From: Min M Xu BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4181 Current lazy-accept accepts the memory under address of 4G. To improve boot performance further more, we introduce the feature of customizing the physical end address of lazy-accept. The end address is indicated by PcdAcceptMemoryEndAddress. It means it accepts the memory under PcdAcceptMemoryEndAddress. The default value is 4G. In IntelTdxX64 PcdAcceptMemoryEndAddress can be customized on-demand in build-time by adding -D ACCEPT_MEMORY_END_ADDRESS=3D512 in build command. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/IntelTdx/IntelTdxX64.dsc | 8 ++++ OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 37 ++++++++++++++----- .../PlatformInitLib/PlatformInitLib.inf | 1 + OvmfPkg/OvmfPkg.dec | 2 + 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX6= 4.dsc index 6ec64df91871..46b0b96ad671 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -62,6 +62,11 @@ # DEFINE UP_CPU_DXE_GUID =3D 6490f1c5-ebcc-4665-8892-0075b9bb49b7 =20 + # + # Define the end of physical address of memory to be accepted. The unit = is M. + # + DEFINE ACCEPT_MEMORY_END_ADDRESS =3D 512 + [BuildOptions] GCC:RELEASE_*_*_CC_FLAGS =3D -DMDEPKG_NDEBUG INTEL:RELEASE_*_*_CC_FLAGS =3D /D MDEPKG_NDEBUG @@ -457,6 +462,9 @@ # TDX need 1G PageTable support gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE =20 + ## End of physical address of memory to be accepted. + gUefiOvmfPkgTokenSpaceGuid.PcdAcceptMemoryEndAddress|($(ACCEPT_MEMORY_EN= D_ADDRESS)*0x100000) + gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000 =20 # IRQs 5, 9, 10, 11 are level-triggered diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c b/OvmfPkg/Library/P= latformInitLib/IntelTdx.c index 6cb63139cba0..9514badb8ef6 100644 --- a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c +++ b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c @@ -375,7 +375,8 @@ AcceptMemoryForAPsStack ( } =20 /** - BSP and APs work togeter to accept memory which is under the address of = 4G. + BSP and APs work togeter to accept memory which is under the address + indicated by PcdAcceptMemoryEndAddress. =20 @param[in] VmmHobList The Hoblist pass the firmware @param[in] CpusNum Number of vCPUs @@ -400,13 +401,22 @@ AcceptMemory ( EFI_PHYSICAL_ADDRESS PhysicalEnd; EFI_PHYSICAL_ADDRESS AcceptMemoryEndAddress; =20 - Status =3D EFI_SUCCESS; - AcceptMemoryEndAddress =3D BASE_4GB; + Status =3D EFI_SUCCESS; =20 ASSERT (VmmHobList !=3D NULL); Hob.Raw =3D (UINT8 *)VmmHobList; =20 - DEBUG ((DEBUG_INFO, "AcceptMemory under address of 4G\n")); + AcceptMemoryEndAddress =3D (PHYSICAL_ADDRESS)FixedPcdGet64 (PcdAcceptMem= oryEndAddress); + if (AcceptMemoryEndAddress =3D=3D 0) { + AcceptMemoryEndAddress =3D MAX_UINT64; + } + + if (AcceptMemoryEndAddress <=3D PhysicalAddressStart) { + ASSERT (FALSE); + return EFI_SUCCESS; + } + + DEBUG ((DEBUG_INFO, "AcceptMemory till 0x%llx\n", AcceptMemoryEndAddress= )); =20 // // Parse the HOB list until end of list or matching type is found. @@ -816,11 +826,7 @@ BuildResourceDescriptorHobForUnacceptedMemory ( ResourceLength =3D Hob->ResourceLength; PhysicalEnd =3D PhysicalStart + ResourceLength; =20 - // - // 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; + MaxAcceptedMemoryAddress =3D FixedPcdGet64 (PcdAcceptMemoryEndAddress); =20 if (PhysicalEnd <=3D MaxAcceptedMemoryAddress) { // @@ -833,6 +839,19 @@ BuildResourceDescriptorHobForUnacceptedMemory ( // This memory region hasn't been accepted. // So keep the ResourceType and ResourceAttribute unchange. // + } else if ((PhysicalStart < MaxAcceptedMemoryAddress) && (PhysicalEnd > = MaxAcceptedMemoryAddress)) { + // + // Left part of the memory region is accepted. The right part is unacc= epted. + // + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ResourceAttribute | (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_A= TTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED), + PhysicalStart, + MaxAcceptedMemoryAddress - PhysicalStart + ); + + PhysicalStart =3D MaxAcceptedMemoryAddress; + ResourceLength =3D PhysicalEnd - MaxAcceptedMemoryAddress; } =20 BuildResourceDescriptorHob ( diff --git a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf b/OvmfPkg/= Library/PlatformInitLib/PlatformInitLib.inf index 140216979a54..2a909ade895b 100644 --- a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf +++ b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf @@ -100,6 +100,7 @@ gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase gUefiOvmfPkgTokenSpaceGuid.PcdCfvRawDataSize + gUefiOvmfPkgTokenSpaceGuid.PcdAcceptMemoryEndAddress =20 [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 693925a1dc7a..e6cc524e0f7f 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -408,6 +408,8 @@ =20 ## The Tdx accept page size. 0x1000(4k),0x200000(2M) gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageSize|0x200000|UINT32|0x65 + ## End of physical address of memory to be accepted + gUefiOvmfPkgTokenSpaceGuid.PcdAcceptMemoryEndAddress|0x100000000|UINT64|= 0x69 =20 ## The QEMU fw_cfg variable that UefiDriverEntryPointFwCfgOverrideLib wi= ll # check to decide whether to abort dispatch of the driver it is linked = into. --=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 (#97754): https://edk2.groups.io/g/devel/message/97754 Mute This Topic: https://groups.io/mt/95882251/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-