From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web11.1647.1578527003521986060 for ; Wed, 08 Jan 2020 15:43:23 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZzIfB6Da; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578527002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XVslWtcn5cYB6z8IXpnoN2/rJE2phyUF8CzD45uDirI=; b=ZzIfB6DaHVNhF+aFBoJ3D8iMzhAKyhT3X0NXBFlVbCflp4Ldhq3EQczRBandZSJwBFySRB RctuUxbCdM79seT5A3HJHwSMiPkBASdI3fKTSUcxr5LCkkdi6LibAHPWrBqozUgIvhGI44 /m0A3ZvzttHzG9ITi+nYxtaY8H2ovGg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-391-SdRPq9GxNfKZIl8CCIq7sw-1; Wed, 08 Jan 2020 18:43:20 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 540A4DB20; Wed, 8 Jan 2020 23:43:19 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-37.ams2.redhat.com [10.36.117.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B10F1001B28; Wed, 8 Jan 2020 23:43:17 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Hao A Wu , Jian J Wang , Ray Ni , Zhichao Gao Subject: [PATCH 1/2] MdeModulePkg/UefiBootManagerLib: log reserved mem allocation failure Date: Thu, 9 Jan 2020 00:43:12 +0100 Message-Id: <20200108234313.28510-2-lersek@redhat.com> In-Reply-To: <20200108234313.28510-1-lersek@redhat.com> References: <20200108234313.28510-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: SdRPq9GxNfKZIl8CCIq7sw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable The LoadFile protocol can report such a large buffer size that we cannot allocate enough reserved pages for. This particularly affects HTTP(S) Boot, if the remote file is very large (for example, an ISO image). While the TianoCore wiki mentions this at : > The maximum RAM disk image size depends on how much continuous reserved > memory block the platform could provide. it's hard to remember; so log a DEBUG_ERROR message when the allocation fails. This patch produces error messages such as: > UiApp:BmExpandLoadFile: failed to allocate reserved pages: > BufferSize=3D4501536768 > LoadFile=3D"PciRoot(0x0)/Pci(0x3,0x0)/MAC(5254001B103E,0x1)/ > IPv4(0.0.0.0,TCP,DHCP,192.168.124.106,192.168.124.1,255.255.255.0)/ > Dns(192.168.124.1)/ > Uri(https://ipv4-server/RHEL-7.7-20190723.1-Server-x86_64-dvd1.iso)" > FilePath=3D"" (Manually rewrapped here for keeping PatchCheck.py happy.) Cc: Hao A Wu Cc: Jian J Wang Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Laszlo Ersek --- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePk= g/Library/UefiBootManagerLib/BmBoot.c index 62c5b2dc94ab..540d169ec1a6 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -1387,6 +1387,37 @@ BmExpandLoadFile ( // FileBuffer =3D AllocateReservedPages (EFI_SIZE_TO_PAGES (BufferSize)); if (FileBuffer =3D=3D NULL) { + DEBUG_CODE ( + EFI_DEVICE_PATH *LoadFilePath; + CHAR16 *LoadFileText; + CHAR16 *FileText; + + LoadFilePath =3D DevicePathFromHandle (LoadFileHandle); + if (LoadFilePath =3D=3D NULL) { + LoadFileText =3D NULL; + } else { + LoadFileText =3D ConvertDevicePathToText (LoadFilePath, FALSE, FAL= SE); + } + FileText =3D ConvertDevicePathToText (FilePath, FALSE, FALSE); + + DEBUG (( + DEBUG_ERROR, + "%a:%a: failed to allocate reserved pages: " + "BufferSize=3D%Lu LoadFile=3D\"%s\" FilePath=3D\"%s\"\n", + gEfiCallerBaseName, + __FUNCTION__, + (UINT64)BufferSize, + LoadFileText, + FileText + )); + + if (FileText !=3D NULL) { + FreePool (FileText); + } + if (LoadFileText !=3D NULL) { + FreePool (LoadFileText); + } + ); return NULL; } =20 --=20 2.19.1.3.g30247aa5d201