Blame SOURCES/edk2-OvmfPkg-move-tcg-configuration-to-dsc-and-fdf-includ.patch

7439a5
From 02544e617ce4dfffff15dab47463484ccdc9a51f Mon Sep 17 00:00:00 2001
7439a5
From: Gerd Hoffmann <kraxel@redhat.com>
7439a5
Date: Wed, 15 Dec 2021 12:39:17 +0100
7439a5
Subject: [PATCH 2/6] OvmfPkg: move tcg configuration to dsc and fdf include
7439a5
 files
7439a5
7439a5
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
7439a5
RH-MergeRequest: 9: backport tpm build updates, disable tpm 1.2 support
7439a5
RH-Commit: [2/6] d811b2cf266baa0fa3f958af0b80bb208f3fe27c (kraxel/centos-edk2)
7439a5
RH-Bugzilla: 1935497
7439a5
RH-Acked-by: Oliver Steffen <None>
7439a5
7439a5
With this in place the tpm configuration is not duplicated for each of
7439a5
our four ovmf config variants (ia32, ia32x64, x64, amdsev) and it is
7439a5
easier to keep them all in sync when updating the tpm configuration.
7439a5
7439a5
No functional change.
7439a5
7439a5
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7439a5
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
7439a5
(cherry picked from commit b47575801e1903e8b316d01840572ce2681cf2c6)
7439a5
7439a5
[ kraxel: solve conflict in OvmfPkg/AmdSev/AmdSevX64.dsc ]
7439a5
---
7439a5
 OvmfPkg/AmdSev/AmdSevX64.dsc         | 85 ++++-----------------------
7439a5
 OvmfPkg/AmdSev/AmdSevX64.fdf         | 17 +-----
7439a5
 OvmfPkg/OvmfPkgIa32.dsc              | 88 ++++------------------------
7439a5
 OvmfPkg/OvmfPkgIa32.fdf              | 17 +-----
7439a5
 OvmfPkg/OvmfPkgIa32X64.dsc           | 85 ++++-----------------------
7439a5
 OvmfPkg/OvmfPkgIa32X64.fdf           | 17 +-----
7439a5
 OvmfPkg/OvmfPkgX64.dsc               | 85 ++++-----------------------
7439a5
 OvmfPkg/OvmfPkgX64.fdf               | 17 +-----
7439a5
 OvmfPkg/OvmfTpmComponentsDxe.dsc.inc | 28 +++++++++
7439a5
 OvmfPkg/OvmfTpmComponentsPei.dsc.inc | 22 +++++++
7439a5
 OvmfPkg/OvmfTpmDefines.dsc.inc       |  6 ++
7439a5
 OvmfPkg/OvmfTpmDxe.fdf.inc           | 12 ++++
7439a5
 OvmfPkg/OvmfTpmLibs.dsc.inc          | 14 +++++
7439a5
 OvmfPkg/OvmfTpmLibsDxe.dsc.inc       |  8 +++
7439a5
 OvmfPkg/OvmfTpmLibsPeim.dsc.inc      |  9 +++
7439a5
 OvmfPkg/OvmfTpmPcds.dsc.inc          |  7 +++
7439a5
 OvmfPkg/OvmfTpmPcdsHii.dsc.inc       |  8 +++
7439a5
 OvmfPkg/OvmfTpmPei.fdf.inc           | 11 ++++
7439a5
 OvmfPkg/OvmfTpmSecurityStub.dsc.inc  |  8 +++
7439a5
 19 files changed, 185 insertions(+), 359 deletions(-)
7439a5
 create mode 100644 OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmComponentsPei.dsc.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmDefines.dsc.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmDxe.fdf.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmLibs.dsc.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmLibsDxe.dsc.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmLibsPeim.dsc.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmPcds.dsc.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmPcdsHii.dsc.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmPei.fdf.inc
7439a5
 create mode 100644 OvmfPkg/OvmfTpmSecurityStub.dsc.inc
