render / rpms / edk2

Forked from rpms/edk2 3 months ago
Clone

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

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