Blame SOURCES/edk2-MdeModulePkg-UefiBootManagerLib-log-reserved-mem-all.patch

6009e6
From e57f49101a66663a4f5425995e9ea97ae0858e1b Mon Sep 17 00:00:00 2001
6009e6
From: Laszlo Ersek <lersek@redhat.com>
6009e6
Date: Tue, 14 Jan 2020 12:39:05 +0100
6009e6
Subject: [PATCH 1/2] MdeModulePkg/UefiBootManagerLib: log reserved mem
6009e6
 allocation failure
6009e6
MIME-Version: 1.0
6009e6
Content-Type: text/plain; charset=UTF-8
6009e6
Content-Transfer-Encoding: 8bit
6009e6
6009e6
RH-Author: Laszlo Ersek <lersek@redhat.com>
6009e6
Message-id: <20200114123906.8547-2-lersek@redhat.com>
6009e6
Patchwork-id: 93339
6009e6
O-Subject: [RHEL-8.2.0 edk2 PATCH 1/2] MdeModulePkg/UefiBootManagerLib: log reserved mem allocation failure
6009e6
Bugzilla: 1789797
6009e6
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6009e6
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6009e6
6009e6
The LoadFile protocol can report such a large buffer size that we cannot
6009e6
allocate enough reserved pages for. This particularly affects HTTP(S)
6009e6
Boot, if the remote file is very large (for example, an ISO image).
6009e6
6009e6
While the TianoCore wiki mentions this at
6009e6
<https://github.com/tianocore/tianocore.github.io/wiki/HTTP-Boot#ram-disk-image-size>:
6009e6
6009e6
> The maximum RAM disk image size depends on how much continuous reserved
6009e6
> memory block the platform could provide.
6009e6
6009e6
it's hard to remember; so log a DEBUG_ERROR message when the allocation
6009e6
fails.
6009e6
6009e6
This patch produces error messages such as:
6009e6
6009e6
> UiApp:BmExpandLoadFile: failed to allocate reserved pages:
6009e6
> BufferSize=4501536768
6009e6
> LoadFile="PciRoot(0x0)/Pci(0x3,0x0)/MAC(5254001B103E,0x1)/
6009e6
>      IPv4(0.0.0.0,TCP,DHCP,192.168.124.106,192.168.124.1,255.255.255.0)/
6009e6
>      Dns(192.168.124.1)/
6009e6
>      Uri(https://ipv4-server/RHEL-7.7-20190723.1-Server-x86_64-dvd1.iso)"
6009e6
> FilePath=""
6009e6
6009e6
(Manually rewrapped here for keeping PatchCheck.py happy.)
6009e6
6009e6
Cc: Hao A Wu <hao.a.wu@intel.com>
6009e6
Cc: Jian J Wang <jian.j.wang@intel.com>
6009e6
Cc: Ray Ni <ray.ni@intel.com>
6009e6
Cc: Zhichao Gao <zhichao.gao@intel.com>
6009e6
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
6009e6
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
6009e6
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
6009e6
Acked-by: Hao A Wu <hao.a.wu@intel.com>
6009e6
(cherry picked from commit a56af23f066e2816c67b7c6e64de7ddefcd70780)
6009e6
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
6009e6
---
6009e6
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 31 ++++++++++++++++++++++++
6009e6
 1 file changed, 31 insertions(+)
6009e6
6009e6
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
6009e6
index 952033f..ded9ae9 100644
6009e6
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
6009e6
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
6009e6
@@ -1386,6 +1386,37 @@ BmExpandLoadFile (
6009e6
   //
6009e6
   FileBuffer = AllocateReservedPages (EFI_SIZE_TO_PAGES (BufferSize));
6009e6
   if (FileBuffer == NULL) {
6009e6
+    DEBUG_CODE (
6009e6
+      EFI_DEVICE_PATH *LoadFilePath;
6009e6
+      CHAR16          *LoadFileText;
6009e6
+      CHAR16          *FileText;
6009e6
+
6009e6
+      LoadFilePath = DevicePathFromHandle (LoadFileHandle);
6009e6
+      if (LoadFilePath == NULL) {
6009e6
+        LoadFileText = NULL;
6009e6
+      } else {
6009e6
+        LoadFileText = ConvertDevicePathToText (LoadFilePath, FALSE, FALSE);
6009e6
+      }
6009e6
+      FileText = ConvertDevicePathToText (FilePath, FALSE, FALSE);
6009e6
+
6009e6
+      DEBUG ((
6009e6
+        DEBUG_ERROR,
6009e6
+        "%a:%a: failed to allocate reserved pages: "
6009e6
+        "BufferSize=%Lu LoadFile=\"%s\" FilePath=\"%s\"\n",
6009e6
+        gEfiCallerBaseName,
6009e6
+        __FUNCTION__,
6009e6
+        (UINT64)BufferSize,
6009e6
+        LoadFileText,
6009e6
+        FileText
6009e6
+        ));
6009e6
+
6009e6
+      if (FileText != NULL) {
6009e6
+        FreePool (FileText);
6009e6
+      }
6009e6
+      if (LoadFileText != NULL) {
6009e6
+        FreePool (LoadFileText);
6009e6
+      }
6009e6
+      );
6009e6
     return NULL;
6009e6
   }
6009e6
 
6009e6
-- 
6009e6
1.8.3.1
6009e6