7439a5
7439a5
diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
7439a5
index 88b65b9f59..8610602ddb 100644
7439a5
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
7439a5
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
7439a5
@@ -32,8 +32,8 @@
7439a5
   # -D FLAG=VALUE
7439a5
   #
7439a5
   DEFINE SOURCE_DEBUG_ENABLE     = FALSE
7439a5
-  DEFINE TPM_ENABLE              = FALSE
7439a5
-  DEFINE TPM_CONFIG_ENABLE       = FALSE
7439a5
+
7439a5
+!include OvmfPkg/OvmfTpmDefines.dsc.inc
7439a5
 
7439a5
   #
7439a5
   # Shell can be useful for debugging but should not be enabled for production
7439a5
@@ -203,16 +203,7 @@
7439a5
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
7439a5
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
7439a5
-  Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
7439a5
-  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
7439a5
-  Tcg2PpVendorLib|SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
7439a5
-  TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
7439a5
-!else
7439a5
-  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
7439a5
-  TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmLibs.dsc.inc
7439a5
 
7439a5
 [LibraryClasses.common]
7439a5
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
7439a5
@@ -286,11 +277,7 @@
7439a5
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
7439a5
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
7439a5
-  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmLibsPeim.dsc.inc
7439a5
 
7439a5
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
7439a5
 
7439a5
@@ -371,10 +358,8 @@
7439a5
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
7439a5
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
7439a5
   QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
7439a5
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf
7439a5
-!endif
7439a5
+
7439a5
+!include OvmfPkg/OvmfTpmLibsDxe.dsc.inc
7439a5
 
7439a5
 [LibraryClasses.common.UEFI_APPLICATION]
7439a5
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
7439a5
@@ -576,15 +561,10 @@
7439a5
 
7439a5
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPcds.dsc.inc
7439a5
 
7439a5
 [PcdsDynamicHii]
7439a5
-!if $(TPM_ENABLE) == TRUE && $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x0|"1.3"|NV,BS
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x8|3|NV,BS
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPcdsHii.dsc.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 #
7439a5
@@ -625,24 +605,7 @@
7439a5
   UefiCpuPkg/CpuMpPei/CpuMpPei.inf
7439a5
   OvmfPkg/AmdSev/SecretPei/SecretPei.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
-  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
-  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
-  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf {
7439a5
-    <LibraryClasses>
7439a5
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
-  }
7439a5
-  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf {
7439a5
-    <LibraryClasses>
7439a5
-      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
-  }
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmComponentsPei.dsc.inc
7439a5
 
7439a5
   #
7439a5
   # DXE Phase modules
7439a5
@@ -664,10 +627,7 @@
7439a5
 
7439a5
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
7439a5
     <LibraryClasses>
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-      NULL|SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf
7439a5
-      NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmSecurityStub.dsc.inc
7439a5
   }
7439a5
 
7439a5
   OvmfPkg/8259InterruptControllerDxe/8259.inf
7439a5
@@ -830,27 +790,4 @@
7439a5
   #
7439a5
   # TPM support
7439a5
   #
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
7439a5
-      NULL|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
7439a5
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
-  }
7439a5
-!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
-!endif
7439a5
-  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
-  }
7439a5
-  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
-  }
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
7439a5
diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf
7439a5
index 325570c5a3..3f2329dab4 100644
7439a5
--- a/OvmfPkg/AmdSev/AmdSevX64.fdf
7439a5
+++ b/OvmfPkg/AmdSev/AmdSevX64.fdf
7439a5
@@ -156,13 +156,7 @@ INF  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
7439a5
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
7439a5
 INF  OvmfPkg/AmdSev/SecretPei/SecretPei.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-INF  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
-INF  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
-INF  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPei.fdf.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 
7439a5
@@ -311,14 +305,7 @@ INF  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
7439a5
 #
7439a5
 # TPM support
