]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
authorArd Biesheuvel <ard.biesheuvel@arm.com>
Sat, 18 Apr 2020 16:45:13 +0000 (18:45 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 12 May 2020 19:23:44 +0000 (19:23 +0000)
The MM communicate 2 protocol was introduced to factor out the mismatch
between traditional MM, which requires the physical address of the MM
buffer to be passed, and standalone MM, which copies the MM communicate
buffer data into a separate buffer, requiring the virtual address. For
this reason, MM communicate 2 carries both addresses, allowing the
implementation to decide which address it needs.

This hides this implementation detail from the callers of the protocol,
which simply passes both addresses without having to reason about what the
implementation of the protocol actually needs.

Note that the old version of the protocol is retained, in order to support
existing implementations that don't require this flexibility.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf

index 20b84eaee2772409d4ea5bc1eb30ea4b525e937b..0385f1d4bdeea037a8daa24e3bc4816bcaa64338 100644 (file)
@@ -10,6 +10,7 @@
 \r
 #include <Protocol/SmmBase2.h>\r
 #include <Protocol/SmmCommunication.h>\r
 \r
 #include <Protocol/SmmBase2.h>\r
 #include <Protocol/SmmCommunication.h>\r
+#include <Protocol/MmCommunication2.h>\r
 #include <Protocol/SmmAccess2.h>\r
 #include <Protocol/SmmConfiguration.h>\r
 #include <Protocol/SmmControl2.h>\r
 #include <Protocol/SmmAccess2.h>\r
 #include <Protocol/SmmConfiguration.h>\r
 #include <Protocol/SmmControl2.h>\r
@@ -118,6 +119,39 @@ SmmCommunicationCommunicate (
   IN OUT UINTN                             *CommSize OPTIONAL\r
   );\r
 \r
   IN OUT UINTN                             *CommSize OPTIONAL\r
   );\r
 \r
