render / rpms / edk2

Forked from rpms/edk2 2 months ago
Clone

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

c4e3b2
From dc27035d2a8ca09dc5b0113c97a643341f286c08 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
c4e3b2
index 6d17616c1c..f1a97d4b2d 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>
c4e3b2
@@ -2642,6 +2643,22 @@ DriverEntry (
c4e3b2
   if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceNoneGuid) ||
c4e3b2
       CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){
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
-- 
c4e3b2
2.27.0
c4e3b2