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

75d8e7
From 9e7da28d166fb4b5b434b444c655d522c9f32b1a Mon Sep 17 00:00:00 2001
c4e3b2
From: Laszlo Ersek <lersek@redhat.com>
c4e3b2
Date: Wed, 24 Jun 2020 11:31:36 +0200
c4e3b2
Subject: OvmfPkg/QemuKernelLoaderFsDxe: suppress error on no "-kernel" in
c4e3b2
 silent aa64 build (RH)
c4e3b2
c4e3b2
Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] ->
c4e3b2
RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase:
c4e3b2
c4e3b2
- Remove obsolete commit message tags related to downstream patch
c4e3b2
  management: Message-id, Patchwork-id, O-Subject, Acked-by, From,
c4e3b2
  RH-Acked-by, RH-Author (RHBZ#1846481).
c4e3b2
c4e3b2
Bugzilla: 1844682
c4e3b2
c4e3b2
If the "-kernel" QEMU option is not used, then QemuKernelLoaderFsDxe
c4e3b2
should return EFI_NOT_FOUND, so that the DXE Core can unload it. However,
c4e3b2
the associated error message, logged by the DXE Core to the serial
c4e3b2
console, is not desired in the silent edk2-aarch64 build, given that the
c4e3b2
absence of "-kernel" is nothing out of the ordinary. Therefore, return
c4e3b2
success and stay resident. The wasted guest RAM still gets freed after
c4e3b2
ExitBootServices().
c4e3b2
c4e3b2
(Inspired by RHEL-8.1.0 commit aaaedc1e2cfd.)
c4e3b2
c4e3b2
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
c4e3b2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
c4e3b2
(cherry picked from commit 9adcdf493ebbd11efb74e2905ab5f6c8996e096d)
c4e3b2
---
c4e3b2
 .../QemuKernelLoaderFsDxe.c                     | 17 +++++++++++++++++
c4e3b2
 .../QemuKernelLoaderFsDxe.inf                   |  1 +
c4e3b2
 2 files changed, 18 insertions(+)
c4e3b2
c4e3b2
diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
75d8e7
index 6832d563bc..08ed67f5ff 100644
c4e3b2
--- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
c4e3b2
+++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
75d8e7
@@ -19,6 +19,7 @@
c4e3b2
 #include <Library/BaseMemoryLib.h>
75d8e7
 #include <Library/BlobVerifierLib.h>
c4e3b2
 #include <Library/DebugLib.h>
c4e3b2
+#include <Library/DebugPrintErrorLevelLib.h>
c4e3b2
 #include <Library/DevicePathLib.h>
c4e3b2
 #include <Library/MemoryAllocationLib.h>
c4e3b2
 #include <Library/QemuFwCfgLib.h>
75d8e7
@@ -1054,6 +1055,22 @@ QemuKernelLoaderFsDxeEntrypoint (
c4e3b2
 
c4e3b2
   if (KernelBlob->Data == NULL) {
c4e3b2
     Status = EFI_NOT_FOUND;
c4e3b2
+#if defined (MDE_CPU_AARCH64)
c4e3b2
+    //
c4e3b2
+    // RHBZ#1844682
c4e3b2
+    //
c4e3b2
+    // If the "-kernel" QEMU option is not being used, this platform DXE driver
c4e3b2
+    // should return EFI_NOT_FOUND, so that the DXE Core can unload it.
c4e3b2
+    // However, the associated error message, logged by the DXE Core to the
c4e3b2
+    // serial console, is not desired in the silent edk2-aarch64 build, given
c4e3b2
+    // that the absence of "-kernel" is nothing out of the ordinary. Therefore,
c4e3b2
+    // return success and stay resident. The wasted guest RAM still gets freed
c4e3b2
+    // after ExitBootServices().
c4e3b2
+    //
c4e3b2
+    if (GetDebugPrintErrorLevel () == DEBUG_ERROR) {
c4e3b2
+      Status = EFI_SUCCESS;
c4e3b2
+    }
c4e3b2
+#endif
c4e3b2
     goto FreeBlobs;
c4e3b2
   }
c4e3b2
 
c4e3b2
diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
c4e3b2
index 7b35adb8e0..e0331c6e2c 100644
c4e3b2
--- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
c4e3b2
+++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
c4e3b2
@@ -28,6 +28,7 @@
c4e3b2
   BaseLib
c4e3b2
   BaseMemoryLib
c4e3b2
   DebugLib
c4e3b2
+  DebugPrintErrorLevelLib
c4e3b2
   DevicePathLib
c4e3b2
   MemoryAllocationLib
c4e3b2
   QemuFwCfgLib
c4e3b2
-- 
c4e3b2
2.27.0
c4e3b2