7439a5
 #
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-INF  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf
7439a5
-!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-INF  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
-!endif
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmDxe.fdf.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 
7439a5
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
7439a5
index fa42d919be..904176ccfc 100644
7439a5
--- a/OvmfPkg/OvmfPkgIa32.dsc
7439a5
+++ b/OvmfPkg/OvmfPkgIa32.dsc
7439a5
@@ -32,10 +32,10 @@
7439a5
   DEFINE SECURE_BOOT_ENABLE      = FALSE
7439a5
   DEFINE SMM_REQUIRE             = FALSE
7439a5
   DEFINE SOURCE_DEBUG_ENABLE     = FALSE
7439a5
-  DEFINE TPM_ENABLE              = FALSE
7439a5
-  DEFINE TPM_CONFIG_ENABLE       = FALSE
7439a5
   DEFINE LOAD_X64_ON_IA32_ENABLE = FALSE
7439a5
 
7439a5
+!include OvmfPkg/OvmfTpmDefines.dsc.inc
7439a5
+
7439a5
   #
7439a5
   # Network definition
7439a5
   #
7439a5
@@ -229,16 +229,7 @@
7439a5
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
7439a5
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
7439a5
-  Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
7439a5
-  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
7439a5
-  Tcg2PpVendorLib|SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
7439a5
-  TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
7439a5
-!else
7439a5
-  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
7439a5
-  TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmLibs.dsc.inc
7439a5
 
7439a5
 [LibraryClasses.common]
7439a5
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
7439a5
@@ -309,11 +300,7 @@
7439a5
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
7439a5
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
7439a5
-  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmLibsPeim.dsc.inc
7439a5
 
7439a5
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
7439a5
 
7439a5
@@ -401,10 +388,8 @@
7439a5
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
7439a5
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
7439a5
   QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
7439a5
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf
7439a5
-!endif
7439a5
+
7439a5
+!include OvmfPkg/OvmfTpmLibsDxe.dsc.inc
7439a5
 
7439a5
 [LibraryClasses.common.UEFI_APPLICATION]
7439a5
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
7439a5
@@ -643,19 +628,14 @@
7439a5
 
7439a5
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPcds.dsc.inc
7439a5
 
7439a5
   # IPv4 and IPv6 PXE Boot support.
7439a5
   gEfiNetworkPkgTokenSpaceGuid.PcdIPv4PXESupport|0x01
7439a5
   gEfiNetworkPkgTokenSpaceGuid.PcdIPv6PXESupport|0x01
7439a5
 
7439a5
 [PcdsDynamicHii]
7439a5
-!if $(TPM_ENABLE) == TRUE && $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x0|"1.3"|NV,BS
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x8|3|NV,BS
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPcdsHii.dsc.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 #
7439a5
@@ -705,24 +685,7 @@
7439a5
 !endif
7439a5
   UefiCpuPkg/CpuMpPei/CpuMpPei.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
-  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
-  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
-  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf {
7439a5
-    <LibraryClasses>
7439a5
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
-  }
7439a5
-  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf {
7439a5
-    <LibraryClasses>
7439a5
-      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
-  }
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmComponentsPei.dsc.inc
7439a5
 
7439a5
   #
7439a5
   # DXE Phase modules
7439a5
@@ -747,10 +710,7 @@
7439a5
 !if $(SECURE_BOOT_ENABLE) == TRUE
7439a5
       NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
7439a5
 !endif
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-      NULL|SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf
7439a5
-      NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmSecurityStub.dsc.inc
7439a5
   }
7439a5
 
7439a5
   OvmfPkg/8259InterruptControllerDxe/8259.inf
7439a5
@@ -1004,31 +964,5 @@
7439a5
   #
7439a5
   # TPM support
7439a5
   #
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
7439a5
-      NULL|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
7439a5
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
-  }
7439a5
-!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
-!endif
7439a5
-  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
-  }
7439a5
-  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
-  }
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
7439a5
 
