From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 42400211944C0 for ; Sun, 9 Dec 2018 18:04:06 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Dec 2018 18:04:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,336,1539673200"; d="scan'208";a="128523070" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga001.fm.intel.com with ESMTP; 09 Dec 2018 18:04:06 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 9 Dec 2018 18:04:06 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 9 Dec 2018 18:04:05 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.59]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.46]) with mapi id 14.03.0415.000; Mon, 10 Dec 2018 10:04:03 +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: [RFC PATCH 3/7] MdeModulePkg/Dxe/Page: take MAX_ALLOC_ADDRESS into account Thread-Index: AQHUjh9Gu+m0EgACGkehi4+js0IXUaV3NxXA Date: Mon, 10 Dec 2018 02:04:03 +0000 Message-ID: References: <20181207112304.19765-1-ard.biesheuvel@linaro.org> <20181207112304.19765-4-ard.biesheuvel@linaro.org> In-Reply-To: <20181207112304.19765-4-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjczMmJjYTYtNzVkYS00MGU1LWEwZDItOWViMjFmOTFmMzA4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoid1d1bHFqOWRKU3lrMEc3YW1nQmlPWUFnYXVhb0ZQRFYzOTc1UndYcHBUN1p2V0E4Umd0SGdiNGFxcDNyR3dKOCJ9 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: [RFC PATCH 3/7] 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: Mon, 10 Dec 2018 02:04:07 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ard, I think MAX_ALLOC_ADDRESS will affect other archs besides ARM. Please do en= ough test for them (IA32/X64 for my concern). In addition, do you think it's safer to replace MAX_ADDRESS with MAX_ALLOC_= ADDRESS in MemoryAllocationLib like following situation? (MdeModulePkg\Library\DxeCoreMemoryAllocationLib\MemoryAllocationLib.c) VOID * InternalAllocateCopyPool ( IN EFI_MEMORY_TYPE PoolType, IN UINTN AllocationSize, IN CONST VOID *Buffer ) { VOID *Memory; ASSERT (Buffer !=3D NULL); ASSERT (AllocationSize <=3D (MAX_ADDRESS - (UINTN) Buffer + 1)); ... } Regards, Jian > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Friday, December 07, 2018 7:23 PM > 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: [RFC PATCH 3/7] 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