From nobody Sat May 11 15:50:25 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+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- From nobody Sat May 11 15:50:25 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+97751+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+97751+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1672018443; cv=none; d=zohomail.com; s=zohoarc; b=W40nEkYsk21Z70lzWmsqzNwP85sM749xUXPdDoL0Z+xBN8kNr0W3bR/j8aZ/bK+hLqLZqR5oJep2at8EF/gZRyBMLa8+1G1YXpO4YXE4lJ1QJM35ThoKgTgnyKUHBqLolTCvTobLBqREu0nKr7vcv/rq9y5sdUKr/mNlS97qC7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672018443; 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=/u509KRdmwFFOf7wqlu+u4erh4C6uQZst0a7+k/yzSU=; b=npQqz7fZmZ9OHJRNWoCulUepmmSst8jRIN/Mu9l5DvU/n++HOxm+JPj8QJyr5wjJvo2utqNzKd8xDtImCPwTY3jYV/Ay8gv71SpYjZHn3CeF8MkulqJPMiiixvL69P39xjPsI0b+px0lI9WNrXvHBA6bDQYnf8oT7CqvXhLpGOc= 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+97751+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 1672018443496641.5911088942493; Sun, 25 Dec 2022 17:34:03 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Y1KHYY1788612xCWDYqKktbZ; Sun, 25 Dec 2022 17:34:02 -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="347697069" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="347697069" 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:00 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10571"; a="826755462" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="826755462" 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:53 -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 2/3] OvmfPkg/PeilessStartupLib: Update ConstructFwHobList for lazy-accept Date: Mon, 26 Dec 2022 09:33:37 +0800 Message-Id: <20221226013338.1924-3-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: cVDvqogROwzMGMQBNUzew9p3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1672018442; bh=muRzhJSrhcwXfU4eEetn39C6+Noh5pEmFAvQH5l33Uw=; h=Cc:Date:From:Reply-To:Subject:To; b=n2xysJDpU/zxoJ51gc7Bq5nyi5AdH0999hGW4+jzIUWOEJsSjQrHaUB+nWqwwM7vcr5 rdAgCykPED0X99m2xGI1/tdLesH61HvJU+U7aKcT47QhfRiErhKiFRqabhrpPVmko3baZ pIEmb7U0uaEmcHqyjIQItwqHHfsCrYAdhcA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1672018445141000012 Content-Type: text/plain; charset="utf-8" From: Min M Xu BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4181 ConstructFwHobList once searched the accepted memory under 4G. This need to be updated because of PcdAcceptMemoryEndAddress. If PcdAcceptMemoryEndAddress is less than 4G, we should search the memory under PcdAcceptMemoryEndAddress. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/Library/PeilessStartupLib/Hob.c | 25 +++++++++++++------ .../PeilessStartupLib/PeilessStartupLib.inf | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/Library/PeilessStartupLib/Hob.c b/OvmfPkg/Library/Peil= essStartupLib/Hob.c index 630ce445ebec..8ea7a68343ed 100644 --- a/OvmfPkg/Library/PeilessStartupLib/Hob.c +++ b/OvmfPkg/Library/PeilessStartupLib/Hob.c @@ -74,17 +74,23 @@ ConstructFwHobList ( ) { EFI_PEI_HOB_POINTERS Hob; + EFI_PHYSICAL_ADDRESS PhysicalStart; EFI_PHYSICAL_ADDRESS PhysicalEnd; UINT64 ResourceLength; EFI_PHYSICAL_ADDRESS LowMemoryStart; UINT64 LowMemoryLength; + EFI_PHYSICAL_ADDRESS AcceptMemoryEndAddress; =20 ASSERT (VmmHobList !=3D NULL); =20 Hob.Raw =3D (UINT8 *)VmmHobList; =20 - LowMemoryLength =3D 0; - LowMemoryStart =3D 0; + LowMemoryLength =3D 0; + LowMemoryStart =3D 0; + AcceptMemoryEndAddress =3D FixedPcdGet64 (PcdAcceptMemoryEndAddress); + if ((AcceptMemoryEndAddress =3D=3D 0) || (AcceptMemoryEndAddress > SIZE_= 4GB)) { + AcceptMemoryEndAddress =3D SIZE_4GB; + } =20 // // Parse the HOB list until end of list or matching type is found. @@ -92,16 +98,21 @@ ConstructFwHobList ( while (!END_OF_HOB_LIST (Hob)) { if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { if (Hob.ResourceDescriptor->ResourceType =3D=3D BZ3937_EFI_RESOURCE_= MEMORY_UNACCEPTED) { - PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Hob.Res= ourceDescriptor->ResourceLength; + PhysicalStart =3D Hob.ResourceDescriptor->PhysicalStart; + PhysicalEnd =3D PhysicalStart + Hob.ResourceDescriptor->Resourc= eLength; ResourceLength =3D Hob.ResourceDescriptor->ResourceLength; =20 - if (PhysicalEnd <=3D BASE_4GB) { + if (PhysicalEnd >=3D AcceptMemoryEndAddress) { + ResourceLength =3D AcceptMemoryEndAddress - PhysicalStart; + } + + if (PhysicalStart >=3D AcceptMemoryEndAddress) { + break; + } else { if (ResourceLength > LowMemoryLength) { LowMemoryStart =3D Hob.ResourceDescriptor->PhysicalStart; LowMemoryLength =3D ResourceLength; } - } else { - break; } } } @@ -110,7 +121,7 @@ ConstructFwHobList ( } =20 if (LowMemoryLength =3D=3D 0) { - DEBUG ((DEBUG_ERROR, "Cannot find a memory region under 4GB for Fw hob= list.\n")); + DEBUG ((DEBUG_ERROR, "Cannot find a memory region under 0x%llx for Fw = hoblist.\n", AcceptMemoryEndAddress)); return EFI_NOT_FOUND; } =20 diff --git a/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf b/Ovmf= Pkg/Library/PeilessStartupLib/PeilessStartupLib.inf index def50b4b019e..644facb60074 100644 --- a/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf +++ b/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf @@ -88,3 +88,4 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ##= CONSUMES gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize + gUefiOvmfPkgTokenSpaceGuid.PcdAcceptMemoryEndAddress --=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 (#97751): https://edk2.groups.io/g/devel/message/97751 Mute This Topic: https://groups.io/mt/95882248/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 Sat May 11 15:50:25 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+97753+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+97753+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=J9oFIDCYVo/Kgpy1hZrMCFx2ecP/kVNqy+CJjCRlXGh8DNzY7sLNt6wpZPzt7QjP2cXff5EM6HADo/PZnnRYBnhAc9oSnPUPHAHaCiMA+64jinRJZtW+HFxfkUNCZPTV5fymhzenQEwKzmiq8ZSyfp/e/98Q3UmfmB9/xWekZXs= 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=da6BmiKHtZcBpJG4oU/Yl1P2NFXwQSSbzQMr01IX8Fk=; b=QN2itfndA2OsVFZxvxX3LkBiTCOG6XdnPtHgQ99jckez/R2RtF7S+G83M2OZ0SCkByDHaqK7R0vRfAy9kTGot2hkJeZPjBPxhpEd6QKr8Wh+pycQhnTJ+QhrzFqZCH4m2BiGR7M7sqSZGlJAntA+7ZxSAJDwGvCpvQ48FSwEIY8= 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+97753+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 167201844479323.13813482485625; Sun, 25 Dec 2022 17:34:04 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id qhBmYY1788612xUn0Qu2wHH0; 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="347697082" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="347697082" 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:00 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10571"; a="826755467" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="826755467" 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:56 -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 3/3] OvmfPkg/PlatformPei: Adjust LowerMemorySize in PublishPeiMemory Date: Mon, 26 Dec 2022 09:33:38 +0800 Message-Id: <20221226013338.1924-4-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: nFbadF959XZf4FnPWpGh5PBex1787277AA= 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=fnwVA4S7m2sms3T85qQ6J3ELfYgVHeJh12OKBiStxo8=; h=Cc:Date:From:Reply-To:Subject:To; b=qSzlLK0dDRBnE5rqFk0Utb5VpgCmfEMnQPjDcY+86kSarv40PcQhxFac7eEq2Ae6TrB e+vu2mhd6XpbLlH8n+Q3NwyBHauWDHW1U3kaovwmOV55rrUoLxOo755KD0z5IdMnWICVf kDpUZpBA4kXpAVi5yFr0lxefpgYq75gQWjI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1672018445132000011 Content-Type: text/plain; charset="utf-8" From: Min M Xu BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4181 With the introduce of PcdAcceptMemoryEndAddress, TDVF may accept less memory than LowerMemorySizse. So it should be adjusted in PublishPeiMemory(). Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/PlatformPei/MemDetect.c | 13 +++++++++++++ OvmfPkg/PlatformPei/PlatformPei.inf | 1 + 2 files changed, 14 insertions(+) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 3d8375320dcb..12a1ad46f1ca 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -270,8 +270,21 @@ PublishPeiMemory ( UINT32 PeiMemoryCap; UINT32 S3AcpiReservedMemoryBase; UINT32 S3AcpiReservedMemorySize; + UINT64 AcceptMemoryEndAddress; =20 LowerMemorySize =3D PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob= ); + + // + // In Tdx guest there may be less memory accepted than LowerMemorySize. + // So LowerMemorySize need to be adjusted accordingly. + // + if (TdIsEnabled ()) { + AcceptMemoryEndAddress =3D FixedPcdGet64 (PcdAcceptMemoryEndAddress); + if ((AcceptMemoryEndAddress < SIZE_4GB) && (LowerMemorySize > (UINT32)= (UINTN)AcceptMemoryEndAddress)) { + LowerMemorySize =3D (UINT32)(UINTN)AcceptMemoryEndAddress; + } + } + if (PlatformInfoHob->SmmSmramRequire) { // // TSEG is chipped from the end of low RAM diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 1fadadeb5565..c87d2fa25c08 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -130,6 +130,7 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize + gUefiOvmfPkgTokenSpaceGuid.PcdAcceptMemoryEndAddress =20 [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable --=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 (#97753): https://edk2.groups.io/g/devel/message/97753 Mute This Topic: https://groups.io/mt/95882250/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-