]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UefiBootManagerLib: log reserved mem allocation failure
authorLaszlo Ersek <lersek@redhat.com>
Wed, 8 Jan 2020 20:19:35 +0000 (21:19 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 14 Jan 2020 10:53:42 +0000 (10:53 +0000)
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
<https://github.com/tianocore/tianocore.github.io/wiki/HTTP-Boot#ram-disk-image-size>:

> 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=4501536768
> LoadFile="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=""

(Manually rewrapped here for keeping PatchCheck.py happy.)

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
Acked-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c

index 62c5b2dc94ab309449513a3344432d2a1cdf2820..540d169ec1a6a0170b81581e25c023549a8931b2 100644 (file)
@@ -1387,6 +1387,37 @@ BmExpandLoadFile (
   //\r
   FileBuffer = AllocateReservedPages (EFI_SIZE_TO_PAGES (BufferSize));\r
   if (FileBuffer == NULL) {\r
+    DEBUG_CODE (\r
+      EFI_DEVICE_PATH *LoadFilePath;\r
+      CHAR16          *LoadFileText;\r
+      CHAR16          *FileText;\r
+\r
+      LoadFilePath = DevicePathFromHandle (LoadFileHandle);\r
+      if (LoadFilePath == NULL) {\r
+        LoadFileText = NULL;\r
+      } else {\r
+        LoadFileText = ConvertDevicePathToText (LoadFilePath, FALSE, FALSE);\r
+      }\r
+      FileText = ConvertDevicePathToText (FilePath, FALSE, FALSE);\r
+\r
+      DEBUG ((\r
+        DEBUG_ERROR,\r
+        "%a:%a: failed to allocate reserved pages: "\r
+        "BufferSize=%Lu LoadFile=\"%s\" FilePath=\"%s\"\n",\r
+        gEfiCallerBaseName,\r
+        __FUNCTION__,\r
+        (UINT64)BufferSize,\r
+        LoadFileText,\r
+        FileText\r
+        ));\r
+\r
+      if (FileText != NULL) {\r
+        FreePool (FileText);\r
+      }\r
+      if (LoadFileText != NULL) {\r
+        FreePool (LoadFileText);\r
+      }\r
+      );\r
     return NULL;\r
   }\r
 \r