7439a5
-!if $(LOAD_X64_ON_IA32_ENABLE) == TRUE
7439a5
-  OvmfPkg/CompatImageLoaderDxe/CompatImageLoaderDxe.inf
7439a5
-!endif
7439a5
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
7439a5
index 51433836d6..8ba9ffc83e 100644
7439a5
--- a/OvmfPkg/OvmfPkgIa32.fdf
7439a5
+++ b/OvmfPkg/OvmfPkgIa32.fdf
7439a5
@@ -161,13 +161,7 @@ INF  OvmfPkg/SmmAccess/SmmAccessPei.inf
7439a5
 !endif
7439a5
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-INF  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
-INF  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
-INF  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPei.fdf.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 
7439a5
@@ -353,14 +347,7 @@ INF  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
7439a5
 #
7439a5
 # TPM support
7439a5
 #
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-INF  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf
7439a5
-!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-INF  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
-!endif
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmDxe.fdf.inc
7439a5
 
7439a5
 !if $(LOAD_X64_ON_IA32_ENABLE) == TRUE
7439a5
 INF  OvmfPkg/CompatImageLoaderDxe/CompatImageLoaderDxe.inf
7439a5
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
7439a5
index ef962565f8..aebd8980e4 100644
7439a5
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
7439a5
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
7439a5
@@ -32,8 +32,8 @@
7439a5
   DEFINE SECURE_BOOT_ENABLE      = FALSE
7439a5
   DEFINE SMM_REQUIRE             = FALSE
7439a5
   DEFINE SOURCE_DEBUG_ENABLE     = FALSE
7439a5
-  DEFINE TPM_ENABLE              = FALSE
7439a5
-  DEFINE TPM_CONFIG_ENABLE       = FALSE
7439a5
+
7439a5
+!include OvmfPkg/OvmfTpmDefines.dsc.inc
7439a5
 
7439a5
   #
7439a5
   # Network definition
7439a5
@@ -233,16 +233,7 @@
7439a5
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
7439a5
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
7439a5
-  Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
7439a5
-  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
7439a5
-  Tcg2PpVendorLib|SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
7439a5
-  TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
7439a5
-!else
7439a5
-  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
7439a5
-  TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmLibs.dsc.inc
7439a5
 
7439a5
 [LibraryClasses.common]
7439a5
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
7439a5
@@ -313,11 +304,7 @@
7439a5
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
7439a5
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
7439a5
-  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmLibsPeim.dsc.inc
7439a5
 
7439a5
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
7439a5
 
7439a5
@@ -405,10 +392,8 @@
7439a5
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
7439a5
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
7439a5
   QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
7439a5
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf
7439a5
-!endif
7439a5
+
7439a5
+!include OvmfPkg/OvmfTpmLibsDxe.dsc.inc
7439a5
 
7439a5
 [LibraryClasses.common.UEFI_APPLICATION]
7439a5
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
7439a5
@@ -655,9 +640,7 @@
7439a5
 
7439a5
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPcds.dsc.inc
7439a5
 
7439a5
 [PcdsDynamicDefault.X64]
7439a5
   # IPv4 and IPv6 PXE Boot support.
7439a5
@@ -665,10 +648,7 @@
7439a5
   gEfiNetworkPkgTokenSpaceGuid.PcdIPv6PXESupport|0x01
7439a5
 
7439a5
 [PcdsDynamicHii]
7439a5
-!if $(TPM_ENABLE) == TRUE && $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x0|"1.3"|NV,BS
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x8|3|NV,BS
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPcdsHii.dsc.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 #
7439a5
@@ -718,24 +698,7 @@
7439a5
 !endif
7439a5
   UefiCpuPkg/CpuMpPei/CpuMpPei.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
-  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
-  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
-  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf {
7439a5
-    <LibraryClasses>
7439a5
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
-  }
7439a5
-  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf {
7439a5
-    <LibraryClasses>
7439a5
-      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
-  }
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmComponentsPei.dsc.inc
7439a5
 
7439a5
 [Components.X64]
7439a5
   #
7439a5
@@ -761,10 +724,7 @@
7439a5
 !if $(SECURE_BOOT_ENABLE) == TRUE
7439a5
       NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
