From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 CDB6180450 for ; Sun, 19 Mar 2017 10:19:55 -0700 (PDT) Received: by mail-wr0-x230.google.com with SMTP id g10so79129683wrg.2 for ; Sun, 19 Mar 2017 10:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=LRl+9gjqiwPs5T+6KTD4I4EZDN2IUCoFfb+uwpcsOac=; b=OgDa4MiVVyJIyJ/2oXSNim/oFeZfa7nayhhfcCRJlAyYnNX2g4xXZFqNSjbezg0nIS c/h4L+4oQMZq6elo5+wvxSZ2sazlQspET6b3Ot7BG5nPet/x457nWQKU+ZHn14opClyT T8zGXdUhch/UVHlovj7j1PDtGJTdlh1IoQ5aY= 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; bh=LRl+9gjqiwPs5T+6KTD4I4EZDN2IUCoFfb+uwpcsOac=; b=KR8Pp5g69cfHhOqOuO3o41QeMC7Ue1OZ/HLW9TcoY40t5fczjonXbikDoEZvkEpxjR UAaUNhZq8mUUWdSaUZPT2es91ZfbdxW1CNpb583FB+IjDgKmH1BzZo8H8cqD3+/yFSbK GXyuYJzZDBX1Ifajt+rpKspgwM+5zH/yjyaHmuYvFXZLoxiJ1/roRwJgN+F91sCBz088 oC4oXGndIrB8Kko1mhrNHQSaev+6UtUQqss5DpTx6NnApaHQXdRgntHQ1HrEaclIJQTC 84lNYVpZpRIocVM7qq5ehsiGofFaTmRTzpxxqaClpMD9GEAXAMLIZJHP6RNEeFmyQIl0 CHfw== X-Gm-Message-State: AFeK/H3bUPppYwKpa8nsCVSOvznD9FgnJY6G5vDPnIZFIb/olKfoY0w43ICa68Ps/kYJZVWM X-Received: by 10.223.167.66 with SMTP id e2mr21141184wrd.48.1489943994231; Sun, 19 Mar 2017 10:19:54 -0700 (PDT) Received: from localhost.localdomain ([196.88.158.75]) by smtp.gmail.com with ESMTPSA id h3sm17757310wrb.6.2017.03.19.10.19.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Mar 2017 10:19:53 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, star.zeng@intel.com, feng.tian@intel.com Cc: Ard Biesheuvel Date: Sun, 19 Mar 2017 17:19:48 +0000 Message-Id: <1489943988-15378-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH] MdeModulePkg/BootGraphicsResourceTableDxe: don't allocate below 4 GB X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 17:19:56 -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 --- 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