From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B9E9680407 for ; Sun, 19 Mar 2017 18:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489972201; x=1521508201; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ji0biYbYYILnrUiO9KGtO3cVstXzHW368K/+5Aa/8Q4=; b=DmkoY3p/F3eluTWoRxbiaDUdFoilQrnaVt0GoW7mBoqyXLGTnSSTpqhS +tcYamB1p+d65sIOMH9zOYm3OsL0DQ==; Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2017 18:10:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,191,1486454400"; d="scan'208";a="68877601" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga004.jf.intel.com with ESMTP; 19 Mar 2017 18:10:01 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 19 Mar 2017 18:10:00 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 19 Mar 2017 18:10:00 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.177]) with mapi id 14.03.0248.002; Mon, 20 Mar 2017 09:09:58 +0800 From: "Zeng, Star" To: Ard Biesheuvel , "edk2-devel@lists.01.org" , "Tian, Feng" CC: "Yao, Jiewen" , "Gao, Liming" , "Zeng, Star" Thread-Topic: [PATCH] MdeModulePkg/BootGraphicsResourceTableDxe: don't allocate below 4 GB Thread-Index: AQHSoNUJJ53Y1CED5kCGDyIEMm2TJaGc63og Date: Mon, 20 Mar 2017 01:09:57 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B835A6F@shsmsx102.ccr.corp.intel.com> References: <1489943988-15378-1-git-send-email-ard.biesheuvel@linaro.org> In-Reply-To: <1489943988-15378-1-git-send-email-ard.biesheuvel@linaro.org> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Mon, 20 Mar 2017 01:10:01 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I am ok with this patch. Jiewen and Liming, do you have any comments? Thanks, Star -----Original Message----- From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]=20 Sent: Monday, March 20, 2017 1:20 AM To: edk2-devel@lists.01.org; Zeng, Star ; Tian, Feng <= feng.tian@intel.com> Cc: Ard Biesheuvel Subject: [PATCH] MdeModulePkg/BootGraphicsResourceTableDxe: don't allocate = below 4 GB 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 AS= SERT() 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 ord= inary AllocatePages() call. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResou= rceTableDxe.c | 41 ++------------------ 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootG= raphicsResourceTableDxe.c b/MdeModulePkg/Universal/Acpi/BootGraphicsResourc= eTableDxe/BootGraphicsResourceTableDxe.c index 804ffa5a6bb6..6a7165a95489 100644 --- a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphics= ResourceTableDxe.c +++ b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraph +++ icsResourceTableDxe.c @@ -227,43 +227,6 @@ BgrtAcpiTableChecksum ( } =20 /** - 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 =3D EFI_SIZE_TO_PAGES (Size); - Address =3D 0xffffffff; - - Status =3D gBS->AllocatePages ( - AllocateMaxAddress, - EfiBootServicesData, - Pages, - &Address - ); - ASSERT_EFI_ERROR (Status); - - Buffer =3D (VOID *) (UINTN) Address; - ZeroMem (Buffer, Size); - - return Buffer; -} - -/** Install Boot Graphics Resource Table to ACPI table. =20 @return Status code. @@ -358,11 +321,13 @@ InstallBootGraphicsResourceTable ( // The image should be stored in EfiBootServicesData, allowing the sys= tem to reclaim the memory // BmpSize =3D (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (BMP= _IMAGE_HEADER); - ImageBuffer =3D BgrtAllocateBsDataMemoryBelow4G (BmpSize); + ImageBuffer =3D AllocatePages (EFI_SIZE_TO_PAGES (BmpSize)); if (ImageBuffer =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } =20 + ZeroMem (ImageBuffer, BmpSize); + mBmpImageHeaderTemplate.Size =3D (UINT32) BmpSize; mBmpImageHeaderTemplate.ImageSize =3D (UINT32) BmpSize - sizeof (BMP_I= MAGE_HEADER); mBmpImageHeaderTemplate.PixelWidth =3D (UINT32) mLogoWidth; -- 2.7.4