7439a5
 !endif
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-      NULL|SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf
7439a5
-      NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmSecurityStub.dsc.inc
7439a5
   }
7439a5
 
7439a5
   OvmfPkg/8259InterruptControllerDxe/8259.inf
7439a5
@@ -1019,27 +979,4 @@
7439a5
   #
7439a5
   # TPM support
7439a5
   #
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
7439a5
-      NULL|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
7439a5
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
-  }
7439a5
-!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
-!endif
7439a5
-  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
-  }
7439a5
-  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
-  }
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
7439a5
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
7439a5
index a50f80e1e9..65d2600016 100644
7439a5
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
7439a5
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
7439a5
@@ -164,13 +164,7 @@ INF  OvmfPkg/SmmAccess/SmmAccessPei.inf
7439a5
 !endif
7439a5
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-INF  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
-INF  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
-INF  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPei.fdf.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 
7439a5
@@ -363,14 +357,7 @@ INF  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
7439a5
 #
7439a5
 # TPM support
7439a5
 #
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-INF  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf
7439a5
-!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-INF  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
-!endif
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmDxe.fdf.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 
7439a5
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
7439a5
index ba9f9833b0..e85ac3d682 100644
7439a5
--- a/OvmfPkg/OvmfPkgX64.dsc
7439a5
+++ b/OvmfPkg/OvmfPkgX64.dsc
7439a5
@@ -32,8 +32,8 @@
7439a5
   DEFINE SECURE_BOOT_ENABLE      = FALSE
7439a5
   DEFINE SMM_REQUIRE             = FALSE
7439a5
   DEFINE SOURCE_DEBUG_ENABLE     = FALSE
7439a5
-  DEFINE TPM_ENABLE              = FALSE
7439a5
-  DEFINE TPM_CONFIG_ENABLE       = FALSE
7439a5
+
7439a5
+!include OvmfPkg/OvmfTpmDefines.dsc.inc
7439a5
 
7439a5
   #
7439a5
   # Network definition
7439a5
@@ -233,16 +233,7 @@
7439a5
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
7439a5
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
7439a5
-  Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
7439a5
-  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
7439a5
-  Tcg2PpVendorLib|SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
7439a5
-  TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
7439a5
-!else
7439a5
-  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
7439a5
-  TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmLibs.dsc.inc
7439a5
 
7439a5
 [LibraryClasses.common]
7439a5
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
7439a5
@@ -315,11 +306,7 @@
7439a5
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
7439a5
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
7439a5
-  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmLibsPeim.dsc.inc
7439a5
 
7439a5
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
7439a5
 
7439a5
@@ -407,10 +394,8 @@
7439a5
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
7439a5
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
7439a5
   QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
7439a5
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf
7439a5
-!endif
7439a5
+
7439a5
+!include OvmfPkg/OvmfTpmLibsDxe.dsc.inc
7439a5
 
7439a5
 [LibraryClasses.common.UEFI_APPLICATION]
7439a5
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
7439a5
@@ -655,19 +640,14 @@
7439a5
 
7439a5
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPcds.dsc.inc
7439a5
 
7439a5
   # IPv4 and IPv6 PXE Boot support.
7439a5
   gEfiNetworkPkgTokenSpaceGuid.PcdIPv4PXESupport|0x01
7439a5
   gEfiNetworkPkgTokenSpaceGuid.PcdIPv6PXESupport|0x01
7439a5
 
7439a5
 [PcdsDynamicHii]
7439a5
-!if $(TPM_ENABLE) == TRUE && $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x0|"1.3"|NV,BS
7439a5
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x8|3|NV,BS
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPcdsHii.dsc.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 #
7439a5
@@ -717,24 +697,7 @@
7439a5
 !endif
7439a5
   UefiCpuPkg/CpuMpPei/CpuMpPei.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
-  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
-  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
-  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf {
7439a5
-    <LibraryClasses>
7439a5
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
-  }
7439a5
-  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf {
7439a5
-    <LibraryClasses>
7439a5
-      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
-  }
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmComponentsPei.dsc.inc
7439a5
 
