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

8ff9b3
From 37930c8079ea630535f82068b678c7ab2f9981a5 Mon Sep 17 00:00:00 2001
7439a5
From: Laszlo Ersek <lersek@redhat.com>
7439a5
Date: Wed, 24 Jun 2020 11:40:09 +0200
7439a5
Subject: SecurityPkg/Tcg2Dxe: suppress error on no swtpm in silent aa64 build
7439a5
 (RH)
7439a5
7439a5
Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] ->
7439a5
RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase:
7439a5
7439a5
- Remove obsolete commit message tags related to downstream patch
7439a5
  management: Message-id, Patchwork-id, O-Subject, Acked-by, From,
7439a5
  RH-Acked-by, RH-Author (RHBZ#1846481).
7439a5
7439a5
Bugzilla: 1844682
7439a5
7439a5
If swtpm / vTPM2 is not being used, Tcg2Dxe should return EFI_UNSUPPORTED,
7439a5
so that the DXE Core can unload it. However, the associated error message,
7439a5
logged by the DXE Core to the serial console, is not desired in the silent
7439a5
edk2-aarch64 build, given that the absence of swtpm / vTPM2 is nothing out
7439a5
of the ordinary. Therefore, return success and stay resident. The wasted
7439a5
guest RAM still gets freed after ExitBootServices().
7439a5
7439a5
(Inspired by RHEL-8.1.0 commit aaaedc1e2cfd.)
7439a5
7439a5
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
7439a5
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7439a5
(cherry picked from commit cbce29f7749477e271f9764fed82de94724af5df)
7439a5
---
7439a5
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c   | 17 +++++++++++++++++
7439a5
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf |  1 +
7439a5
 2 files changed, 18 insertions(+)
7439a5
7439a5
diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
be6997
index f6ea8b2bbf..681eb7e08b 100644
7439a5
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
7439a5
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
7439a5
@@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
 #include <Protocol/ResetNotification.h>
7439a5
 
7439a5
 #include <Library/DebugLib.h>
7439a5
+#include <Library/DebugPrintErrorLevelLib.h>
7439a5
 #include <Library/BaseMemoryLib.h>
7439a5
 #include <Library/UefiRuntimeServicesTableLib.h>
7439a5
 #include <Library/UefiDriverEntryPoint.h>
be6997
@@ -2691,6 +2692,22 @@ DriverEntry (
be6997
       CompareGuid (PcdGetPtr (PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid))
be6997
   {
7439a5
     DEBUG ((DEBUG_INFO, "No TPM2 instance required!\n"));
7439a5
+#if defined (MDE_CPU_AARCH64)
7439a5
+    //
7439a5
+    // RHBZ#1844682
7439a5
+    //
7439a5
+    // If swtpm / vTPM2 is not being used, this driver should return
7439a5
+    // EFI_UNSUPPORTED, so that the DXE Core can unload it. However, the
7439a5
+    // associated error message, logged by the DXE Core to the serial console,
7439a5
+    // is not desired in the silent edk2-aarch64 build, given that the absence
7439a5
+    // of swtpm / vTPM2 is nothing out of the ordinary. Therefore, return
7439a5
+    // success and stay resident. The wasted guest RAM still gets freed after
7439a5
+    // ExitBootServices().
7439a5
+    //
7439a5
+    if (GetDebugPrintErrorLevel () == DEBUG_ERROR) {
7439a5
+      return EFI_SUCCESS;
7439a5
+    }
7439a5
+#endif
7439a5
     return EFI_UNSUPPORTED;
7439a5
   }
7439a5
 
7439a5
diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
7439a5
index 7dc7a2683d..3bc8833931 100644
7439a5
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
7439a5
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
7439a5
@@ -55,6 +55,7 @@
7439a5
   UefiRuntimeServicesTableLib
7439a5
   BaseMemoryLib
7439a5
   DebugLib
7439a5
+  DebugPrintErrorLevelLib
7439a5
   Tpm2CommandLib
7439a5
   PrintLib
7439a5
   UefiLib
7439a5
-- 
8ff9b3
2.38.1
7439a5