diff options
author | Dun Tan <dun.tan@intel.com> | 2024-06-04 09:52:52 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-07-02 03:31:31 +0000 |
commit | 9a76c7945b762ed8abed3b917aa6217846ae1918 (patch) | |
tree | bf1c17976656b0fe09783e37976ada3fca02f5e2 /SecurityPkg | |
parent | cb6ba975ae54f8eb915136264bf040d52d7bc2b4 (diff) | |
download | edk2-9a76c7945b762ed8abed3b917aa6217846ae1918.zip edk2-9a76c7945b762ed8abed3b917aa6217846ae1918.tar.gz edk2-9a76c7945b762ed8abed3b917aa6217846ae1918.tar.bz2 |
SecurityPkg: Build gEdkiiTcg2AcpiCommunicateBufferHobGuid
Install a callback of gEfiPeiMemoryDiscoveredPpiGuid to
build the gEdkiiTcg2AcpiCommunicateBufferHobGuid in the
Tcg2ConfigPei PEIM.
The HOB contains a buffer reserved by MmUnblockMemoryLib.
The buffer will be used in Tcg2Acpi driver to retrive
information from standalone mm environment.
Signed-off-by: Dun Tan <dun.tan@intel.com>
Diffstat (limited to 'SecurityPkg')
-rw-r--r-- | SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf | 3 | ||||
-rw-r--r-- | SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c | 52 |
2 files changed, 55 insertions, 0 deletions
diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf index b0c9c44..f7213b2 100644 --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf @@ -47,6 +47,7 @@ Tpm12CommandLib
Tpm12DeviceLib
HobLib
+ MmUnblockMemoryLib
[Guids]
## SOMETIMES_CONSUMES ## Variable:L"TCG2_CONFIGURATION"
@@ -56,10 +57,12 @@ gEfiTpmDeviceInstanceNoneGuid ## SOMETIMES_CONSUMES ## GUID # TPM device identifier
gEdkiiTpmInstanceHobGuid
gEdkiiTcgPhysicalPresenceInterfaceVerHobGuid
+ gEdkiiTcg2AcpiCommunicateBufferHobGuid
[Ppis]
gEfiPeiReadOnlyVariable2PpiGuid ## CONSUMES
gPeiTpmInitializationDonePpiGuid ## SOMETIMES_PRODUCES
+ gEfiPeiMemoryDiscoveredPpiGuid
[Pcd]
gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid ## PRODUCES
diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c index 9840deb..ce78e32 100644 --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c @@ -9,6 +9,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <PiPei.h>
#include <Guid/TpmInstance.h>
+#include <Guid/Tcg2AcpiCommunicateBuffer.h>
+#include <Guid/TpmNvsMm.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
@@ -17,6 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/PeiServicesLib.h>
#include <Library/PcdLib.h>
#include <Library/HobLib.h>
+#include <Library/MmUnblockMemoryLib.h>
#include <Ppi/ReadOnlyVariable2.h>
#include <Ppi/TpmInitialized.h>
@@ -52,6 +55,53 @@ DetectTpmDevice ( );
/**
+ Build gEdkiiTcg2AcpiCommunicateBufferHobGuid.
+
+ @param[in] PeiServices General purpose services available to every PEIM.
+ @param[in] NotifyDescriptor The notification structure this PEIM registered on install.
+ @param[in] Ppi The memory discovered PPI. Not used.
+
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval others Failed to build Tcg2AcpiCommunicateBuffer Hob.
+
+**/
+EFI_STATUS
+EFIAPI
+BuildTcg2AcpiCommunicateBufferHob (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ )
+{
+ TCG2_ACPI_COMMUNICATE_BUFFER *Tcg2AcpiCommunicateBufferHob;
+ EFI_STATUS Status;
+ VOID *Buffer;
+ UINTN Pages;
+
+ Pages = sizeof (TCG_NVS);
+ Buffer = AllocateRuntimePages (Pages);
+ ASSERT (Buffer != NULL);
+
+ Status = MmUnblockMemoryRequest ((UINTN)Buffer, Pages);
+ if ((Status != EFI_UNSUPPORTED) && EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Tcg2AcpiCommunicateBufferHob = BuildGuidHob (&gEdkiiTcg2AcpiCommunicateBufferHobGuid, sizeof (TCG2_ACPI_COMMUNICATE_BUFFER));
+ ASSERT (Tcg2AcpiCommunicateBufferHob != NULL);
+ Tcg2AcpiCommunicateBufferHob->Tcg2AcpiCommunicateBuffer = (UINTN)Buffer;
+ Tcg2AcpiCommunicateBufferHob->Pages = Pages;
+
+ return EFI_SUCCESS;
+}
+
+EFI_PEI_NOTIFY_DESCRIPTOR mPostMemNotifyList = {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiPeiMemoryDiscoveredPpiGuid,
+ BuildTcg2AcpiCommunicateBufferHob
+};
+
+/**
The entry point for Tcg2 configuration driver.
@param FileHandle Handle of the file being invoked.
@@ -155,6 +205,8 @@ Tcg2ConfigPeimEntryPoint ( );
ASSERT (Hob != NULL);
+ PeiServicesNotifyPpi (&mPostMemNotifyList);
+
//
// Selection done
//
|