7439a5
   #
7439a5
   # DXE Phase modules
7439a5
@@ -758,10 +721,7 @@
7439a5
     <LibraryClasses>
7439a5
 !if $(SECURE_BOOT_ENABLE) == TRUE
7439a5
       NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
7439a5
-!endif
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-      NULL|SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf
7439a5
-      NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
7439a5
+!include OvmfPkg/OvmfTpmSecurityStub.dsc.inc
7439a5
 !endif
7439a5
   }
7439a5
 
7439a5
@@ -1017,27 +977,4 @@
7439a5
   #
7439a5
   # TPM support
7439a5
   #
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
7439a5
-      NULL|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
7439a5
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
-      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
-  }
7439a5
-!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
-!endif
7439a5
-  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
-  }
7439a5
-  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf {
7439a5
-    <LibraryClasses>
7439a5
-      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
-  }
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
7439a5
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
7439a5
index dd1c6eded9..e5cbae2073 100644
7439a5
--- a/OvmfPkg/OvmfPkgX64.fdf
7439a5
+++ b/OvmfPkg/OvmfPkgX64.fdf
7439a5
@@ -180,13 +180,7 @@ INF  OvmfPkg/SmmAccess/SmmAccessPei.inf
7439a5
 !endif
7439a5
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
7439a5
 
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-INF  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
-INF  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
-INF  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmPei.fdf.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 
7439a5
@@ -379,14 +373,7 @@ INF  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
7439a5
 #
7439a5
 # TPM support
7439a5
 #
7439a5
-!if $(TPM_ENABLE) == TRUE
7439a5
-INF  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
7439a5
-INF  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf
7439a5
-!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
-INF  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
-!endif
7439a5
-!endif
7439a5
+!include OvmfPkg/OvmfTpmDxe.fdf.inc
7439a5
 
7439a5
 ################################################################################
7439a5
 
