public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org, star.zeng@intel.com, feng.tian@intel.com
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH] MdeModulePkg/BootGraphicsResourceTableDxe: don't allocate below 4 GB
Date: Sun, 19 Mar 2017 17:19:48 +0000	[thread overview]
Message-ID: <1489943988-15378-1-git-send-email-ard.biesheuvel@linaro.org> (raw)

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>
---
 MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c | 41 ++------------------
 1 file changed, 3 insertions(+), 38 deletions(-)

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



             reply	other threads:[~2017-03-19 17:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-19 17:19 Ard Biesheuvel [this message]
2017-03-20  1:09 ` [PATCH] MdeModulePkg/BootGraphicsResourceTableDxe: don't allocate below 4 GB Zeng, Star
2017-03-21  2:37   ` Gao, Liming
2017-03-21  7:11     ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1489943988-15378-1-git-send-email-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox