Blame SOURCES/edk2-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch

82dd91
From 9adcdf493ebbd11efb74e2905ab5f6c8996e096d Mon Sep 17 00:00:00 2001
82dd91
From: Laszlo Ersek <lersek@redhat.com>
82dd91
Date: Wed, 24 Jun 2020 11:31:36 +0200
82dd91
Subject: [PATCH 1/3] OvmfPkg/QemuKernelLoaderFsDxe: suppress error on no
82dd91
 "-kernel" in silent aa64 build (RH)
82dd91
MIME-Version: 1.0
82dd91
Content-Type: text/plain; charset=UTF-8
82dd91
Content-Transfer-Encoding: 8bit
82dd91
82dd91
RH-Author: Laszlo Ersek <lersek@redhat.com>
82dd91
Message-id: <20200615080105.11859-2-lersek@redhat.com>
82dd91
Patchwork-id: 97532
82dd91
O-Subject: [RHEL-8.3.0 edk2 PATCH 1/3] OvmfPkg/QemuKernelLoaderFsDxe: suppress error on no "-kernel" in silent aa64 build (RH)
82dd91
Bugzilla: 1844682
82dd91
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
82dd91
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
82dd91
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
82dd91
82dd91
If the "-kernel" QEMU option is not used, then QemuKernelLoaderFsDxe
82dd91
should return EFI_NOT_FOUND, so that the DXE Core can unload it. However,
82dd91
the associated error message, logged by the DXE Core to the serial
82dd91
console, is not desired in the silent edk2-aarch64 build, given that the
82dd91
absence of "-kernel" is nothing out of the ordinary. Therefore, return
82dd91
success and stay resident. The wasted guest RAM still gets freed after
82dd91
ExitBootServices().
82dd91
82dd91
(Inspired by RHEL-8.1.0 commit aaaedc1e2cfd.)
82dd91
82dd91
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
82dd91
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
82dd91
---
82dd91
 .../QemuKernelLoaderFsDxe.c                     | 17 +++++++++++++++++
82dd91
 .../QemuKernelLoaderFsDxe.inf                   |  1 +
82dd91
 2 files changed, 18 insertions(+)
82dd91
82dd91
diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
82dd91
index b09ff6a359..ec0244d61b 100644
82dd91
--- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
82dd91
+++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
82dd91
@@ -18,6 +18,7 @@
82dd91
 #include <Library/BaseLib.h>
82dd91
 #include <Library/BaseMemoryLib.h>
82dd91
 #include <Library/DebugLib.h>
82dd91
+#include <Library/DebugPrintErrorLevelLib.h>
82dd91
 #include <Library/DevicePathLib.h>
82dd91
 #include <Library/MemoryAllocationLib.h>
82dd91
 #include <Library/QemuFwCfgLib.h>
82dd91
@@ -1039,6 +1040,22 @@ QemuKernelLoaderFsDxeEntrypoint (
82dd91
 
82dd91
   if (KernelBlob->Data == NULL) {
82dd91
     Status = EFI_NOT_FOUND;
82dd91
+#if defined (MDE_CPU_AARCH64)
82dd91
+    //
82dd91
+    // RHBZ#1844682
82dd91
+    //
82dd91
+    // If the "-kernel" QEMU option is not being used, this platform DXE driver
82dd91
+    // should return EFI_NOT_FOUND, so that the DXE Core can unload it.
82dd91
+    // However, the associated error message, logged by the DXE Core to the
82dd91
+    // serial console, is not desired in the silent edk2-aarch64 build, given
82dd91
+    // that the absence of "-kernel" is nothing out of the ordinary. Therefore,
82dd91
+    // return success and stay resident. The wasted guest RAM still gets freed
82dd91
+    // after ExitBootServices().
82dd91
+    //
82dd91
+    if (GetDebugPrintErrorLevel () == DEBUG_ERROR) {
82dd91
+      Status = EFI_SUCCESS;
82dd91
+    }
82dd91
+#endif
82dd91
     goto FreeBlobs;
82dd91
   }
82dd91
 
82dd91
diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
82dd91
index 7b35adb8e0..e0331c6e2c 100644
82dd91
--- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
82dd91
+++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
82dd91
@@ -28,6 +28,7 @@
82dd91
   BaseLib
82dd91
   BaseMemoryLib
82dd91
   DebugLib
82dd91
+  DebugPrintErrorLevelLib
82dd91
   DevicePathLib
82dd91
   MemoryAllocationLib
82dd91
   QemuFwCfgLib
82dd91
-- 
82dd91
2.27.0
82dd91