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

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