From patchwork Sun Mar 19 17:19:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 95451 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp618309qgd; Sun, 19 Mar 2017 10:19:58 -0700 (PDT) X-Received: by 10.99.101.67 with SMTP id z64mr27544892pgb.78.1489943998382; Sun, 19 Mar 2017 10:19:58 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id 191si12336923pge.378.2017.03.19.10.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Mar 2017 10:19:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4FA4C80452; Sun, 19 Mar 2017 10:19:57 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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 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: [edk2] [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: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Signed-off-by: Ard Biesheuvel Reviewed-by: Liming Gao 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;