]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/Tcg2Smm/Tcg2StandaloneMm.c
SecurityPkg: Tcg2Smm: Added support for Standalone Mm
[mirror_edk2.git] / SecurityPkg / Tcg / Tcg2Smm / Tcg2StandaloneMm.c
diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2StandaloneMm.c b/SecurityPkg/Tcg/Tcg2Smm/Tcg2StandaloneMm.c
new file mode 100644 (file)
index 0000000..9e0095e
--- /dev/null
@@ -0,0 +1,71 @@
+/** @file\r
+  TCG2 Standalone MM driver that updates TPM2 items in ACPI table and registers\r
+  SMI2 callback functions for Tcg2 physical presence, ClearMemory, and\r
+  sample for dTPM StartMethod.\r
+\r
+  Caution: This module requires additional review when modified.\r
+  This driver will have external input - variable and ACPINvs data in SMM mode.\r
+  This external input must be validated carefully to avoid security issue.\r
+\r
+  PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.\r
+\r
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) Microsoft Corporation.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "Tcg2Smm.h"\r
+#include <Library/StandaloneMmMemLib.h>\r
+\r
+/**\r
+  Notify the system that the SMM variable driver is ready.\r
+**/\r
+VOID\r
+Tcg2NotifyMmReady (\r
+  VOID\r
+  )\r
+{\r
+  // Do nothing\r
+}\r
+\r
+/**\r
+  This function is an abstraction layer for implementation specific Mm buffer validation routine.\r
+\r
+  @param Buffer  The buffer start address to be checked.\r
+  @param Length  The buffer length to be checked.\r
+\r
+  @retval TRUE  This buffer is valid per processor architecture and not overlap with SMRAM.\r
+  @retval FALSE This buffer is not valid per processor architecture or overlap with SMRAM.\r
+**/\r
+BOOLEAN\r
+IsBufferOutsideMmValid (\r
+  IN EFI_PHYSICAL_ADDRESS  Buffer,\r
+  IN UINT64                Length\r
+  )\r
+{\r
+  return MmIsBufferOutsideMmValid (Buffer, Length);\r
+}\r
+\r
+/**\r
+  The driver's entry point.\r
+\r
+  It install callbacks for TPM physical presence and MemoryClear, and locate\r
+  SMM variable to be used in the callback function.\r
+\r
+  @param[in] ImageHandle  The firmware allocated handle for the EFI image.\r
+  @param[in] SystemTable  A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS     The entry point is executed successfully.\r
+  @retval Others          Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeTcgStandaloneMm (\r
+  IN EFI_HANDLE                  ImageHandle,\r
+  IN EFI_MM_SYSTEM_TABLE         *SystemTable\r
+  )\r
+{\r
+  return InitializeTcgCommon ();\r
+}\r