Blame 0026-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch

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