]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/BootGraphicsResourceTableDxe: don't allocate below 4 GB
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sun, 19 Mar 2017 17:19:48 +0000 (17:19 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 21 Mar 2017 07:10:39 +0000 (07:10 +0000)
The BGRT table has an 8 byte field for the memory address of the image
data, and yet the driver explicitly allocates below 4 GB. This results
in an ASSERT() on systems that do not have any memory below 4 GB to begin
with.

Since neither the PI, the UEFI or the ACPI spec contain any mention of
why this data should reside below 4 GB, replace the allocation call
with an ordinary AllocatePages() call.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c

index 804ffa5a6bb68c97993b24dc7acdba3107093adf..6a7165a954897068e4c4b0da3018445eec953755 100644 (file)
@@ -226,43 +226,6 @@ BgrtAcpiTableChecksum (
   Buffer[ChecksumOffset] = CalculateCheckSum8 (Buffer, Size);\r
 }\r
 \r
-/**\r
-  Allocate EfiBootServicesData below 4G memory address.\r
-\r
-  This function allocates EfiBootServicesData below 4G memory address.\r
-\r
-  @param[in]  Size   Size of memory to allocate.\r
-\r
-  @return Allocated address for output.\r
-\r
-**/\r
-VOID *\r
-BgrtAllocateBsDataMemoryBelow4G (\r
-  IN UINTN       Size\r
-  )\r
-{\r
-  UINTN                 Pages;\r
-  EFI_PHYSICAL_ADDRESS  Address;\r
-  EFI_STATUS            Status;\r
-  VOID                  *Buffer;\r
-\r
-  Pages   = EFI_SIZE_TO_PAGES (Size);\r
-  Address = 0xffffffff;\r
-\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiBootServicesData,\r
-                  Pages,\r
-                  &Address\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Buffer = (VOID *) (UINTN) Address;\r
-  ZeroMem (Buffer, Size);\r
-\r
-  return Buffer;\r
-}\r
-\r
 /**\r
   Install Boot Graphics Resource Table to ACPI table.\r
 \r
@@ -358,11 +321,13 @@ InstallBootGraphicsResourceTable (
     // The image should be stored in EfiBootServicesData, allowing the system to reclaim the memory\r
     //\r
     BmpSize = (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (BMP_IMAGE_HEADER);\r
-    ImageBuffer = BgrtAllocateBsDataMemoryBelow4G (BmpSize);\r
+    ImageBuffer = AllocatePages (EFI_SIZE_TO_PAGES (BmpSize));\r
     if (ImageBuffer == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
 \r
+    ZeroMem (ImageBuffer, BmpSize);\r
+\r
     mBmpImageHeaderTemplate.Size = (UINT32) BmpSize;\r
     mBmpImageHeaderTemplate.ImageSize = (UINT32) BmpSize - sizeof (BMP_IMAGE_HEADER);\r
     mBmpImageHeaderTemplate.PixelWidth = (UINT32) mLogoWidth;\r