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

Gerd Hoffmann ced5d8
From c36a16dad384129382088ef783d8e672ead2752a Mon Sep 17 00:00:00 2001
59c3cd
From: Laszlo Ersek <lersek@redhat.com>
59c3cd
Date: Wed, 24 Jun 2020 11:31:36 +0200
Gerd Hoffmann ced5d8
Subject: [PATCH 18/21] OvmfPkg/QemuKernelLoaderFsDxe: suppress error on no
Gerd Hoffmann 5eb552
 "-kernel" in 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
---
Gerd Hoffmann ced5d8
 .../QemuKernelLoaderFsDxe.inf                  |  1 +
Gerd Hoffmann ced5d8
 .../QemuKernelLoaderFsDxe.c                    | 18 ++++++++++++++++++
Gerd Hoffmann ced5d8
 2 files changed, 19 insertions(+)
59c3cd
Gerd Hoffmann 5eb552
diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
Gerd Hoffmann 5eb552
index 7b35adb8e034..e0331c6e2cbc 100644
Gerd Hoffmann 5eb552
--- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
Gerd Hoffmann 5eb552
+++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
Gerd Hoffmann 5eb552
@@ -28,6 +28,7 @@ [LibraryClasses]
Gerd Hoffmann 5eb552
   BaseLib
Gerd Hoffmann 5eb552
   BaseMemoryLib
Gerd Hoffmann 5eb552
   DebugLib
Gerd Hoffmann 5eb552
+  DebugPrintErrorLevelLib
Gerd Hoffmann 5eb552
   DevicePathLib
Gerd Hoffmann 5eb552
   MemoryAllocationLib
Gerd Hoffmann 5eb552
   QemuFwCfgLib
59c3cd
diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
Gerd Hoffmann ced5d8
index d4f3cd92255f..f007f8a6c233 100644
59c3cd
--- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
59c3cd
+++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
Gerd Hoffmann 5eb552
@@ -19,6 +19,7 @@
59c3cd
 #include <Library/BaseMemoryLib.h>
Gerd Hoffmann 5eb552
 #include <Library/BlobVerifierLib.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>
Gerd Hoffmann ced5d8
@@ -1081,6 +1082,23 @@ QemuKernelLoaderFsDxeEntrypoint (
59c3cd
 
59c3cd
   if (KernelBlob->Data == NULL) {
59c3cd
     Status = EFI_NOT_FOUND;
Gerd Hoffmann ced5d8
+ #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
+    }
Gerd Hoffmann ced5d8
+
Gerd Hoffmann ced5d8
+ #endif
59c3cd
     goto FreeBlobs;
59c3cd
   }
59c3cd
 
59c3cd
-- 
Gerd Hoffmann ced5d8
2.35.1
59c3cd