Blame SOURCES/0019-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch

8c9246
From 83b201c9fa9c8c3bded3b4e8c13de797588fe7bd Mon Sep 17 00:00:00 2001
c4e3b2
From: Laszlo Ersek <lersek@redhat.com>
c4e3b2
Date: Wed, 24 Jun 2020 11:40:09 +0200
c4e3b2
Subject: SecurityPkg/Tcg2Dxe: suppress error on no swtpm in silent aa64 build
c4e3b2
 (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 swtpm / vTPM2 is not being used, Tcg2Dxe should return EFI_UNSUPPORTED,
c4e3b2
so that the DXE Core can unload it. However, the associated error message,
c4e3b2
logged by the DXE Core to the serial console, is not desired in the silent
c4e3b2
edk2-aarch64 build, given that the absence of swtpm / vTPM2 is nothing out
c4e3b2
of the ordinary. Therefore, return success and stay resident. The wasted
c4e3b2
guest RAM still gets freed after 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 cbce29f7749477e271f9764fed82de94724af5df)
c4e3b2
---
c4e3b2
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c   | 17 +++++++++++++++++
c4e3b2
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf |  1 +
c4e3b2
 2 files changed, 18 insertions(+)
c4e3b2
c4e3b2
diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
8c9246
index f6ea8b2bbf..681eb7e08b 100644
c4e3b2
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
c4e3b2
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
c4e3b2
@@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
c4e3b2
 #include <Protocol/ResetNotification.h>
c4e3b2
 
c4e3b2
 #include <Library/DebugLib.h>
c4e3b2
+#include <Library/DebugPrintErrorLevelLib.h>
c4e3b2
 #include <Library/BaseMemoryLib.h>
c4e3b2
 #include <Library/UefiRuntimeServicesTableLib.h>
c4e3b2
 #include <Library/UefiDriverEntryPoint.h>
8c9246
@@ -2691,6 +2692,22 @@ DriverEntry (
8c9246
       CompareGuid (PcdGetPtr (PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid))
8c9246
   {
c4e3b2
     DEBUG ((DEBUG_INFO, "No TPM2 instance required!\n"));
c4e3b2
+#if defined (MDE_CPU_AARCH64)
c4e3b2
+    //
c4e3b2
+    // RHBZ#1844682
c4e3b2
+    //
c4e3b2
+    // If swtpm / vTPM2 is not being used, this driver should return
c4e3b2
+    // EFI_UNSUPPORTED, so that the DXE Core can unload it. However, the
c4e3b2
+    // associated error message, logged by the DXE Core to the serial console,
c4e3b2
+    // is not desired in the silent edk2-aarch64 build, given that the absence
c4e3b2
+    // of swtpm / vTPM2 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
+    if (GetDebugPrintErrorLevel () == DEBUG_ERROR) {
c4e3b2
+      return EFI_SUCCESS;
c4e3b2
+    }
c4e3b2
+#endif
c4e3b2
     return EFI_UNSUPPORTED;
c4e3b2
   }
c4e3b2
 
c4e3b2
diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
c4e3b2
index 7dc7a2683d..3bc8833931 100644
c4e3b2
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
c4e3b2
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
c4e3b2
@@ -55,6 +55,7 @@
c4e3b2
   UefiRuntimeServicesTableLib
c4e3b2
   BaseMemoryLib
c4e3b2
   DebugLib
c4e3b2
+  DebugPrintErrorLevelLib
c4e3b2
   Tpm2CommandLib
c4e3b2
   PrintLib
c4e3b2
   UefiLib
c4e3b2
-- 
8c9246
2.31.1
c4e3b2