From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 932A2211A2D84 for ; Wed, 19 Dec 2018 19:27:43 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2018 19:27:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,375,1539673200"; d="scan'208";a="119847490" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 19 Dec 2018 19:27:42 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 19 Dec 2018 19:27:42 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 19 Dec 2018 19:27:41 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.59]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.222]) with mapi id 14.03.0415.000; Thu, 20 Dec 2018 11:27:39 +0800 From: "Wang, Jian J" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , "Gao, Liming" , "Wu, Hao A" , Leif Lindholm , Laszlo Ersek , Eric Auger , Andrew Jones , "Philippe Mathieu-Daude" Thread-Topic: [PATCH v2 3/6] MdeModulePkg/Dxe/Page: take MAX_ALLOC_ADDRESS into account Thread-Index: AQHUl91igRzU3MB0Lkmavxl/36ZOH6WG98Ag Date: Thu, 20 Dec 2018 03:27:39 +0000 Message-ID: References: <20181219205640.4704-1-ard.biesheuvel@linaro.org> <20181219205640.4704-4-ard.biesheuvel@linaro.org> In-Reply-To: <20181219205640.4704-4-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTY3MDBmOGYtZTQ1Yi00ZGZjLTlkM2MtOTIxODE4N2UxOGFhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiNlFhbnhpclQzbjBKM2lYSnJ1MTRDcndLSDhcL3hCQ0hCeUczeXNYM0lMRkZoaVBFallPRTBtSEZ0TDdnTElmOWoifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 3/6] MdeModulePkg/Dxe/Page: take MAX_ALLOC_ADDRESS into account X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2018 03:27:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jian J Wang > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Thursday, December 20, 2018 4:57 AM > To: edk2-devel@lists.01.org > Cc: Ard Biesheuvel ; Kinney, Michael D > ; Gao, Liming ; Wang, > Jian J ; Wu, Hao A ; Leif > Lindholm ; Laszlo Ersek ; Er= ic > Auger ; Andrew Jones ; > Philippe Mathieu-Daude > Subject: [PATCH v2 3/6] MdeModulePkg/Dxe/Page: take MAX_ALLOC_ADDRESS > into account >=20 > Take MAX_ALLOC_ADDRESS into account in the implementation of the > page allocation routines, so that they will only return memory > that is addressable by the CPU at boot time, even if more memory > is available in the GCD memory map. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > MdeModulePkg/Core/Dxe/Mem/Page.c | 52 ++++++++++---------- > 1 file changed, 26 insertions(+), 26 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c > b/MdeModulePkg/Core/Dxe/Mem/Page.c > index 961c5b833546..5ad8e1171ef7 100644 > --- a/MdeModulePkg/Core/Dxe/Mem/Page.c > +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c > @@ -52,26 +52,26 @@ LIST_ENTRY mFreeMemoryMapEntryList =3D > INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemor > BOOLEAN mMemoryTypeInformationInitialized =3D FALSE; >=20 > EFI_MEMORY_TYPE_STATISTICS mMemoryTypeStatistics[EfiMaxMemoryType + > 1] =3D { > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // > EfiReservedMemoryType > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiLoaderCode > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiLoaderData > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiBootServicesCode > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiBootServicesData > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // > EfiRuntimeServicesCode > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // > EfiRuntimeServicesData > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiConventionalMemory > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiUnusableMemory > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // > EfiACPIReclaimMemory > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // > EfiACPIMemoryNVS > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiMemoryMappedIO > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiMemoryMappedIOPortSpace > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiPalCo= de > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiPersistentMemory > - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // > EfiMaxMemoryType > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // > EfiReservedMemoryType > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiLoaderCode > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiLoaderData > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiBootServicesCode > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiBootServicesData > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // > EfiRuntimeServicesCode > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // > EfiRuntimeServicesData > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiConventionalMemory > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiUnusableMemory > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // > EfiACPIReclaimMemory > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // > EfiACPIMemoryNVS > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiMemoryMappedIO > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiMemoryMappedIOPortSpace > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // > EfiPalCode > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // > EfiPersistentMemory > + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // > EfiMaxMemoryType > }; >=20 > -EFI_PHYSICAL_ADDRESS mDefaultMaximumAddress =3D MAX_ADDRESS; > -EFI_PHYSICAL_ADDRESS mDefaultBaseAddress =3D MAX_ADDRESS; > +EFI_PHYSICAL_ADDRESS mDefaultMaximumAddress =3D MAX_ALLOC_ADDRESS; > +EFI_PHYSICAL_ADDRESS mDefaultBaseAddress =3D MAX_ALLOC_ADDRESS; >=20 > EFI_MEMORY_TYPE_INFORMATION > gMemoryTypeInformation[EfiMaxMemoryType + 1] =3D { > { EfiReservedMemoryType, 0 }, > @@ -419,7 +419,7 @@ PromoteMemoryResource ( > Entry =3D CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE); >=20 > if (Entry->GcdMemoryType =3D=3D EfiGcdMemoryTypeReserved && > - Entry->EndAddress < MAX_ADDRESS && > + Entry->EndAddress < MAX_ALLOC_ADDRESS && > (Entry->Capabilities & (EFI_MEMORY_PRESENT | > EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) =3D=3D > (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)) { > // > @@ -640,7 +640,7 @@ CoreAddMemoryDescriptor ( > gMemoryTypeInformation[FreeIndex].NumberOfPages > ); > mMemoryTypeStatistics[Type].BaseAddress =3D 0; > - mMemoryTypeStatistics[Type].MaximumAddress =3D MAX_ADDRESS; > + mMemoryTypeStatistics[Type].MaximumAddress =3D > MAX_ALLOC_ADDRESS; > } > } > return; > @@ -697,7 +697,7 @@ CoreAddMemoryDescriptor ( > } > } > mMemoryTypeStatistics[Type].CurrentNumberOfPages =3D 0; > - if (mMemoryTypeStatistics[Type].MaximumAddress =3D=3D MAX_ADDRESS) { > + if (mMemoryTypeStatistics[Type].MaximumAddress =3D=3D > MAX_ALLOC_ADDRESS) { > mMemoryTypeStatistics[Type].MaximumAddress =3D > mDefaultMaximumAddress; > } > } > @@ -1318,15 +1318,15 @@ CoreInternalAllocatePages ( > // > // The max address is the max natively addressable address for the pro= cessor > // > - MaxAddress =3D MAX_ADDRESS; > + MaxAddress =3D MAX_ALLOC_ADDRESS; >=20 > // > // Check for Type AllocateAddress, > // if NumberOfPages is 0 or > - // if (NumberOfPages << EFI_PAGE_SHIFT) is above MAX_ADDRESS or > + // if (NumberOfPages << EFI_PAGE_SHIFT) is above MAX_ALLOC_ADDRESS or > // if (Start + NumberOfBytes) rolls over 0 or > - // if Start is above MAX_ADDRESS or > - // if End is above MAX_ADDRESS, > + // if Start is above MAX_ALLOC_ADDRESS or > + // if End is above MAX_ALLOC_ADDRESS, > // return EFI_NOT_FOUND. > // > if (Type =3D=3D AllocateAddress) { > @@ -1968,7 +1968,7 @@ CoreAllocatePoolPages ( > // > // Find the pages to convert > // > - Start =3D FindFreePages (MAX_ADDRESS, NumberOfPages, PoolType, Alignme= nt, > + Start =3D FindFreePages (MAX_ALLOC_ADDRESS, NumberOfPages, PoolType, > Alignment, > NeedGuard); >=20 > // > -- > 2.19.2