Blob Blame History Raw
From aaaedc1e2cfd55ef003fb1b5a37c73a196b26dc7 Mon Sep 17 00:00:00 2001
From: Philippe Mathieu-Daude <philmd@redhat.com>
Date: Thu, 1 Aug 2019 20:43:48 +0200
Subject: [PATCH 2/3] OvmfPkg: QemuRamfbDxe: Do not report DXE failure on
 Aarch64 silent builds (RH only)

Message-id: <20190801184349.28512-3-philmd@redhat.com>
Patchwork-id: 89861
O-Subject:  [RHEL-8.1.0 edk2 PATCH v4 2/3] OvmfPkg: QemuRamfbDxe: Do not report
	DXE failure on Aarch64 silent builds (RH only)
Bugzilla: 1714446
Acked-by: Andrew Jones <drjones@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>

To suppress an error message on the silent build when ramfb is
not configured, change QemuRamfbDxe to return EFI_SUCCESS even
when it fails.
Some memory is wasted (driver stays resident without
any good use), but it is mostly harmless, as the memory
is released by the OS after ExitBootServices().

Suggested-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
 OvmfPkg/QemuRamfbDxe/QemuRamfb.c      | 14 ++++++++++++++
 OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf |  1 +
 2 files changed, 15 insertions(+)

diff --git a/OvmfPkg/QemuRamfbDxe/QemuRamfb.c b/OvmfPkg/QemuRamfbDxe/QemuRamfb.c
index b49f2ca..c27e55f 100644
--- a/OvmfPkg/QemuRamfbDxe/QemuRamfb.c
+++ b/OvmfPkg/QemuRamfbDxe/QemuRamfb.c
@@ -20,6 +20,7 @@
 #include <Library/BaseLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
+#include <Library/DebugPrintErrorLevelLib.h>
 #include <Library/DevicePathLib.h>
 #include <Library/FrameBufferBltLib.h>
 #include <Library/MemoryAllocationLib.h>
@@ -249,6 +250,19 @@ InitializeQemuRamfb (
 
   Status = QemuFwCfgFindFile ("etc/ramfb", &mRamfbFwCfgItem, &FwCfgSize);
   if (EFI_ERROR (Status)) {
+#if defined (MDE_CPU_AARCH64)
+    //
+    // RHBZ#1714446
+    // If no ramfb device was configured, this platform DXE driver should
+    // returns EFI_NOT_FOUND, so the DXE Core can unload it. However, even
+    // using a silent build, an error message is issued to the guest console.
+    // Since this confuse users, return success and stay resident. The wasted
+    // guest RAM still gets freed later after ExitBootServices().
+    //
+    if (GetDebugPrintErrorLevel () == DEBUG_ERROR) {
+      return EFI_SUCCESS;
+    }
+#endif
     return EFI_NOT_FOUND;
   }
   if (FwCfgSize != sizeof (RAMFB_CONFIG)) {
diff --git a/OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf b/OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf
index 013edef..f9e24cb 100644
--- a/OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf
+++ b/OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf
@@ -36,6 +36,7 @@
   BaseLib
   BaseMemoryLib
   DebugLib
+  DebugPrintErrorLevelLib
   DevicePathLib
   FrameBufferBltLib
   MemoryAllocationLib
-- 
1.8.3.1