This is a quick and dirty hack to ensure SBBR compliance in terms of memory allocation granularity. Note that it will lead to substantial relative memory waste (even if the absolute waste may be quite tolerable on multi GB machines) due to the fact that each call to AllocatePages () will return a 64 KB aligned buffer, i.e., every time the PeCoffLoader loads one of the multitude of individual modules UEFI consists of, it will round up the allocation.
The #defines in the patch suggest that it is possible to use 64 KB granularity for runtime regions and 4 KB for boottime regions, but unfortunately, this does not work due the way the pool allocator is wired up: the AllocatePages () invocations that back the pool allocator use the boottime granularity unconditionally, and fixing this properly is far from trivial.
Signed-off-by: Ard Biesheuvel ard.biesheuvel@linaro.org --- MdeModulePkg/Core/Dxe/Mem/Imem.h | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/MdeModulePkg/Core/Dxe/Mem/Imem.h b/MdeModulePkg/Core/Dxe/Mem/Imem.h index d09ff3c5220f..2ebd04874714 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Imem.h +++ b/MdeModulePkg/Core/Dxe/Mem/Imem.h @@ -22,6 +22,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2) #define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)
+#elif defined (MDE_CPU_AARCH64) +/// +/// ARM Server Base Boot Requirements (SBBR) mandate 64 KB alignment +/// for all memory regions on AArch64. +/// +#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (SIZE_64KB) +#define DEFAULT_PAGE_ALLOCATION (SIZE_64KB) + #else /// /// For genric EFI machines make the default allocations 4K aligned