7439a5
diff --git a/OvmfPkg/OvmfTpmComponentsDxe.dsc.inc b/OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
7439a5
new file mode 100644
7439a5
index 0000000000..d5c2586118
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
7439a5
@@ -0,0 +1,28 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE
7439a5
+  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf {
7439a5
+    <LibraryClasses>
7439a5
+      Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
7439a5
+      NULL|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
7439a5
+      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
+  }
7439a5
+!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
+  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
+!endif
7439a5
+  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf {
7439a5
+    <LibraryClasses>
7439a5
+      Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
+  }
7439a5
+  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf {
7439a5
+    <LibraryClasses>
7439a5
+      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
+  }
7439a5
+!endif
7439a5
diff --git a/OvmfPkg/OvmfTpmComponentsPei.dsc.inc b/OvmfPkg/OvmfTpmComponentsPei.dsc.inc
7439a5
new file mode 100644
7439a5
index 0000000000..99fa7c13b3
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmComponentsPei.dsc.inc
7439a5
@@ -0,0 +1,22 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE
7439a5
+  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
+  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
+  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
+  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf {
7439a5
+    <LibraryClasses>
7439a5
+      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
7439a5
+      NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
7439a5
+  }
7439a5
+  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf {
7439a5
+    <LibraryClasses>
7439a5
+      TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
7439a5
+  }
7439a5
+!endif
7439a5
diff --git a/OvmfPkg/OvmfTpmDefines.dsc.inc b/OvmfPkg/OvmfTpmDefines.dsc.inc
7439a5
new file mode 100644
7439a5
index 0000000000..51da7508b3
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmDefines.dsc.inc
7439a5
@@ -0,0 +1,6 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+  DEFINE TPM_ENABLE              = FALSE
7439a5
+  DEFINE TPM_CONFIG_ENABLE       = FALSE
7439a5
diff --git a/OvmfPkg/OvmfTpmDxe.fdf.inc b/OvmfPkg/OvmfTpmDxe.fdf.inc
7439a5
new file mode 100644
7439a5
index 0000000000..9dcdaaf01c
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmDxe.fdf.inc
7439a5
@@ -0,0 +1,12 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE
7439a5
+INF  SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
7439a5
+INF  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
7439a5
+INF  SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf
7439a5
+!if $(TPM_CONFIG_ENABLE) == TRUE
7439a5
+INF  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
7439a5
+!endif
7439a5
+!endif
7439a5
diff --git a/OvmfPkg/OvmfTpmLibs.dsc.inc b/OvmfPkg/OvmfTpmLibs.dsc.inc
7439a5
new file mode 100644
7439a5
index 0000000000..50100f2c03
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmLibs.dsc.inc
7439a5
@@ -0,0 +1,14 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE
7439a5
+  Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
7439a5
+  Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
7439a5
+  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
7439a5
+  Tcg2PpVendorLib|SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
7439a5
+  TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
7439a5
+!else
7439a5
+  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
7439a5
+  TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
7439a5
+!endif
7439a5
diff --git a/OvmfPkg/OvmfTpmLibsDxe.dsc.inc b/OvmfPkg/OvmfTpmLibsDxe.dsc.inc
7439a5
new file mode 100644
7439a5
index 0000000000..67d5027aba
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmLibsDxe.dsc.inc
7439a5
@@ -0,0 +1,8 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE
7439a5
+  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
7439a5
+  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf
7439a5
+!endif
7439a5
diff --git a/OvmfPkg/OvmfTpmLibsPeim.dsc.inc b/OvmfPkg/OvmfTpmLibsPeim.dsc.inc
7439a5
new file mode 100644
7439a5
index 0000000000..4e84e3dcaa
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmLibsPeim.dsc.inc
7439a5
@@ -0,0 +1,9 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE
7439a5
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
7439a5
+  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
7439a5
+  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
7439a5
+!endif
7439a5
diff --git a/OvmfPkg/OvmfTpmPcds.dsc.inc b/OvmfPkg/OvmfTpmPcds.dsc.inc
7439a5
new file mode 100644
7439a5
index 0000000000..0e7f83c04b
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmPcds.dsc.inc
7439a5
@@ -0,0 +1,7 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE
7439a5
+  gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
7439a5
+!endif
7439a5
diff --git a/OvmfPkg/OvmfTpmPcdsHii.dsc.inc b/OvmfPkg/OvmfTpmPcdsHii.dsc.inc
7439a5
new file mode 100644
7439a5
index 0000000000..164bc9c7fc
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmPcdsHii.dsc.inc
7439a5
@@ -0,0 +1,8 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE && $(TPM_CONFIG_ENABLE) == TRUE
7439a5
+  gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x0|"1.3"|NV,BS
7439a5
+  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x8|3|NV,BS
7439a5
+!endif
7439a5
diff --git a/OvmfPkg/OvmfTpmPei.fdf.inc b/OvmfPkg/OvmfTpmPei.fdf.inc
7439a5
new file mode 100644
7439a5
index 0000000000..9aefd73d21
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmPei.fdf.inc
7439a5
@@ -0,0 +1,11 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE
7439a5
+INF  OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf
7439a5
+INF  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
7439a5
+INF  SecurityPkg/Tcg/TcgPei/TcgPei.inf
7439a5
+INF  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
7439a5
+INF  SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
7439a5
+!endif
7439a5
diff --git a/OvmfPkg/OvmfTpmSecurityStub.dsc.inc b/OvmfPkg/OvmfTpmSecurityStub.dsc.inc
7439a5
new file mode 100644
7439a5
index 0000000000..4bd4066843
7439a5
--- /dev/null
7439a5
+++ b/OvmfPkg/OvmfTpmSecurityStub.dsc.inc
7439a5
@@ -0,0 +1,8 @@
7439a5
+##
7439a5
+#    SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
+##
7439a5
+
7439a5
+!if $(TPM_ENABLE) == TRUE
7439a5
+      NULL|SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf
7439a5
+      NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
7439a5
+!endif
7439a5
-- 
7439a5
2.27.0
7439a5