From nobody Sat Nov 2 12:27:40 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1488553908138884.1681769643221; Fri, 3 Mar 2017 07:11:48 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D0BF78221C; Fri, 3 Mar 2017 07:11:44 -0800 (PST) Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AF9118221C for ; Fri, 3 Mar 2017 07:11:43 -0800 (PST) Received: by mail-wm0-x234.google.com with SMTP id v186so17651443wmd.0 for ; Fri, 03 Mar 2017 07:11:43 -0800 (PST) Received: from localhost.localdomain ([105.147.1.203]) by smtp.gmail.com with ESMTPSA id w207sm3428523wmw.1.2017.03.03.07.11.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 07:11:41 -0800 (PST) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gT9IGtM1KAhH7ZBcgDogZGUmWAKOutcUW0r/NV6u8hg=; b=cUj237GQzPgV4n27MkwBqitIJYU3XvnUpJ/V2k22rzOxqkG5mOfqJzkbPpuAKmxdxU 61ZipZjRPCR+1RvksHL6h6K3Omtkx5kewkVuCLwtRO+oOA7bPhcPpXXGfmgLx6VvodiQ +POhTBrCtXschkEVjoDouq8lbMq/94lsmxVlA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gT9IGtM1KAhH7ZBcgDogZGUmWAKOutcUW0r/NV6u8hg=; b=kKtGx47UAjDe+Pu+g7Pa5yIl31noREbcEk/P9GFvRZMm/c+xpwBiJy9VQami+lECU5 gtCTGyRnQYaaiIx/kk2klpAAayy8hqpDEF9z21mmiuKBDc0LiCfJ0OeDlgq0RiEcaytJ ga1BnkPpc2IOitkrPWH0DhQOoTRX23hYPLH+roZm8fK/NAr/dBF3PSGrVvltxcIF4fdB T2dpgdOTBo72vXqYor1RU021haiUuqDQWa6qxBLLS3MWW6oTmzKYBEpVk7P16N93TJy5 qHtEFNFNvk6uz/nxSmIWRFKr/XlCFEvbfVvqBoss0BwiwPb7rzlvkZVE9Un+Y80L9799 JqlA== X-Gm-Message-State: AMke39me3oT8diBBDMlSNjsEo2lFOBcLbiT5jTUCsjMGglRrmi0q4Fyb3ShDoqmJlbyu6Jwv X-Received: by 10.28.111.151 with SMTP id c23mr3514679wmi.17.1488553901823; Fri, 03 Mar 2017 07:11:41 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, liming.gao@intel.com, michael.d.kinney@intel.com Date: Fri, 3 Mar 2017 15:11:31 +0000 Message-Id: <1488553894-3520-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488553894-3520-1-git-send-email-ard.biesheuvel@linaro.org> References: <1488553894-3520-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 1/4] MdePkg/ProcessorBind: add defines for page allocation granularity X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiewen.yao@intel.com, star.zeng@intel.com, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The UEFI spec differs between architectures in the minimum alignment and granularity of page allocations that are visible to the OS as EFI_MEMORY_RUNTIME regions. So define macros that carry these values to the respective ProcessorBind.h header files. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Liming Gao --- MdePkg/Include/AArch64/ProcessorBind.h | 6 ++++++ MdePkg/Include/Arm/ProcessorBind.h | 6 ++++++ MdePkg/Include/Ebc/ProcessorBind.h | 6 ++++++ MdePkg/Include/Ia32/ProcessorBind.h | 6 ++++++ MdePkg/Include/Ipf/ProcessorBind.h | 6 ++++++ MdePkg/Include/X64/ProcessorBind.h | 6 ++++++ 6 files changed, 36 insertions(+) diff --git a/MdePkg/Include/AArch64/ProcessorBind.h b/MdePkg/Include/AArch6= 4/ProcessorBind.h index f100d96be079..775e7498c5c9 100644 --- a/MdePkg/Include/AArch64/ProcessorBind.h +++ b/MdePkg/Include/AArch64/ProcessorBind.h @@ -104,6 +104,12 @@ typedef INT64 INTN; /// #define CPU_STACK_ALIGNMENT 16 =20 +/// +/// Page allocation granularity for AARCH64 +/// +#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000) +#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x10000) + // // Modifier to ensure that all protocol member functions and EFI intrinsics // use the correct C calling convention. All protocol member functions and diff --git a/MdePkg/Include/Arm/ProcessorBind.h b/MdePkg/Include/Arm/Proces= sorBind.h index a543687e57fd..dde1fd1152ba 100644 --- a/MdePkg/Include/Arm/ProcessorBind.h +++ b/MdePkg/Include/Arm/ProcessorBind.h @@ -110,6 +110,12 @@ typedef INT32 INTN; /// #define CPU_STACK_ALIGNMENT sizeof(UINT64) =20 +/// +/// Page allocation granularity for ARM +/// +#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000) +#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000) + // // Modifier to ensure that all protocol member functions and EFI intrinsics // use the correct C calling convention. All protocol member functions and diff --git a/MdePkg/Include/Ebc/ProcessorBind.h b/MdePkg/Include/Ebc/Proces= sorBind.h index 075f768c7691..da8b1a6d802a 100644 --- a/MdePkg/Include/Ebc/ProcessorBind.h +++ b/MdePkg/Include/Ebc/ProcessorBind.h @@ -115,6 +115,12 @@ typedef unsigned long UINTN; #define CPU_STACK_ALIGNMENT sizeof(UINTN) =20 /// +/// Page allocation granularity for EBC +/// +#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000) +#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000) + +/// /// Modifier to ensure that all protocol member functions and EFI intrinsi= cs /// use the correct C calling convention. All protocol member functions and /// EFI intrinsics are required to modify their member functions with EFIA= PI. diff --git a/MdePkg/Include/Ia32/ProcessorBind.h b/MdePkg/Include/Ia32/Proc= essorBind.h index 086b1ff7b1b3..8ba2348261a2 100644 --- a/MdePkg/Include/Ia32/ProcessorBind.h +++ b/MdePkg/Include/Ia32/ProcessorBind.h @@ -257,6 +257,12 @@ typedef INT32 INTN; /// #define CPU_STACK_ALIGNMENT sizeof(UINTN) =20 +/// +/// Page allocation granularity for IA-32. +/// +#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000) +#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000) + // // Modifier to ensure that all protocol member functions and EFI intrinsics // use the correct C calling convention. All protocol member functions and diff --git a/MdePkg/Include/Ipf/ProcessorBind.h b/MdePkg/Include/Ipf/Proces= sorBind.h index c19e47d8f3ca..51885ca61359 100644 --- a/MdePkg/Include/Ipf/ProcessorBind.h +++ b/MdePkg/Include/Ipf/ProcessorBind.h @@ -248,6 +248,12 @@ typedef INT64 INTN; /// #define CPU_STACK_ALIGNMENT 16 =20 +/// +/// Page allocation granularity for Itanium +/// +#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000) +#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x2000) + // // Modifier to ensure that all protocol member functions and EFI intrinsics // use the correct C calling convention. All protocol member functions and diff --git a/MdePkg/Include/X64/ProcessorBind.h b/MdePkg/Include/X64/Proces= sorBind.h index 23e6e55abff6..72cc85151cba 100644 --- a/MdePkg/Include/X64/ProcessorBind.h +++ b/MdePkg/Include/X64/ProcessorBind.h @@ -271,6 +271,12 @@ typedef INT64 INTN; /// #define CPU_STACK_ALIGNMENT 16 =20 +/// +/// Page allocation granularity for x64 +/// +#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000) +#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000) + // // Modifier to ensure that all protocol member functions and EFI intrinsics // use the correct C calling convention. All protocol member functions and --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sat Nov 2 12:27:40 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1488553913181178.95081576645634; Fri, 3 Mar 2017 07:11:53 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1087C82220; Fri, 3 Mar 2017 07:11:49 -0800 (PST) Received: from mail-wr0-x230.google.com (mail-wr0-x230.google.com [IPv6:2a00:1450:400c:c0c::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6183C8220E for ; Fri, 3 Mar 2017 07:11:47 -0800 (PST) Received: by mail-wr0-x230.google.com with SMTP id g10so75609857wrg.2 for ; Fri, 03 Mar 2017 07:11:47 -0800 (PST) Received: from localhost.localdomain ([105.147.1.203]) by smtp.gmail.com with ESMTPSA id w207sm3428523wmw.1.2017.03.03.07.11.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 07:11:43 -0800 (PST) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tH19YrX+91POuocs8o726vabJbJEcYmR2bFGv7zRD9M=; b=F2pguNFqdMhfX+d7K6e5mPkzj7rHuT/AEH5qeYZgOEkcAPTqdokZhnd3F6+afmcegL Qwnrn+KggH3GFkOAWnQFpXZIK/G/L/wwJ87bcPpNLdYqaMfCFdjM3FFZef6oKFUGYIV6 xwwLevnPWTvWyCU2gP4MIyWiuSfMkocYdjV+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tH19YrX+91POuocs8o726vabJbJEcYmR2bFGv7zRD9M=; b=QGJw8dgfncbk/Au4C4A1QsjUV0RXjMeW8xySakDzfJurlpyhFdVVvTh0aIFM8Y8M2h iyPtHBdfYCFD8TsieFf5jTShSOBNMatnl/+RXbZd1wLNNS3Im3nvV0yOXa5Uf8bYAks6 XBTHi4brVXH9GIW7SYuqMs7G1kJCfI24bAZJCHhBV/Za3/7tbfv3V/NMM/TB4Zmfdisx MzYCClgX0VE5i3LGH2Zn3SAQN1doEPmfjgtTrmdU9vGHtrAWEavAWDHkHlr/gmQF50jG psjVvMlflfMkNhJpmBVbFg2To7PKaCTUm7b2W417W7xA95ZRPNT8DlV2DIpJ3wq7gClL /k7g== X-Gm-Message-State: AMke39kbZ9d+lcIre5P1Whw93OcFdtn7I1YOeVslA9ntHXxDRZjRBa1ssC0CG45TMwydlvtK X-Received: by 10.223.130.214 with SMTP id 80mr3262061wrc.43.1488553905496; Fri, 03 Mar 2017 07:11:45 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, liming.gao@intel.com, michael.d.kinney@intel.com Date: Fri, 3 Mar 2017 15:11:32 +0000 Message-Id: <1488553894-3520-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488553894-3520-1-git-send-email-ard.biesheuvel@linaro.org> References: <1488553894-3520-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 2/4] MdeModulePkg/DxeCore: switch to MdePkg allocation granularity macros X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiewen.yao@intel.com, star.zeng@intel.com, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove the local definitions for the default and runtime page allocation granularity macros, and switch to the new MdePkg versions. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Liming Gao --- MdeModulePkg/Core/Dxe/DxeMain.h | 25 ------------------= -- MdeModulePkg/Core/Dxe/Mem/Page.c | 22 ++++++++--------- MdeModulePkg/Core/Dxe/Mem/Pool.c | 8 +++---- MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 2 +- MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 4 ++-- MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 8 +++---- 6 files changed, 22 insertions(+), 47 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMai= n.h index 5668c1f2d648..1a0babba713a 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -123,31 +123,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EIT= HER EXPRESS OR IMPLIED. /// #define DEPEX_STACK_SIZE_INCREMENT 0x1000 =20 -#if defined (MDE_CPU_IPF) -/// -/// For Itanium machines make the default allocations 8K aligned -/// -#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2) -#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2) - -#elif defined (MDE_CPU_AARCH64) -/// -/// 64-bit ARM systems allow the OS to execute with 64 KB page size, -/// so for improved interoperability with the firmware, align the -/// runtime regions to 64 KB as well -/// -#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (SIZE_64KB) -#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE) - -#else -/// -/// For generic EFI machines make the default allocations 4K aligned -/// -#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE) -#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE) - -#endif - typedef struct { EFI_GUID *ProtocolGuid; VOID **Protocol; diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c index 7e8fa94d7d4f..260a30a214c7 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -15,8 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER= EXPRESS OR IMPLIED. #include "DxeMain.h" #include "Imem.h" =20 -#define EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE) - // // Entry for tracking the memory regions for each memory type to coalesce = similar memory types // @@ -287,12 +285,14 @@ AllocateMemoryMapEntry ( // // The list is empty, to allocate one page to refuel the list // - FreeDescriptorEntries =3D CoreAllocatePoolPages (EfiBootServicesData, = EFI_SIZE_TO_PAGES(DEFAULT_PAGE_ALLOCATION), DEFAULT_PAGE_ALLOCATION); - if(FreeDescriptorEntries !=3D NULL) { + FreeDescriptorEntries =3D CoreAllocatePoolPages (EfiBootServicesData, + EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION_G= RANULARITY), + DEFAULT_PAGE_ALLOCATION_GRANULARITY); + if (FreeDescriptorEntries !=3D NULL) { // // Enque the free memmory map entries into the list // - for (Index =3D 0; Index< DEFAULT_PAGE_ALLOCATION / sizeof(MEMORY_MAP= ); Index++) { + for (Index =3D 0; Index < DEFAULT_PAGE_ALLOCATION_GRANULARITY / size= of(MEMORY_MAP); Index++) { FreeDescriptorEntries[Index].Signature =3D MEMORY_MAP_SIGNATURE; InsertTailList (&mFreeMemoryMapEntryList, &FreeDescriptorEntries[I= ndex].Link); } @@ -1222,14 +1222,14 @@ CoreInternalAllocatePages ( return EFI_INVALID_PARAMETER; } =20 - Alignment =3D EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT; + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; =20 if (MemoryType =3D=3D EfiACPIReclaimMemory || MemoryType =3D=3D EfiACPIMemoryNVS || MemoryType =3D=3D EfiRuntimeServicesCode || MemoryType =3D=3D EfiRuntimeServicesData) { =20 - Alignment =3D EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; + Alignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; } =20 if (Type =3D=3D AllocateAddress) { @@ -1398,7 +1398,7 @@ CoreInternalFreePages ( goto Done; } =20 - Alignment =3D EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT; + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; =20 ASSERT (Entry !=3D NULL); if (Entry->Type =3D=3D EfiACPIReclaimMemory || @@ -1406,7 +1406,7 @@ CoreInternalFreePages ( Entry->Type =3D=3D EfiRuntimeServicesCode || Entry->Type =3D=3D EfiRuntimeServicesData) { =20 - Alignment =3D EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; + Alignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; =20 } =20 @@ -1925,12 +1925,12 @@ CoreTerminateMemoryMap ( if (mMemoryTypeStatistics[Entry->Type].Runtime) { ASSERT (Entry->Type !=3D EfiACPIReclaimMemory); ASSERT (Entry->Type !=3D EfiACPIMemoryNVS); - if ((Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT = - 1)) !=3D 0) { + if ((Entry->Start & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != =3D 0) { DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME = memory entry is not on a proper alignment.\n")); Status =3D EFI_INVALID_PARAMETER; goto Done; } - if (((Entry->End + 1) & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNM= ENT - 1)) !=3D 0) { + if (((Entry->End + 1) & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1= )) !=3D 0) { DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME = memory entry is not on a proper alignment.\n")); Status =3D EFI_INVALID_PARAMETER; goto Done; diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/P= ool.c index ced64443c77d..5248ee2e6c02 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c @@ -352,9 +352,9 @@ CoreAllocatePoolI ( PoolType =3D=3D EfiRuntimeServicesCode || PoolType =3D=3D EfiRuntimeServicesData) { =20 - Granularity =3D EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; + Granularity =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; } else { - Granularity =3D DEFAULT_PAGE_ALLOCATION; + Granularity =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; } =20 // @@ -643,9 +643,9 @@ CoreFreePoolI ( Head->Type =3D=3D EfiRuntimeServicesCode || Head->Type =3D=3D EfiRuntimeServicesData) { =20 - Granularity =3D EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; + Granularity =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; } else { - Granularity =3D DEFAULT_PAGE_ALLOCATION; + Granularity =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; } =20 if (PoolType !=3D NULL) { diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModule= Pkg/Core/Dxe/Misc/MemoryAttributesTable.c index 408bcd3527ee..35156aea14dd 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c @@ -104,7 +104,7 @@ InstallMemoryAttributesTable ( =20 if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME= _MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) =3D=3D 0) { DEBUG ((EFI_D_VERBOSE, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DA= TA is not set, ")); - DEBUG ((EFI_D_VERBOSE, "because Runtime Driver Section Alignment is no= t %dK.\n", EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10)); + DEBUG ((EFI_D_VERBOSE, "because Runtime Driver Section Alignment is no= t %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10)); return ; } =20 diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/C= ore/Dxe/Misc/MemoryProtection.c index 45f360cccf75..070228bc7265 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c @@ -344,12 +344,12 @@ IsMemoryProtectionSectionAligned ( switch (MemoryType) { case EfiRuntimeServicesCode: case EfiACPIMemoryNVS: - PageAlignment =3D EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; + PageAlignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; break; case EfiRuntimeServicesData: case EfiACPIReclaimMemory: ASSERT (FALSE); - PageAlignment =3D EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; + PageAlignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; break; case EfiBootServicesCode: case EfiLoaderCode: diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Co= re/Dxe/Misc/PropertiesTable.c index 5ea20dbf8972..e7c4a9571250 100644 --- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c @@ -804,7 +804,7 @@ SetPropertiesTableSectionAlignment ( IN UINT32 SectionAlignment ) { - if (((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1= )) !=3D 0) && + if (((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) !=3D= 0) && ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIM= E_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) !=3D 0)) { DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n")= ); mPropertiesTable.MemoryProtectionAttribute &=3D ~((UINT64)EFI_PROPERTI= ES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA); @@ -1136,9 +1136,9 @@ InsertImageRecord ( } =20 SetPropertiesTableSectionAlignment (SectionAlignment); - if ((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)= ) !=3D 0) { + if ((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) !=3D = 0) { DEBUG ((EFI_D_WARN, "!!!!!!!! InsertImageRecord - Section Alignment(0= x%x) is not %dK !!!!!!!!\n", - SectionAlignment, EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10)); + SectionAlignment, RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10)); PdbPointer =3D PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress= ); if (PdbPointer !=3D NULL) { DEBUG ((EFI_D_WARN, "!!!!!!!! Image - %a !!!!!!!!\n", PdbPointer)); @@ -1338,7 +1338,7 @@ InstallPropertiesTable ( DEBUG ((EFI_D_INFO, "MemoryProtectionAttribute - 0x%016lx\n", mPropert= iesTable.MemoryProtectionAttribute)); if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTI= ME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) =3D=3D 0) { DEBUG ((EFI_D_ERROR, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DA= TA is not set, ")); - DEBUG ((EFI_D_ERROR, "because Runtime Driver Section Alignment is no= t %dK.\n", EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10)); + DEBUG ((EFI_D_ERROR, "because Runtime Driver Section Alignment is no= t %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10)); return ; } =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sat Nov 2 12:27:40 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1488553915016653.1913306078216; Fri, 3 Mar 2017 07:11:55 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4940382224; Fri, 3 Mar 2017 07:11:50 -0800 (PST) Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 028F98220E for ; Fri, 3 Mar 2017 07:11:49 -0800 (PST) Received: by mail-wm0-x231.google.com with SMTP id 196so8701689wmm.1 for ; Fri, 03 Mar 2017 07:11:48 -0800 (PST) Received: from localhost.localdomain ([105.147.1.203]) by smtp.gmail.com with ESMTPSA id w207sm3428523wmw.1.2017.03.03.07.11.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 07:11:46 -0800 (PST) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7Hy6Ebp8gmR2hNL8kwinoRYxdjjLKdFhnWOHu7BVGBw=; b=ddp8PAkAIe6BCy9qcIYaGRmBgKIdoI4p2vd7gtoIMuoDYu9S1EK25f7xqmeOkUulun 7ujmrB28LBrthEMhqhhA/SzVQLKhialTGKjNVdGPAXHVC/g5MEaeLfyzZcoqTv8lK0z9 11z+i+PbiYfLvH2SaXsLs9wzs4YmbovheMlIM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7Hy6Ebp8gmR2hNL8kwinoRYxdjjLKdFhnWOHu7BVGBw=; b=f0OgXp7qf/tVWcCQ+pkIyTAN5NjEF6RR09UQeZDU4+hIItsdSMcWMu0vGleANMt9pc Y/WkF+gDieyAJHBZGnUm8q7EklybwKsMXr2AC2DM2PiyOiL3BKRbpwmJbfIajOny69jw kB/EDLRhn8LiW+cbLnhCBCOsm5xvto8x/k0xC47MZ2Uc1L/By7/mvWls8qdM8heciRPQ Byo6T50+EWAIzpA1G6cj/n2sTuNE9Ihk1K2Rrb2lMkKxYgJ35Tp10nuh+uRm+pTpVVI0 SQdQSbhgmlfeLAUmAJTiTnH5s1ACO5b1gNYS+sZIXTyIaGdqO31Mb5AZLlmd2f7NNa77 iiUg== X-Gm-Message-State: AMke39nOmeaIPT0Ej0QPgq+aIv5sviTsGYzTxO8+WWosY7aRNVDdXPaw5AjOYBK3ykLiPOxD X-Received: by 10.28.55.68 with SMTP id e65mr3214323wma.62.1488553907563; Fri, 03 Mar 2017 07:11:47 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, liming.gao@intel.com, michael.d.kinney@intel.com Date: Fri, 3 Mar 2017 15:11:33 +0000 Message-Id: <1488553894-3520-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488553894-3520-1-git-send-email-ard.biesheuvel@linaro.org> References: <1488553894-3520-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 3/4] MdeModulePkg/PiSmmCore: switch to MdePkg allocation granularity macros X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiewen.yao@intel.com, star.zeng@intel.com, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove the local definitions for the default and runtime page allocation granularity macros, and switch to the new MdePkg versions. Note that this replaces a reference to the 'default' version with the more correct 'runtime' version, but this matters little in practice. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Liming Gao --- MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c | 6 +++--- MdeModulePkg/Core/PiSmmCore/Page.c | 4 ++-- MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 6 ------ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c b/MdeModul= ePkg/Core/PiSmmCore/MemoryAttributesTable.c index 6cfd35945ab1..e3c505ef18ab 100644 --- a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c +++ b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c @@ -795,7 +795,7 @@ SetMemoryAttributesTableSectionAlignment ( IN UINT32 SectionAlignment ) { - if (((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1= )) !=3D 0) && + if (((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) !=3D= 0) && ((mMemoryProtectionAttribute & EFI_MEMORY_ATTRIBUTES_RUNTIME_MEMORY_= PROTECTION_NON_EXECUTABLE_PE_DATA) !=3D 0)) { DEBUG ((DEBUG_VERBOSE, "SMM SetMemoryAttributesTableSectionAlignment -= Clear\n")); mMemoryProtectionAttribute &=3D ~((UINT64)EFI_MEMORY_ATTRIBUTES_RUNTIM= E_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA); @@ -1125,9 +1125,9 @@ SmmInsertImageRecord ( } =20 SetMemoryAttributesTableSectionAlignment (SectionAlignment); - if ((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)= ) !=3D 0) { + if ((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) !=3D = 0) { DEBUG ((DEBUG_WARN, "SMM !!!!!!!! InsertImageRecord - Section Alignme= nt(0x%x) is not %dK !!!!!!!!\n", - SectionAlignment, EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10)); + SectionAlignment, RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10)); PdbPointer =3D PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress= ); if (PdbPointer !=3D NULL) { DEBUG ((DEBUG_WARN, "SMM !!!!!!!! Image - %a !!!!!!!!\n", PdbPoint= er)); diff --git a/MdeModulePkg/Core/PiSmmCore/Page.c b/MdeModulePkg/Core/PiSmmCo= re/Page.c index 1bc8fd82c867..4154c2e6a1ec 100644 --- a/MdeModulePkg/Core/PiSmmCore/Page.c +++ b/MdeModulePkg/Core/PiSmmCore/Page.c @@ -110,7 +110,7 @@ AllocateMemoryMapEntry ( Status =3D SmmInternalAllocatePagesEx ( AllocateAnyPages, EfiRuntimeServicesData, - EFI_SIZE_TO_PAGES(DEFAULT_PAGE_ALLOCATION), + EFI_SIZE_TO_PAGES (RUNTIME_PAGE_ALLOCATION_GRANULARITY), &Mem, TRUE ); @@ -121,7 +121,7 @@ AllocateMemoryMapEntry ( // // Enque the free memmory map entries into the list // - for (Index =3D 0; Index< DEFAULT_PAGE_ALLOCATION / sizeof(MEMORY_MAP= ); Index++) { + for (Index =3D 0; Index< RUNTIME_PAGE_ALLOCATION_GRANULARITY / sizeo= f(MEMORY_MAP); Index++) { FreeDescriptorEntries[Index].Signature =3D MEMORY_MAP_SIGNATURE; InsertTailList (&mFreeMemoryMapEntryList, &FreeDescriptorEntries[I= ndex].Link); } diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/Pi= SmmCore/PiSmmCore.h index bdef026e6c68..45b9d9758be8 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h @@ -1151,12 +1151,6 @@ SmiHandlerProfileUnregisterHandler ( IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler ); =20 -/// -/// For generic EFI machines make the default allocations 4K aligned -/// -#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE) -#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE) - extern UINTN mFullSmramRangeCount; extern EFI_SMRAM_DESCRIPTOR *mFullSmramRanges; =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sat Nov 2 12:27:40 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1488553917111232.73112789806112; Fri, 3 Mar 2017 07:11:57 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7DE9C8221B; Fri, 3 Mar 2017 07:11:53 -0800 (PST) Received: from mail-wr0-x236.google.com (mail-wr0-x236.google.com [IPv6:2a00:1450:400c:c0c::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 38A9F8220E for ; Fri, 3 Mar 2017 07:11:51 -0800 (PST) Received: by mail-wr0-x236.google.com with SMTP id g10so75611114wrg.2 for ; Fri, 03 Mar 2017 07:11:51 -0800 (PST) Received: from localhost.localdomain ([105.147.1.203]) by smtp.gmail.com with ESMTPSA id w207sm3428523wmw.1.2017.03.03.07.11.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 07:11:48 -0800 (PST) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2jrsvirfXwl422T3/KmOkrEwBQTWZoEHp+d6Ey9/ZUc=; b=jC26o4OXO0K/+mb4vBrTVWsZ1B0lKPLfTf41tnDh43dlg6EcxA1t6njYKCvoIBmS+7 uhX1wmUyRg+jYLGSvgGeug1d1hLVasZHYjyrth/spWVesPcIsVXDqGDfDd62ItH3VCM0 Z3+1hKb/sVxazvTABqzdo7bxJ65TgxIWeaWLg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2jrsvirfXwl422T3/KmOkrEwBQTWZoEHp+d6Ey9/ZUc=; b=jnOfZFRJjwvntx+Bwxse+restUhZEhap9Ai7hn7Q2dQg5ok+2EwhfB2SO9/FbTRtHr +Z+3bHUUdagPx/+UYazoGdhN7Ke6JL30af+kH1CEKuaimlSeou/dQknhBQoyy3QVDB1u 0wIuEdHjoBtWC/8UQjTNzyDZ1CKPmXQlNuQhjbh7QB89hKLrHIV/DG5++bQLYd9izCWS cJuFGr7Hs1GcwcR6dfwk+yRxy9RjBz1IdjgzGXnI3C8pKD31v3WQbStGG44SeAUHbWQB R5gun4Pqa9eWJKng1BAxbf16eT01MkvGiXYeI1ua8ar92/glhbRXvuQHNFU0Ev86Ydhg tQeQ== X-Gm-Message-State: AMke39lhF+BIJ1Mkz/abtUUV5ezDuAtiIK/zU3IWgRerNq6kirM8WuW3PSaGM3vY4pzfrKAn X-Received: by 10.223.169.164 with SMTP id b33mr3322522wrd.132.1488553909559; Fri, 03 Mar 2017 07:11:49 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, liming.gao@intel.com, michael.d.kinney@intel.com Date: Fri, 3 Mar 2017 15:11:34 +0000 Message-Id: <1488553894-3520-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488553894-3520-1-git-send-email-ard.biesheuvel@linaro.org> References: <1488553894-3520-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 4/4] MdeModulePkg/PeiCore: honour minimal runtime allocation granularity X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiewen.yao@intel.com, star.zeng@intel.com, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Architectures such as AArch64 may run the OS with 16 KB or 64 KB sized pages, and for this reason, the UEFI spec mandates a minimal allocation granularity of 64 KB for regions that may require different memory attributes at OS runtime. So make PeiCore's implementation of AllocatePages () take this into account as well. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Star Zeng Reviewed-by: Liming Gao --- MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 39 +++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/C= ore/Pei/Memory/MemoryServices.c index 4efe14313ca5..719372e06128 100644 --- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c +++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c @@ -140,6 +140,8 @@ PeiAllocatePages ( EFI_PHYSICAL_ADDRESS *FreeMemoryTop; EFI_PHYSICAL_ADDRESS *FreeMemoryBottom; UINTN RemainingPages; + UINTN Granularity; + UINTN Padding; =20 if ((MemoryType !=3D EfiLoaderCode) && (MemoryType !=3D EfiLoaderData) && @@ -153,6 +155,20 @@ PeiAllocatePages ( return EFI_INVALID_PARAMETER; } =20 + Granularity =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; + + if (RUNTIME_PAGE_ALLOCATION_GRANULARITY > DEFAULT_PAGE_ALLOCATION_GRANU= LARITY && + (MemoryType =3D=3D EfiACPIReclaimMemory || + MemoryType =3D=3D EfiACPIMemoryNVS || + MemoryType =3D=3D EfiRuntimeServicesCode || + MemoryType =3D=3D EfiRuntimeServicesData)) { + + Granularity =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; + + DEBUG ((DEBUG_INFO, "AllocatePages: aligning allocation to %d KB\n", + Granularity / SIZE_1KB)); + } + PrivateData =3D PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); Hob.Raw =3D PrivateData->HobList.Raw; =20 @@ -176,9 +192,27 @@ PeiAllocatePages ( } =20 // - // Check to see if on 4k boundary, If not aligned, make the allocation a= ligned. + // Check to see if on correct boundary for the memory type. + // If not aligned, make the allocation aligned. // - *(FreeMemoryTop) -=3D *(FreeMemoryTop) & 0xFFF; + Padding =3D *(FreeMemoryTop) & (Granularity - 1); + if ((UINTN) (*FreeMemoryTop - *FreeMemoryBottom) < Padding) { + DEBUG ((DEBUG_ERROR, "AllocatePages failed: Out of space after padding= .\n")); + return EFI_OUT_OF_RESOURCES; + } + + *(FreeMemoryTop) -=3D Padding; + if (Padding >=3D EFI_PAGE_SIZE) { + // + // Create a memory allocation HOB to cover + // the pages that we will lose to rounding + // + BuildMemoryAllocationHob ( + *(FreeMemoryTop), + Padding & ~(UINTN)EFI_PAGE_MASK, + EfiConventionalMemory + ); + } =20 // // Verify that there is sufficient memory to satisfy the allocation. @@ -192,6 +226,7 @@ PeiAllocatePages ( // // The number of remaining pages needs to be greater than or equal to th= at of the request pages. // + Pages =3D ALIGN_VALUE (Pages, EFI_SIZE_TO_PAGES (Granularity)); if (RemainingPages < Pages) { DEBUG ((EFI_D_ERROR, "AllocatePages failed: No 0x%lx Pages is availabl= e.\n", (UINT64) Pages)); DEBUG ((EFI_D_ERROR, "There is only left 0x%lx pages memory resource t= o be allocated.\n", (UINT64) RemainingPages)); --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel