]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: MmUnblockMemoryLib: Added definition and null instance
authorKun Qin <kun.q@outlook.com>
Fri, 5 Mar 2021 04:12:47 +0000 (20:12 -0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 5 Mar 2021 15:25:07 +0000 (15:25 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3168

This interface provides an abstration layer to allow MM modules to access
requested areas that are outside of MMRAM. On MM model that blocks all
non-MMRAM accesses, areas requested through this API will be mapped or
unblocked for accessibility inside MM environment.

For MM modules that need to access regions outside of MMRAMs, the agents
that set up these regions are responsible for invoking this API in order
for these memory areas to be accessible from inside MM.

Example usages:
1. To enable runtime cache feature for variable service, Variable MM
module will need to access the allocated runtime buffer. Thus the agent
sets up these buffers, VariableSmmRuntimeDxe, will need to invoke this
API to make these regions accessible by Variable MM.
2. For TPM ACPI table to communicate to physical presence handler, the
corresponding NVS region has to be accessible from inside MM. Once the
NVS region are assigned, it needs to be unblocked thourgh this API.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Message-Id: <MWHPR06MB31028AF0D0785B93E4E7CF63F3969@MWHPR06MB3102.namprd06.prod.outlook.com>

MdePkg/Include/Library/MmUnblockMemoryLib.h [new file with mode: 0644]
MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c [new file with mode: 0644]
MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf [new file with mode: 0644]
MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni [new file with mode: 0644]
MdePkg/MdePkg.dec
MdePkg/MdePkg.dsc

diff --git a/MdePkg/Include/Library/MmUnblockMemoryLib.h b/MdePkg/Include/Library/MmUnblockMemoryLib.h
new file mode 100644 (file)
index 0000000..00fab53
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+  MM Unblock Memory Library Interface.\r
+\r
+  This library provides an interface to request non-MMRAM pages to be mapped/unblocked\r
+  from inside MM environment.\r
+\r
+  For MM modules that need to access regions outside of MMRAMs, the agents that set up\r
+  these regions are responsible for invoking this API in order for these memory areas\r
+  to be accessed from inside MM.\r
+\r
+  Copyright (c) Microsoft Corporation.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef MM_UNBLOCK_MEMORY_LIB_H_\r
+#define MM_UNBLOCK_MEMORY_LIB_H_\r
+\r
+/**\r
+  This API provides a way to unblock certain data pages to be accessible inside MM environment.\r
+\r
+  @param  UnblockAddress              The address of buffer caller requests to unblock, the address\r
+                                      has to be page aligned.\r
+  @param  NumberOfPages               The number of pages requested to be unblocked from MM\r
+                                      environment.\r
+\r
+  @retval RETURN_SUCCESS              The request goes through successfully.\r
+  @retval RETURN_NOT_AVAILABLE_YET    The requested functionality is not produced yet.\r
+  @retval RETURN_UNSUPPORTED          The requested functionality is not supported on current platform.\r
+  @retval RETURN_SECURITY_VIOLATION   The requested address failed to pass security check for\r
+                                      unblocking.\r
+  @retval RETURN_INVALID_PARAMETER    Input address either NULL pointer or not page aligned.\r
+  @retval RETURN_ACCESS_DENIED        The request is rejected due to system has passed certain boot\r
+                                      phase.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+MmUnblockMemoryRequest (\r
+  IN PHYSICAL_ADDRESS       UnblockAddress,\r
+  IN UINT64                 NumberOfPages\r
+);\r
+\r
+#endif // MM_UNBLOCK_MEMORY_LIB_H_\r
diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c
new file mode 100644 (file)
index 0000000..b205c91
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+  Null instance of MM Unblock Page Library.\r
+\r
+  This library provides an interface to request non-MMRAM pages to be mapped/unblocked\r
+  from inside MM environment.\r
+\r
+  For MM modules that need to access regions outside of MMRAMs, the agents that set up\r
+  these regions are responsible for invoking this API in order for these memory areas\r
+  to be accessed from inside MM.\r
+\r
+  Copyright (c) Microsoft Corporation.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Base.h>\r
+\r
+/**\r
+  This API provides a way to unblock certain data pages to be accessible inside MM environment.\r
+\r
+  @param  UnblockAddress              The address of buffer caller requests to unblock, the address\r
+                                      has to be page aligned.\r
+  @param  NumberOfPages               The number of pages requested to be unblocked from MM\r
+                                      environment.\r
+\r
+  @retval RETURN_SUCCESS              The request goes through successfully.\r
+  @retval RETURN_NOT_AVAILABLE_YET    The requested functionality is not produced yet.\r
+  @retval RETURN_UNSUPPORTED          The requested functionality is not supported on current platform.\r
+  @retval RETURN_SECURITY_VIOLATION   The requested address failed to pass security check for\r
+                                      unblocking.\r
+  @retval RETURN_INVALID_PARAMETER    Input address either NULL pointer or not page aligned.\r
+  @retval RETURN_ACCESS_DENIED        The request is rejected due to system has passed certain boot\r
+                                      phase.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+MmUnblockMemoryRequest (\r
+  IN PHYSICAL_ADDRESS       UnblockAddress,\r
+  IN UINT64                 NumberOfPages\r
+  )\r
+{\r
+  return RETURN_UNSUPPORTED;\r
+}\r
diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
new file mode 100644 (file)
index 0000000..8ecb767
--- /dev/null
@@ -0,0 +1,34 @@
+## @file\r
+#  Null instance of MM Unblock Page Library.\r
+#\r
+#  This library provides an interface to request non-MMRAM pages to be mapped/unblocked\r
+#  from inside MM environment.\r
+#\r
+#  For MM modules that need to access regions outside of MMRAMs, the agents that set up\r
+#  these regions are responsible for invoking this API in order for these memory areas\r
+#  to be accessed from inside MM.\r
+#\r
+#  Copyright (c) Microsoft Corporation.\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x0001001B\r
+  BASE_NAME                      = MmUnblockMemoryLibNull\r
+  MODULE_UNI_FILE                = MmUnblockMemoryLibNull.uni\r
+  FILE_GUID                      = 9E890F68-5C95-4C31-95DD-59E6286F85EA\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = MmUnblockMemoryLib\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  MmUnblockMemoryLibNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni
new file mode 100644 (file)
index 0000000..d7f2709
--- /dev/null
@@ -0,0 +1,21 @@
+// /** @file\r
+// Null instance of MM Unblock Page Library.\r
+//\r
+// This library provides an interface to request non-MMRAM pages to be mapped/unblocked\r
+// from inside MM environment.\r
+//\r
+// For MM modules that need to access regions outside of MMRAMs, the agents that set up\r
+// these regions are responsible for invoking this API in order for these memory areas\r
+// to be accessed from inside MM.\r
+//\r
+// Copyright (c) Microsoft Corporation.\r
+// SPDX-License-Identifier: BSD-2-Clause-Patent\r
+//\r
+// **/\r
+\r
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "Null instance of MM Unblock Page Library."\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "This library provides an interface to request non-MMRAM pages to be mapped/unblocked from inside MM environment.\n"\r
+                                                        "For MM modules that need to access regions outside of MMRAMs, the agents that set up these regions are responsible for invoking this API in order for these memory areas to be accessed from inside MM."\r
+\r
index 3928db65d18815509d7a914b21ea457ba19e3f4e..1d2637acc22a24fa54c9ba2f573a1cdd46ee2082 100644 (file)
   #\r
   UnitTestHostBaseLib|Test/UnitTest/Include/Library/UnitTestHostBaseLib.h\r
 \r
+  ##  @libraryclass  This library provides an interface to request non-MMRAM pages to be mapped\r
+  #                  or unblocked from inside MM environment.\r
+  #\r
+  MmUnblockMemoryLib|Include/Library/MmUnblockMemoryLib.h\r
+\r
 [LibraryClasses.IA32, LibraryClasses.X64]\r
   ##  @libraryclass  Abstracts both S/W SMI generation and detection.\r
   ##\r
index ce009086815f3b6c812c3585cfe24fa61e436210..79629e3f93baca739bb7a7ce32377f5701fbf5db 100644 (file)
   MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf\r
   MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.inf\r
   MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf\r
+  MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf\r
 \r
 [Components.EBC]\r
   MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r