+/**\r
+  Communicates with a registered handler.\r
+\r
+  This function provides a service to send and receive messages from a registered UEFI service.\r
+\r
+  @param[in] This                The EFI_MM_COMMUNICATION_PROTOCOL instance.\r
+  @param[in] CommBufferPhysical  Physical address of the MM communication buffer\r
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer\r
+  @param[in] CommSize            The size of the data buffer being passed in. On exit, the size of data\r
+                                 being returned. Zero if the handler does not wish to reply with any data.\r
+                                 This parameter is optional and may be NULL.\r
+\r
+  @retval EFI_SUCCESS            The message was successfully posted.\r
+  @retval EFI_INVALID_PARAMETER  The CommBuffer was NULL.\r
+  @retval EFI_BAD_BUFFER_SIZE    The buffer is too large for the MM implementation.\r
+                                 If this error is returned, the MessageLength field\r
+                                 in the CommBuffer header or the integer pointed by\r
+                                 CommSize, are updated to reflect the maximum payload\r
+                                 size the implementation can accommodate.\r
+  @retval EFI_ACCESS_DENIED      The CommunicateBuffer parameter or CommSize parameter,\r
+                                 if not omitted, are in address range that cannot be\r
+                                 accessed by the MM environment.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmCommunicationMmCommunicate2 (\r
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,\r
+  IN OUT VOID                               *CommBufferPhysical,\r
+  IN OUT VOID                               *CommBufferVirtual,\r
+  IN OUT UINTN                              *CommSize OPTIONAL\r
+  );\r
+\r
 /**\r
   Event notification that is fired every time a gEfiSmmConfigurationProtocol installs.\r
 \r
 /**\r
   Event notification that is fired every time a gEfiSmmConfigurationProtocol installs.\r
 \r
@@ -240,6 +274,13 @@ EFI_SMM_COMMUNICATION_PROTOCOL  mSmmCommunication = {
   SmmCommunicationCommunicate\r
 };\r
 \r
   SmmCommunicationCommunicate\r
 };\r
 \r
+//\r
+// PI 1.7 MM Communication Protocol 2 instance\r
+//\r
+EFI_MM_COMMUNICATION2_PROTOCOL  mMmCommunication2 = {\r
+  SmmCommunicationMmCommunicate2\r
+};\r
+\r
 //\r
 // SMM Core Private Data structure that contains the data shared between\r
 // the SMM IPL and the SMM Core.\r
 //\r
 // SMM Core Private Data structure that contains the data shared between\r
 // the SMM IPL and the SMM Core.\r
@@ -576,6 +617,44 @@ SmmCommunicationCommunicate (
   return (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;\r
 }\r
 \r
   return (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;\r
 }\r
 \r
+/**\r
+  Communicates with a registered handler.\r
+\r
+  This function provides a service to send and receive messages from a registered UEFI service.\r
+\r
+  @param[in] This                The EFI_MM_COMMUNICATION_PROTOCOL instance.\r
+  @param[in] CommBufferPhysical  Physical address of the MM communication buffer\r
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer\r
+  @param[in] CommSize            The size of the data buffer being passed in. On exit, the size of data\r
+                                 being returned. Zero if the handler does not wish to reply with any data.\r
+                                 This parameter is optional and may be NULL.\r
+\r
+  @retval EFI_SUCCESS            The message was successfully posted.\r
+  @retval EFI_INVALID_PARAMETER  The CommBuffer was NULL.\r
+  @retval EFI_BAD_BUFFER_SIZE    The buffer is too large for the MM implementation.\r
+                                 If this error is returned, the MessageLength field\r
+                                 in the CommBuffer header or the integer pointed by\r
+                                 CommSize, are updated to reflect the maximum payload\r
+                                 size the implementation can accommodate.\r
+  @retval EFI_ACCESS_DENIED      The CommunicateBuffer parameter or CommSize parameter,\r
+                                 if not omitted, are in address range that cannot be\r
+                                 accessed by the MM environment.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmCommunicationMmCommunicate2 (\r
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,\r
+  IN OUT VOID                               *CommBufferPhysical,\r
+  IN OUT VOID                               *CommBufferVirtual,\r
+  IN OUT UINTN                              *CommSize OPTIONAL\r
+  )\r
+{\r
+  return SmmCommunicationCommunicate (&mSmmCommunication,\r
+                                      CommBufferPhysical,\r
+                                      CommSize);\r
+}\r
+\r
 /**\r
   Event notification that is fired when GUIDed Event Group is signaled.\r
 \r
 /**\r
   Event notification that is fired when GUIDed Event Group is signaled.\r
 \r
@@ -1758,6 +1837,7 @@ SmmIplEntry (
                   &mSmmIplHandle,\r
                   &gEfiSmmBase2ProtocolGuid,         &mSmmBase2,\r
                   &gEfiSmmCommunicationProtocolGuid, &mSmmCommunication,\r
                   &mSmmIplHandle,\r
                   &gEfiSmmBase2ProtocolGuid,         &mSmmBase2,\r
                   &gEfiSmmCommunicationProtocolGuid, &mSmmCommunication,\r
+                  &gEfiMmCommunication2ProtocolGuid, &mMmCommunication2,\r
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
index 619603d6c2a0e30cc2fc13c5224c7443566d33e8..6109d6b5449c080337cba4cfea3146d206e90a98 100644 (file)
@@ -50,6 +50,7 @@
 [Protocols]\r
   gEfiSmmBase2ProtocolGuid                      ## PRODUCES\r
   gEfiSmmCommunicationProtocolGuid              ## PRODUCES\r
 [Protocols]\r
   gEfiSmmBase2ProtocolGuid                      ## PRODUCES\r
   gEfiSmmCommunicationProtocolGuid              ## PRODUCES\r
+  gEfiMmCommunication2ProtocolGuid              ## PRODUCES\r
   gEfiSmmAccess2ProtocolGuid                    ## CONSUMES\r
   ## NOTIFY\r
   ## CONSUMES\r
   gEfiSmmAccess2ProtocolGuid                    ## CONSUMES\r
   ## NOTIFY\r
   ## CONSUMES\r