From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 643A3740041 for ; Fri, 26 Jan 2024 15:50:35 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=UOC5heZsNmuFaRfTxgAl0P+EdG65er1U3MaE1g+BCC4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Thread-Index:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding:Content-Language; s=20140610; t=1706284234; v=1; b=ZzVkLoSockM610jHMBv7x1S9W4t9UGGnipPznTVhAMIdG2RWq2ce3BPFgr9ODbhoEK0Kq8L4 rS8eWyLTckszoaentoIQEjGA0YCXRSkxvlZL57DG9YGSO+md+TqE+MovDPEC9EllMzY+3Ub97dI EqHWIeVLBHYKvplGzR1Lxj6Y= X-Received: by 127.0.0.2 with SMTP id jq9uYY7687511xm7HRcjEFtB; Fri, 26 Jan 2024 07:50:34 -0800 X-Received: from cxsh.intel-email.com (cxsh.intel-email.com [121.46.250.151]) by mx.groups.io with SMTP id smtpd.web10.1113.1706284231710328863 for ; Fri, 26 Jan 2024 07:50:33 -0800 X-Received: from cxsh.intel-email.com (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id B37B3DDA7B1 for ; Fri, 26 Jan 2024 23:50:24 +0800 (CST) X-Received: from localhost (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id AEB2CDDA7A1 for ; Fri, 26 Jan 2024 23:50:24 +0800 (CST) X-Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by cxsh.intel-email.com (Postfix) with SMTP id 04473DDA79C for ; Fri, 26 Jan 2024 23:50:21 +0800 (CST) X-Received: from DESKTOPS6D0PVI ([114.93.194.54]) (envelope-sender ) by 192.168.6.13 with ESMTP(SSL) for ; Fri, 26 Jan 2024 23:50:13 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 114.93.194.54 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming via groups.io" To: "'Kinney, Michael D'" , , "'Laszlo Ersek'" Cc: "'Li, Aaron'" , "'Liu, Yun Y'" , "'Andrew Fish'" References: <20240123202424.1960-1-michael.d.kinney@intel.com> <01d301da4ed5$f3527940$d9f76bc0$@byosoft.com.cn> <01fe01da4f2c$721bc9b0$56535d10$@byosoft.com.cn> In-Reply-To: Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0g5Zue5aSNOiBbUGF0Y2ggdjIgMS8xXSBNZGVNb2R1bGVQa2cvQ29yZS9EeGU6IFNldCBNZW1vcnlUeXBlSW5mbyBiaW4gcmFuZ2UgZnJvbSBIT0I=?= Date: Fri, 26 Jan 2024 23:50:16 +0800 Message-ID: <01ba01da506f$5bbc25e0$133471a0$@byosoft.com.cn> MIME-Version: 1.0 Thread-Index: AQKlaLmYUGFC0Hf9tRtlc8DcZosrwwLqrpYNAU/IF90CBZozUgIkRilxAYJUjiGvBtZ4MA== Precedence: Bulk 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,gaoliming@byosoft.com.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: jCwohkjHXBu0IOl8ybxXhXwMx7686176AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=ZzVkLoSo; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Mike: OK. I agree this patch can assure the memory type be always allocated at = the same address. I have no comments for this change. =20 Thanks Liming > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > =E5=8F=91=E4=BB=B6=E4=BA=BA: Kinney, Michael D > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2024=E5=B9=B41=E6=9C=8825=E6=97=A5 = 9:39 > =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io; gaoliming@byosoft.com.= cn; 'Laszlo Ersek' > > =E6=8A=84=E9=80=81: Li, Aaron ; Liu, Yun Y ; > 'Andrew Fish' ; Kinney, Michael D > > =E4=B8=BB=E9=A2=98: RE: [edk2-devel] =E5=9B=9E=E5=A4=8D: [Patch v2 1/1] M= deModulePkg/Core/Dxe: Set > MemoryTypeInfo bin range from HOB >=20 > Hi Liming, >=20 > The exact range that may or may not support S4 resume may be OS > dependent. > I am not sure. >=20 > In general, a UEFI OS should not be dependent on specific UEFI memory > types being above or below specific addresses. >=20 > The only S4 requirement I know of is landing the memory types at the > same address. >=20 > If you are aware of additional constraints for specific OSes, then > that is good information, but not sure where to put it. >=20 > Mike >=20 > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of > gaoliming > > via groups.io > > Sent: Wednesday, January 24, 2024 5:19 PM > > To: Kinney, Michael D ; 'Laszlo Ersek' > > ; devel@edk2.groups.io > > Cc: Li, Aaron ; Liu, Yun Y ; > > 'Andrew Fish' > > Subject: =E5=9B=9E=E5=A4=8D: [edk2-devel] =E5=9B=9E=E5=A4=8D: [Patch v2= 1/1] > MdeModulePkg/Core/Dxe: > > Set MemoryTypeInfo bin range from HOB > > > > Mike: > > I suggest to document the recommended usage of the specified memory > > type info bin range. I worry that someone configures the low memory > > range for the memory type info bin range. It may still cause S4 failure= . > > > > Thanks > > Liming > > > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > > > =E5=8F=91=E4=BB=B6=E4=BA=BA: Kinney, Michael D > > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2024=E5=B9=B41=E6=9C=8825=E6=97= =A5 1:53 > > > =E6=94=B6=E4=BB=B6=E4=BA=BA: Laszlo Ersek ; devel@= edk2.groups.io; > > > gaoliming@byosoft.com.cn > > > =E6=8A=84=E9=80=81: Li, Aaron ; Liu, Yun Y > > ; > > > 'Andrew Fish' ; Kinney, Michael D > > > > > > =E4=B8=BB=E9=A2=98: RE: [edk2-devel] =E5=9B=9E=E5=A4=8D: [Patch v2 1/= 1] MdeModulePkg/Core/Dxe: > Set > > > MemoryTypeInfo bin range from HOB > > > > > > Hi Liming, > > > > > > The current algorithm allocates the bins from the top of the first > > > memory range given to the DXE Core. This is not guaranteed to be > > > the top of RAM. The heuristic will use the memory range from the > > > PHIT HOB if it is considered big enough. If PHIT is not big enough > > > then a search of the HOBs is made for one that is considered big > > > enough near the top of memory that is tested. > > > > > > Additional memory can be added or promoted from untested to tested > > > after DXE Core init and that added or promoted memory may have > > > a higher address than the initial memory given to the DXE Core. > > > > > > With current heuristics, platforms have to carefully construct the > > > HOBs in PEIM phase to get the behavior where these bins are at the > > > top of RAM. > > > > > > With this feature, it provides precise control over where the > > > bins are placed. > > > > > > Mike > > > > > > > -----Original Message----- > > > > From: Laszlo Ersek > > > > Sent: Wednesday, January 24, 2024 8:17 AM > > > > To: devel@edk2.groups.io; gaoliming@byosoft.com.cn; Kinney, Michael > > D > > > > > > > > Cc: Li, Aaron ; Liu, Yun Y > > ; > > > > 'Andrew Fish' > > > > Subject: Re: [edk2-devel] =E5=9B=9E=E5=A4=8D: [Patch v2 1/1] > > MdeModulePkg/Core/Dxe: > > > > Set MemoryTypeInfo bin range from HOB > > > > > > > > On 1/24/24 15:59, gaoliming via groups.io wrote: > > > > > Mike: > > > > > Current algorithm tries to reserve the top available memory for > > > > memory type > > > > > bin range. > > > > > If the platform uses new way to describe the memory range, shoul= d > > we > > > > > suggest the rule to still > > > > > use the top memory resource hob for the memory type bin range? > > > > > > > > How would that work, technically? If the platform specifies a > > concrete > > > > address range, how can that be reconciled with using the top of RAM= ? > > > > > > > > Or do you mean documentation? I.e., a note for platform implementor= s > > > > that they should point their new HOB to the top of RAM? > > > > > > > > Thanks > > > > Laszlo > > > > > > > > > > > > > > Thanks > > > > > Liming > > > > >> -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > > > > >> =E5=8F=91=E4=BB=B6=E4=BA=BA: Michael D Kinney > > > > >> =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2024=E5=B9=B41=E6=9C=8824= =E6=97=A5 4:24 > > > > >> =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io > > > > >> =E6=8A=84=E9=80=81: Liming Gao ; Aaron= Li > > > > >> ; Liu Yun ; Andrew Fish > > > > >> > > > > >> =E4=B8=BB=E9=A2=98: [Patch v2 1/1] MdeModulePkg/Core/Dxe: Set > MemoryTypeInfo > > > bin > > > > >> range from HOB > > > > >> > > > > >> Provide an optional method for PEI to declare a specific address > > > > >> range to use for the Memory Type Information bins. The current > > > > >> algorithm uses heuristics that tends to place the Memory Type > > > > >> Information bins in the same location, but memory configuration > > > > >> changes across boots or algorithm changes across a firmware > > > > >> updates could potentially change the Memory Type Information bin > > > > >> location. > > > > >> > > > > >> If the HOB List contains a Resource Descriptor HOB that > > > > >> describes tested system memory and has an Owner GUID of > > > > >> gEfiMemoryTypeInformationGuid, then use the address range > > > > >> described by the Resource Descriptor HOB as the preferred > > > > >> location of the Memory Type Information bins. If this HOB is > > > > >> not detected, then the current behavior is preserved. > > > > >> > > > > >> The HOB with an Owner GUID of gEfiMemoryTypeInformationGuid > > > > >> is ignored for the following conditions: > > > > >> * The HOB with an Owner GUID of gEfiMemoryTypeInformationGuid > > > > >> is smaller than the Memory Type Information bins. > > > > >> * The HOB list contains more than one Resource Descriptor HOB > > > > >> with an owner GUID of gEfiMemoryTypeInformationGuid. > > > > >> * The Resource Descriptor HOB with an Owner GUID of > > > > >> gEfiMemoryTypeInformationGuid is the same Resource Descriptor > > > > >> HOB that that describes the PHIT memory range. > > > > >> > > > > >> Update the DxeMain initialization order to initialize GCD > > > > >> services before any runtime allocations are performed. This > > > > >> is required to prevent runtime data fragmentation when the > > > > >> UEFI System Table and UEFI Runtime Service Table is allocated. > > > > >> > > > > >> Cc: Liming Gao > > > > >> Cc: Aaron Li > > > > >> Cc: Liu Yun > > > > >> Cc: Andrew Fish > > > > >> Signed-off-by: Michael D Kinney > > > > >> --- > > > > >> MdeModulePkg/Core/Dxe/DxeMain.h | 6 ++ > > > > >> MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 23 +++--- > > > > >> MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 72 > > > ++++++++++++++++- > > > > >> MdeModulePkg/Core/Dxe/Mem/Page.c | 101 > > > > >> ++++++++++++++++++++++++ > > > > >> 4 files changed, 190 insertions(+), 12 deletions(-) > > > > >> > > > > >> diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h > > > > >> b/MdeModulePkg/Core/Dxe/DxeMain.h > > > > >> index 86a7be2f5188..53e26703f8c7 100644 > > > > >> --- a/MdeModulePkg/Core/Dxe/DxeMain.h > > > > >> +++ b/MdeModulePkg/Core/Dxe/DxeMain.h > > > > >> @@ -277,6 +277,12 @@ CoreInitializePool ( > > > > >> VOID > > > > >> ); > > > > >> > > > > >> +VOID > > > > >> +CoreSetMemoryTypeInformationRange ( > > > > >> + IN EFI_PHYSICAL_ADDRESS Start, > > > > >> + IN UINT64 Length > > > > >> + ); > > > > >> + > > > > >> /** > > > > >> Called to initialize the memory map and add descriptors to > > > > >> the current descriptor list. > > > > >> diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c > > > > >> b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c > > > > >> index 0e0f9769b99d..17d510a287e5 100644 > > > > >> --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c > > > > >> +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c > > > > >> @@ -276,6 +276,18 @@ DxeMain ( > > > > >> > > > > >> MemoryProfileInit (HobStart); > > > > >> > > > > >> + // > > > > >> + // Start the Image Services. > > > > >> + // > > > > >> + Status =3D CoreInitializeImageServices (HobStart); > > > > >> + ASSERT_EFI_ERROR (Status); > > > > >> + > > > > >> + // > > > > >> + // Initialize the Global Coherency Domain Services > > > > >> + // > > > > >> + Status =3D CoreInitializeGcdServices (&HobStart, > > MemoryBaseAddress, > > > > >> MemoryLength); > > > > >> + ASSERT_EFI_ERROR (Status); > > > > >> + > > > > >> // > > > > >> // Allocate the EFI System Table and EFI Runtime Service Tabl= e > > > > from > > > > >> EfiRuntimeServicesData > > > > >> // Use the templates to initialize the contents of the EFI > > System > > > > Table > > > > > and > > > > >> EFI Runtime Services Table > > > > >> @@ -289,16 +301,9 @@ DxeMain ( > > > > >> gDxeCoreST->RuntimeServices =3D gDxeCoreRT; > > > > >> > > > > >> // > > > > >> - // Start the Image Services. > > > > >> + // Update DXE Core Loaded Image Protocol with allocated UEFI > > > > System > > > > >> Table > > > > >> // > > > > >> - Status =3D CoreInitializeImageServices (HobStart); > > > > >> - ASSERT_EFI_ERROR (Status); > > > > >> - > > > > >> - // > > > > >> - // Initialize the Global Coherency Domain Services > > > > >> - // > > > > >> - Status =3D CoreInitializeGcdServices (&HobStart, > > MemoryBaseAddress, > > > > >> MemoryLength); > > > > >> - ASSERT_EFI_ERROR (Status); > > > > >> + gDxeCoreLoadedImage->SystemTable =3D gDxeCoreST; > > > > >> > > > > >> // > > > > >> // Call constructor for all libraries > > > > >> diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > > > > >> b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > > > > >> index 792cd2e0af23..c450d1bf2531 100644 > > > > >> --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > > > > >> +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > > > > >> @@ -2238,6 +2238,8 @@ CoreInitializeMemoryServices ( > > > > >> EFI_HOB_HANDOFF_INFO_TABLE *PhitHob; > > > > >> EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; > > > > >> EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob; > > > > >> + EFI_HOB_RESOURCE_DESCRIPTOR > > > > >> *MemoryTypeInformationResourceHob; > > > > >> + UINTN Count; > > > > >> EFI_PHYSICAL_ADDRESS BaseAddress; > > > > >> UINT64 Length; > > > > >> UINT64 Attributes; > > > > >> @@ -2289,12 +2291,47 @@ CoreInitializeMemoryServices ( > > > > >> // > > > > >> // See if a Memory Type Information HOB is available > > > > >> // > > > > >> - GuidHob =3D GetFirstGuidHob (&gEfiMemoryTypeInformationGuid); > > > > >> + MemoryTypeInformationResourceHob =3D NULL; > > > > >> + GuidHob =3D GetFirstGuidHob > > > > >> (&gEfiMemoryTypeInformationGuid); > > > > >> if (GuidHob !=3D NULL) { > > > > >> EfiMemoryTypeInformation =3D GET_GUID_HOB_DATA > (GuidHob); > > > > >> DataSize =3D GET_GUID_HOB_DATA_SIZE > > > (GuidHob); > > > > >> if ((EfiMemoryTypeInformation !=3D NULL) && (DataSize > 0) = && > > > > (DataSize > > > > >> <=3D (EfiMaxMemoryType + 1) * sizeof > > > (EFI_MEMORY_TYPE_INFORMATION))) { > > > > >> CopyMem (&gMemoryTypeInformation, > > > EfiMemoryTypeInformation, > > > > >> DataSize); > > > > >> + > > > > >> + // > > > > >> + // Look for Resource Descriptor HOB with a ResourceType o= f > > > > System > > > > >> Memory > > > > >> + // and an Owner GUID of gEfiMemoryTypeInformationGuid. > If > > > more > > > > >> than 1 is > > > > >> + // found, then set MemoryTypeInformationResourceHob to > > > NULL. > > > > >> + // > > > > >> + Count =3D 0; > > > > >> + for (Hob.Raw =3D *HobStart; !END_OF_HOB_LIST (Hob); > Hob.Raw > > > =3D > > > > >> GET_NEXT_HOB (Hob)) { > > > > >> + if (GET_HOB_TYPE (Hob) !=3D > > > > >> EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { > > > > >> + continue; > > > > >> + } > > > > >> + > > > > >> + ResourceHob =3D Hob.ResourceDescriptor; > > > > >> + if (!CompareGuid (&ResourceHob->Owner, > > > > >> &gEfiMemoryTypeInformationGuid)) { > > > > >> + continue; > > > > >> + } > > > > >> + > > > > >> + Count++; > > > > >> + if (ResourceHob->ResourceType !=3D > > > > >> EFI_RESOURCE_SYSTEM_MEMORY) { > > > > >> + continue; > > > > >> + } > > > > >> + > > > > >> + if ((ResourceHob->ResourceAttribute & > > > > >> MEMORY_ATTRIBUTE_MASK) !=3D TESTED_MEMORY_ATTRIBUTES) { > > > > >> + continue; > > > > >> + } > > > > >> + > > > > >> + if (ResourceHob->ResourceLength >=3D > > > > >> CalculateTotalMemoryBinSizeNeeded ()) { > > > > >> + MemoryTypeInformationResourceHob =3D ResourceHob; > > > > >> + } > > > > >> + } > > > > >> + > > > > >> + if (Count > 1) { > > > > >> + MemoryTypeInformationResourceHob =3D NULL; > > > > >> + } > > > > >> } > > > > >> } > > > > >> > > > > >> @@ -2344,6 +2381,15 @@ CoreInitializeMemoryServices ( > > > > >> PhitResourceHob =3D ResourceHob; > > > > >> Found =3D TRUE; > > > > >> > > > > >> + // > > > > >> + // If a Memory Type Information Resource HOB was found and > > is > > > > the > > > > >> same > > > > >> + // Resource HOB that describes the PHIT HOB, then ignore th= e > > > > Memory > > > > >> Type > > > > >> + // Information Resource HOB. > > > > >> + // > > > > >> + if (MemoryTypeInformationResourceHob =3D=3D PhitResourceHob= ) > { > > > > >> + MemoryTypeInformationResourceHob =3D NULL; > > > > >> + } > > > > >> + > > > > >> // > > > > >> // Compute range between PHIT EfiMemoryTop and the end of > > > the > > > > >> Resource Descriptor HOB > > > > >> // > > > > >> @@ -2387,8 +2433,9 @@ CoreInitializeMemoryServices ( > > > > >> if (Length < MinimalMemorySizeNeeded) { > > > > >> // > > > > >> // Search all the resource descriptor HOBs from the highest > > > > possible > > > > >> addresses down for a memory > > > > >> - // region that is big enough to initialize the DXE core. > > Always > > > > skip > > > > > the > > > > >> PHIT Resource HOB. > > > > >> - // The max address must be within the physically addressibl= e > > > > range > > > > > for > > > > >> the processor. > > > > >> + // region that is big enough to initialize the DXE core. > > Always > > > > skip > > > > > the > > > > >> PHIT Resource HOB > > > > >> + // and the Memory Type Information Resource HOB. The max > > > address > > > > >> must be within the physically > > > > >> + // addressable range for the processor. > > > > >> // > > > > >> HighAddress =3D MAX_ALLOC_ADDRESS; > > > > >> for (Hob.Raw =3D *HobStart; !END_OF_HOB_LIST (Hob); > Hob.Raw =3D > > > > >> GET_NEXT_HOB (Hob)) { > > > > >> @@ -2399,6 +2446,13 @@ CoreInitializeMemoryServices ( > > > > >> continue; > > > > >> } > > > > >> > > > > >> + // > > > > >> + // Skip the Resource Descriptor HOB that contains Memory > > Type > > > > >> Information bins > > > > >> + // > > > > >> + if (Hob.ResourceDescriptor =3D=3D > > > > MemoryTypeInformationResourceHob) > > > > >> { > > > > >> + continue; > > > > >> + } > > > > >> + > > > > >> // > > > > >> // Skip all HOBs except Resource Descriptor HOBs > > > > >> // > > > > >> @@ -2466,6 +2520,18 @@ CoreInitializeMemoryServices ( > > > > >> Capabilities =3D > > > > >> CoreConvertResourceDescriptorHobAttributesToCapabilities > > > > >> (EfiGcdMemoryTypeSystemMemory, Attributes); > > > > >> } > > > > >> > > > > >> + if (MemoryTypeInformationResourceHob !=3D NULL) { > > > > >> + // > > > > >> + // If a Memory Type Information Resource HOB was found, > then > > > use > > > > the > > > > >> address > > > > >> + // range of the Memory Type Information Resource HOB as > the > > > > >> preferred > > > > >> + // address range for the Memory Type Information bins. > > > > >> + // > > > > >> + CoreSetMemoryTypeInformationRange ( > > > > >> + MemoryTypeInformationResourceHob->PhysicalStart, > > > > >> + MemoryTypeInformationResourceHob->ResourceLength > > > > >> + ); > > > > >> + } > > > > >> + > > > > >> // > > > > >> // Declare the very first memory region, so the EFI Memory > > > > Services are > > > > >> available. > > > > >> // > > > > >> diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c > > > > >> b/MdeModulePkg/Core/Dxe/Mem/Page.c > > > > >> index 6497af573353..458c62090265 100644 > > > > >> --- a/MdeModulePkg/Core/Dxe/Mem/Page.c > > > > >> +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c > > > > >> @@ -532,6 +532,107 @@ CoreLoadingFixedAddressHook ( > > > > >> return; > > > > >> } > > > > >> > > > > >> +/** > > > > >> + Sets the preferred memory range to use for the Memory Type > > > > Information > > > > >> bins. > > > > >> + This service must be called before fist call to > > > > > CoreAddMemoryDescriptor(). > > > > >> + > > > > >> + If the location of the Memory Type Information bins has > > already > > > > been > > > > >> + established or the size of the range provides is smaller than > > all > > > > the > > > > >> + Memory Type Information bins, then the range provides is not > > used. > > > > >> + > > > > >> + @param Start The start address of the Memory Type > > > Information > > > > >> range. > > > > >> + @param Length The size, in bytes, of the Memory Type > > > Information > > > > >> range. > > > > >> +**/ > > > > >> +VOID > > > > >> +CoreSetMemoryTypeInformationRange ( > > > > >> + IN EFI_PHYSICAL_ADDRESS Start, > > > > >> + IN UINT64 Length > > > > >> + ) > > > > >> +{ > > > > >> + EFI_PHYSICAL_ADDRESS Top; > > > > >> + EFI_MEMORY_TYPE Type; > > > > >> + UINTN Index; > > > > >> + UINTN Size; > > > > >> + > > > > >> + // > > > > >> + // Return if Memory Type Information bin locations have > > already > > > > been > > > > > set > > > > >> + // > > > > >> + if (mMemoryTypeInformationInitialized) { > > > > >> + return; > > > > >> + } > > > > >> + > > > > >> + // > > > > >> + // Return if size of the Memory Type Information bins is > > greater > > > > than > > > > >> Length > > > > >> + // > > > > >> + Size =3D 0; > > > > >> + for (Index =3D 0; gMemoryTypeInformation[Index].Type !=3D > > > > >> EfiMaxMemoryType; Index++) { > > > > >> + // > > > > >> + // Make sure the memory type in the > gMemoryTypeInformation[] > > > > array > > > > >> is valid > > > > >> + // > > > > >> + Type =3D > > > (EFI_MEMORY_TYPE)(gMemoryTypeInformation[Index].Type); > > > > >> + if ((UINT32)Type > EfiMaxMemoryType) { > > > > >> + continue; > > > > >> + } > > > > >> + > > > > >> + Size +=3D EFI_PAGES_TO_SIZE > > > > >> (gMemoryTypeInformation[Index].NumberOfPages); > > > > >> + } > > > > >> + > > > > >> + if (Size > Length) { > > > > >> + return; > > > > >> + } > > > > >> + > > > > >> + // > > > > >> + // Loop through each memory type in the order specified by th= e > > > > >> + // gMemoryTypeInformation[] array > > > > >> + // > > > > >> + Top =3D Start + Length; > > > > >> + for (Index =3D 0; gMemoryTypeInformation[Index].Type !=3D > > > > >> EfiMaxMemoryType; Index++) { > > > > >> + // > > > > >> + // Make sure the memory type in the > gMemoryTypeInformation[] > > > > array > > > > >> is valid > > > > >> + // > > > > >> + Type =3D > > > (EFI_MEMORY_TYPE)(gMemoryTypeInformation[Index].Type); > > > > >> + if ((UINT32)Type > EfiMaxMemoryType) { > > > > >> + continue; > > > > >> + } > > > > >> + > > > > >> + if (gMemoryTypeInformation[Index].NumberOfPages !=3D 0) { > > > > >> + mMemoryTypeStatistics[Type].MaximumAddress =3D Top - 1; > > > > >> + Top -=3D > > > > >> EFI_PAGES_TO_SIZE > > > (gMemoryTypeInformation[Index].NumberOfPages); > > > > >> + mMemoryTypeStatistics[Type].BaseAddress =3D Top; > > > > >> + > > > > >> + // > > > > >> + // If the current base address is the lowest address so > > far, > > > > then > > > > >> update > > > > >> + // the default maximum address > > > > >> + // > > > > >> + if (mMemoryTypeStatistics[Type].BaseAddress < > > > > >> mDefaultMaximumAddress) { > > > > >> + mDefaultMaximumAddress =3D > > > > >> mMemoryTypeStatistics[Type].BaseAddress - 1; > > > > >> + } > > > > >> + > > > > >> + mMemoryTypeStatistics[Type].NumberOfPages =3D > > > > >> gMemoryTypeInformation[Index].NumberOfPages; > > > > >> + gMemoryTypeInformation[Index].NumberOfPages =3D 0; > > > > >> + } > > > > >> + } > > > > >> + > > > > >> + // > > > > >> + // If the number of pages reserved for a memory type is 0, > > then > > > > all > > > > >> + // allocations for that type should be in the default range. > > > > >> + // > > > > >> + for (Type =3D (EFI_MEMORY_TYPE)0; Type < EfiMaxMemoryType; > > > Type++) { > > > > >> + for (Index =3D 0; gMemoryTypeInformation[Index].Type !=3D > > > > >> EfiMaxMemoryType; Index++) { > > > > >> + if (Type =3D=3D > > > > >> (EFI_MEMORY_TYPE)gMemoryTypeInformation[Index].Type) { > > > > >> + mMemoryTypeStatistics[Type].InformationIndex =3D Index; > > > > >> + } > > > > >> + } > > > > >> + > > > > >> + mMemoryTypeStatistics[Type].CurrentNumberOfPages =3D 0; > > > > >> + if (mMemoryTypeStatistics[Type].MaximumAddress =3D=3D > > > > >> MAX_ALLOC_ADDRESS) { > > > > >> + mMemoryTypeStatistics[Type].MaximumAddress =3D > > > > >> mDefaultMaximumAddress; > > > > >> + } > > > > >> + } > > > > >> + > > > > >> + mMemoryTypeInformationInitialized =3D TRUE; > > > > >> +} > > > > >> + > > > > >> /** > > > > >> Called to initialize the memory map and add descriptors to > > > > >> the current descriptor list. > > > > >> -- > > > > >> 2.40.1.windows.1 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >=20 > > -=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 (#114619): https://edk2.groups.io/g/devel/message/114619 Mute This Topic: https://groups.io/mt/103978575/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-