public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
@ 2020-05-06 17:27 Ard Biesheuvel
  2020-05-06 17:27 ` [PATCH resend 1/7] MdePkg: introduce MM communicate 2 protocol Ard Biesheuvel
                   ` (7 more replies)
  0 siblings, 8 replies; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-06 17:27 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Michael D Kinney, Liming Gao, Jian J Wang,
	Hao A Wu, Leif Lindholm, Sami Mujawar, Jiewen Yao

Now that version 1.7 errata A of the PI spec has finally been released,
we can take another look at this series, which incorporates the new MM
communicate2 protocol definition, updates the producers for conventional
SMM and standalone MM, and updates the variable store components to consume
the new version of the protocol. This solves a long standing compatibility
issue which made standalone MM fundamentally incompatible with a virtually
remapped address space as installed by SetVirtualAddressMap().

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>

Ard Biesheuvel (7):
  MdePkg: introduce MM communicate 2 protocol
  MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
  ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol
  MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol
  MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2
  MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2
  StandaloneMmPkg: switch to MM communicate 2 protocol

 .../MmCommunicationDxe/MmCommunication.c      | 81 +++++++++----------
 .../MmCommunicationDxe/MmCommunication.inf    |  6 +-
 .../Application/VariableInfo/VariableInfo.c   | 19 +++--
 .../Application/VariableInfo/VariableInfo.inf |  2 +-
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c        | 80 ++++++++++++++++++
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf      |  1 +
 MdeModulePkg/Include/Guid/SmmVariableCommon.h |  6 +-
 .../FaultTolerantWriteSmmCommon.h             |  2 +-
 .../FaultTolerantWriteSmmDxe.c                | 25 +++---
 .../FaultTolerantWriteSmmDxe.h                |  2 +-
 .../FaultTolerantWriteSmmDxe.inf              |  4 +-
 .../RuntimeDxe/VariableSmmRuntimeDxe.c        | 39 ++++-----
 .../RuntimeDxe/VariableSmmRuntimeDxe.inf      |  4 +-
 MdePkg/Include/Protocol/MmCommunication2.h    | 69 ++++++++++++++++
 MdePkg/MdePkg.dec                             |  7 ++
 StandaloneMmPkg/Core/StandaloneMmCore.h       |  2 +-
 .../StandaloneMmCpu/AArch64/StandaloneMmCpu.h |  2 +-
 17 files changed, 256 insertions(+), 95 deletions(-)
 create mode 100644 MdePkg/Include/Protocol/MmCommunication2.h

-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH resend 1/7] MdePkg: introduce MM communicate 2 protocol
  2020-05-06 17:27 [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Ard Biesheuvel
@ 2020-05-06 17:27 ` Ard Biesheuvel
  2020-05-12 17:09   ` [edk2-devel] " Sami Mujawar
  2020-05-06 17:27 ` [PATCH resend 2/7] MdeModulePkg/SmmIpl: expose " Ard Biesheuvel
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-06 17:27 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Michael D Kinney, Liming Gao, Jian J Wang,
	Hao A Wu, Leif Lindholm, Sami Mujawar, Jiewen Yao

Add the protocol definition of the MM communicate 2 protocol,
which has been introduced by version 1.7 errata A of the PI spec.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 MdePkg/Include/Protocol/MmCommunication2.h | 69 ++++++++++++++++++++
 MdePkg/MdePkg.dec                          |  7 ++
 2 files changed, 76 insertions(+)

diff --git a/MdePkg/Include/Protocol/MmCommunication2.h b/MdePkg/Include/Protocol/MmCommunication2.h
new file mode 100644
index 000000000000..05f56dcae53e
--- /dev/null
+++ b/MdePkg/Include/Protocol/MmCommunication2.h
@@ -0,0 +1,69 @@
+/** @file
+  EFI MM Communication Protocol 2 as defined in the PI 1.7 errata A specification.
+
+  This protocol provides a means of communicating between drivers outside of MM and MMI
+  handlers inside of MM.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _MM_COMMUNICATION2_H_
+#define _MM_COMMUNICATION2_H_
+
+#include <Protocol/MmCommunication.h>
+
+#define EFI_MM_COMMUNICATION2_PROTOCOL_GUID \
+  { \
+    0x378daedc, 0xf06b, 0x4446, { 0x83, 0x14, 0x40, 0xab, 0x93, 0x3c, 0x87, 0xa3 } \
+  }
+
+typedef struct _EFI_MM_COMMUNICATION2_PROTOCOL  EFI_MM_COMMUNICATION2_PROTOCOL;
+
+/**
+  Communicates with a registered handler.
+
+  This function provides a service to send and receive messages from a registered UEFI service.
+
+  @param[in] This                The EFI_MM_COMMUNICATION_PROTOCOL instance.
+  @param[in] CommBufferPhysical  Physical address of the MM communication buffer
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer
+  @param[in] CommSize            The size of the data buffer being passed in. On exit, the size of data
+                                 being returned. Zero if the handler does not wish to reply with any data.
+                                 This parameter is optional and may be NULL.
+
+  @retval EFI_SUCCESS            The message was successfully posted.
+  @retval EFI_INVALID_PARAMETER  CommBufferPhysical was NULL or CommBufferVirtual was NULL.
+  @retval EFI_BAD_BUFFER_SIZE    The buffer is too large for the MM implementation.
+                                 If this error is returned, the MessageLength field
+                                 in the CommBuffer header or the integer pointed by
+                                 CommSize, are updated to reflect the maximum payload
+                                 size the implementation can accommodate.
+  @retval EFI_ACCESS_DENIED      The CommunicateBuffer parameter or CommSize parameter,
+                                 if not omitted, are in address range that cannot be
+                                 accessed by the MM environment.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MM_COMMUNICATE2)(
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,
+  IN OUT VOID                               *CommBufferPhysical,
+  IN OUT VOID                               *CommBufferVirtual,
+  IN OUT UINTN                              *CommSize OPTIONAL
+  );
+
+///
+/// EFI MM Communication Protocol provides runtime services for communicating
+/// between DXE drivers and a registered MMI handler.
+///
+struct _EFI_MM_COMMUNICATION2_PROTOCOL {
+  EFI_MM_COMMUNICATE2  Communicate;
+};
+
+extern EFI_GUID gEfiMmCommunication2ProtocolGuid;
+
+#endif
+
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 6c37c2181c62..e2a79dd85db6 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -1277,6 +1277,13 @@ [Protocols]
   ## Include/Protocol/SpiSmmNorFlash.h
   gEfiSpiSmmNorFlashProtocolGuid         = { 0xaab18f19, 0xfe14, 0x4666, { 0x86, 0x04, 0x87, 0xff, 0x6d, 0x66, 0x2c, 0x9a }}
 
+  #
+  # Protocols defined in PI 1.7.
+  #
+
+  ## Include/Protocol/MmCommunication2.h
+  gEfiMmCommunication2ProtocolGuid  = { 0x378daedc, 0xf06b, 0x4446, { 0x83, 0x14, 0x40, 0xab, 0x93, 0x3c, 0x87, 0xa3 }}
+
   #
   # Protocols defined in UEFI2.1/UEFI2.0/EFI1.1
   #
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH resend 2/7] MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
  2020-05-06 17:27 [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Ard Biesheuvel
  2020-05-06 17:27 ` [PATCH resend 1/7] MdePkg: introduce MM communicate 2 protocol Ard Biesheuvel
@ 2020-05-06 17:27 ` Ard Biesheuvel
  2020-05-12 17:09   ` [edk2-devel] " Sami Mujawar
  2020-05-06 17:27 ` [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate " Ard Biesheuvel
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-06 17:27 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Michael D Kinney, Liming Gao, Jian J Wang,
	Hao A Wu, Leif Lindholm, Sami Mujawar, Jiewen Yao

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>
---
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c   | 80 ++++++++++++++++++++
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf |  1 +
 2 files changed, 81 insertions(+)

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


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol
  2020-05-06 17:27 [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Ard Biesheuvel
  2020-05-06 17:27 ` [PATCH resend 1/7] MdePkg: introduce MM communicate 2 protocol Ard Biesheuvel
  2020-05-06 17:27 ` [PATCH resend 2/7] MdeModulePkg/SmmIpl: expose " Ard Biesheuvel
@ 2020-05-06 17:27 ` Ard Biesheuvel
  2020-05-12  9:30   ` Leif Lindholm
  2020-05-12 17:21   ` [edk2-devel] " Sami Mujawar
  2020-05-06 17:27 ` [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate " Ard Biesheuvel
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-06 17:27 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Michael D Kinney, Liming Gao, Jian J Wang,
	Hao A Wu, Leif Lindholm, Sami Mujawar, Jiewen Yao

Implement the new MmCommunication2 protocol which supports the use
of standalone MM at runtime inside an address space that has been
virtually remapped by the OS.

Note that the implementation of the old MM Communicate protocol is
removed: it never worked correctly so there is no point in keeping it.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c   | 81 +++++++++-----------
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf |  6 +-
 2 files changed, 41 insertions(+), 46 deletions(-)

diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index a9e06be1adc2..9457eaf1d809 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2016-2018, ARM Limited. All rights reserved.
+  Copyright (c) 2016-2020, ARM Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -16,7 +16,7 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiRuntimeServicesTableLib.h>
 
-#include <Protocol/MmCommunication.h>
+#include <Protocol/MmCommunication2.h>
 
 #include <IndustryStandard/ArmStdSmc.h>
 
@@ -39,39 +39,34 @@ STATIC EFI_HANDLE  mMmCommunicateHandle;
 /**
   Communicates with a registered handler.
 
-  This function provides an interface to send and receive messages to the
-  Standalone MM environment on behalf of UEFI services.  This function is part
-  of the MM Communication Protocol that may be called in physical mode prior to
-  SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap().
+  This function provides a service to send and receive messages from a registered UEFI service.
 
-  @param[in]      This                The EFI_MM_COMMUNICATION_PROTOCOL
-                                      instance.
-  @param[in, out] CommBuffer          A pointer to the buffer to convey
-                                      into MMRAM.
-  @param[in, out] CommSize            The size of the data buffer being
-                                      passed in. This is optional.
+  @param[in] This                The EFI_MM_COMMUNICATION_PROTOCOL instance.
+  @param[in] CommBufferPhysical  Physical address of the MM communication buffer
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer
+  @param[in] CommSize            The size of the data buffer being passed in. On exit, the size of data
+                                 being returned. Zero if the handler does not wish to reply with any data.
+                                 This parameter is optional and may be NULL.
+
+  @retval EFI_SUCCESS            The message was successfully posted.
+  @retval EFI_INVALID_PARAMETER  CommBufferPhysical was NULL or CommBufferVirtual was NULL.
+  @retval EFI_BAD_BUFFER_SIZE    The buffer is too large for the MM implementation.
+                                 If this error is returned, the MessageLength field
+                                 in the CommBuffer header or the integer pointed by
+                                 CommSize, are updated to reflect the maximum payload
+                                 size the implementation can accommodate.
+  @retval EFI_ACCESS_DENIED      The CommunicateBuffer parameter or CommSize parameter,
+                                 if not omitted, are in address range that cannot be
+                                 accessed by the MM environment.
 
-  @retval EFI_SUCCESS                 The message was successfully posted.
-  @retval EFI_INVALID_PARAMETER       The CommBuffer was NULL.
-  @retval EFI_BAD_BUFFER_SIZE         The buffer size is incorrect for the MM
-                                      implementation. If this error is
-                                      returned, the MessageLength field in
-                                      the CommBuffer header or the integer
-                                      pointed by CommSize are updated to reflect
-                                      the maximum payload size the
-                                      implementation can accommodate.
-  @retval EFI_ACCESS_DENIED           The CommunicateBuffer parameter
-                                      or CommSize parameter, if not omitted,
-                                      are in address range that cannot be
-                                      accessed by the MM environment
 **/
-STATIC
 EFI_STATUS
 EFIAPI
-MmCommunicationCommunicate (
-  IN CONST EFI_MM_COMMUNICATION_PROTOCOL  *This,
-  IN OUT VOID                             *CommBuffer,
-  IN OUT UINTN                            *CommSize OPTIONAL
+MmCommunication2Communicate (
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,
+  IN OUT VOID                               *CommBufferPhysical,
+  IN OUT VOID                               *CommBufferVirtual,
+  IN OUT UINTN                              *CommSize OPTIONAL
   )
 {
   EFI_MM_COMMUNICATE_HEADER   *CommunicateHeader;
@@ -87,11 +82,11 @@ MmCommunicationCommunicate (
   //
   // Check parameters
   //
-  if (CommBuffer == NULL) {
+  if (CommBufferVirtual == NULL) {
     return EFI_INVALID_PARAMETER;
   }
 
-  CommunicateHeader = CommBuffer;
+  CommunicateHeader = CommBufferVirtual;
   // CommBuffer is a mandatory parameter. Hence, Rely on
   // MessageLength + Header to ascertain the
   // total size of the communication payload rather than
@@ -136,7 +131,7 @@ MmCommunicationCommunicate (
   CommunicateSmcArgs.Arg1 = 0;
 
   // Copy Communication Payload
-  CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBuffer, BufferSize);
+  CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBufferVirtual, BufferSize);
 
   // comm_buffer_address (64-bit physical address)
   CommunicateSmcArgs.Arg2 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
@@ -149,7 +144,7 @@ MmCommunicationCommunicate (
 
   switch (CommunicateSmcArgs.Arg0) {
   case ARM_SMC_MM_RET_SUCCESS:
-    ZeroMem (CommBuffer, BufferSize);
+    ZeroMem (CommBufferVirtual, BufferSize);
     // On successful return, the size of data being returned is inferred from
     // MessageLength + Header.
     CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
@@ -158,7 +153,7 @@ MmCommunicationCommunicate (
                  sizeof (CommunicateHeader->MessageLength);
 
     CopyMem (
-      CommBuffer,
+      CommBufferVirtual,
       (VOID *)mNsCommBuffMemRegion.VirtualBase,
       BufferSize
       );
@@ -191,8 +186,8 @@ MmCommunicationCommunicate (
 //
 // MM Communication Protocol instance
 //
-EFI_MM_COMMUNICATION_PROTOCOL  mMmCommunication = {
-  MmCommunicationCommunicate
+STATIC EFI_MM_COMMUNICATION2_PROTOCOL  mMmCommunication2 = {
+  MmCommunication2Communicate
 };
 
 /**
@@ -293,7 +288,7 @@ MmGuidedEventNotify (
   Header.Data[0] = 0;
 
   Size = sizeof (Header);
-  MmCommunicationCommunicate (&mMmCommunication, &Header, &Size);
+  MmCommunication2Communicate (&mMmCommunication2, &Header, &Header, &Size);
 }
 
 /**
@@ -312,7 +307,7 @@ MmGuidedEventNotify (
 **/
 EFI_STATUS
 EFIAPI
-MmCommunicationInitialize (
+MmCommunication2Initialize (
   IN EFI_HANDLE         ImageHandle,
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
@@ -363,9 +358,9 @@ MmCommunicationInitialize (
   // Install the communication protocol
   Status = gBS->InstallProtocolInterface (
                   &mMmCommunicateHandle,
-                  &gEfiMmCommunicationProtocolGuid,
+                  &gEfiMmCommunication2ProtocolGuid,
                   EFI_NATIVE_INTERFACE,
-                  &mMmCommunication
+                  &mMmCommunication2
                   );
   if (EFI_ERROR(Status)) {
     DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: "
@@ -402,8 +397,8 @@ MmCommunicationInitialize (
 UninstallProtocol:
   gBS->UninstallProtocolInterface (
          mMmCommunicateHandle,
-         &gEfiMmCommunicationProtocolGuid,
-         &mMmCommunication
+         &gEfiMmCommunication2ProtocolGuid,
+         &mMmCommunication2
          );
 
 CleanAddedMemorySpace:
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
index 505228704ea5..2465fb77c58e 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
@@ -2,7 +2,7 @@
 #
 #  DXE MM Communicate driver
 #
-#  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+#  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -14,7 +14,7 @@ [Defines]
   FILE_GUID                      = 09EE81D3-F15E-43F4-85B4-CB9873DA5D6B
   MODULE_TYPE                    = DXE_RUNTIME_DRIVER
   VERSION_STRING                 = 1.0
-  ENTRY_POINT                    = MmCommunicationInitialize
+  ENTRY_POINT                    = MmCommunication2Initialize
 
 #
 # The following is for reference only and not required by
@@ -40,7 +40,7 @@ [LibraryClasses]
   UefiDriverEntryPoint
 
 [Protocols]
-  gEfiMmCommunicationProtocolGuid              ## PRODUCES
+  gEfiMmCommunication2ProtocolGuid              ## PRODUCES
 
 [Guids]
   gEfiEndOfDxeEventGroupGuid
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol
  2020-05-06 17:27 [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Ard Biesheuvel
                   ` (2 preceding siblings ...)
  2020-05-06 17:27 ` [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate " Ard Biesheuvel
@ 2020-05-06 17:27 ` Ard Biesheuvel
  2020-05-06 17:53   ` [EXTERNAL] [edk2-devel] " Bret Barkelew
  2020-05-12 17:10   ` Sami Mujawar
  2020-05-06 17:27 ` [PATCH resend 5/7] MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2 Ard Biesheuvel
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-06 17:27 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Michael D Kinney, Liming Gao, Jian J Wang,
	Hao A Wu, Leif Lindholm, Sami Mujawar, Jiewen Yao

Switch to the new MM communicate 2 protocol which supports both
traditional and standalone MM.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 MdeModulePkg/Application/VariableInfo/VariableInfo.c   | 19 +++++++++++--------
 MdeModulePkg/Application/VariableInfo/VariableInfo.inf |  2 +-
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Application/VariableInfo/VariableInfo.c b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
index c04ba182132f..a7df365b5895 100644
--- a/MdeModulePkg/Application/VariableInfo/VariableInfo.c
+++ b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
@@ -20,10 +20,10 @@
 #include <Guid/VariableFormat.h>
 #include <Guid/SmmVariableCommon.h>
 #include <Guid/PiSmmCommunicationRegionTable.h>
-#include <Protocol/SmmCommunication.h>
+#include <Protocol/MmCommunication2.h>
 #include <Protocol/SmmVariable.h>
 
-EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication = NULL;
+EFI_MM_COMMUNICATION2_PROTOCOL  *mMmCommunication2 = NULL;
 
 /**
   This function get the variable statistics data from SMM variable driver.
@@ -41,7 +41,7 @@ EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication = NULL;
 EFI_STATUS
 EFIAPI
 GetVariableStatisticsData (
-  IN OUT  EFI_SMM_COMMUNICATE_HEADER  *SmmCommunicateHeader,
+  IN OUT  EFI_MM_COMMUNICATE_HEADER   *SmmCommunicateHeader,
   IN OUT  UINTN                       *SmmCommunicateSize
   )
 {
@@ -49,12 +49,15 @@ GetVariableStatisticsData (
   SMM_VARIABLE_COMMUNICATE_HEADER     *SmmVariableFunctionHeader;
 
   CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
-  SmmCommunicateHeader->MessageLength = *SmmCommunicateSize - OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
+  SmmCommunicateHeader->MessageLength = *SmmCommunicateSize - OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);
 
   SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) &SmmCommunicateHeader->Data[0];
   SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_STATISTICS;
 
-  Status = mSmmCommunication->Communicate (mSmmCommunication, SmmCommunicateHeader, SmmCommunicateSize);
+  Status = mMmCommunication2->Communicate (mMmCommunication2,
+                                           SmmCommunicateHeader,
+                                           SmmCommunicateHeader,
+                                           SmmCommunicateSize);
   ASSERT_EFI_ERROR (Status);
 
   Status = SmmVariableFunctionHeader->ReturnStatus;
@@ -76,7 +79,7 @@ PrintInfoFromSmm (
 {
   EFI_STATUS                                     Status;
   VARIABLE_INFO_ENTRY                            *VariableInfo;
-  EFI_SMM_COMMUNICATE_HEADER                     *CommBuffer;
+  EFI_MM_COMMUNICATE_HEADER                      *CommBuffer;
   UINTN                                          RealCommSize;
   UINTN                                          CommSize;
   SMM_VARIABLE_COMMUNICATE_HEADER                *FunctionHeader;
@@ -92,7 +95,7 @@ PrintInfoFromSmm (
     return Status;
   }
 
-  Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication);
+  Status = gBS->LocateProtocol (&gEfiMmCommunication2ProtocolGuid, NULL, (VOID **) &mMmCommunication2);
   if (EFI_ERROR (Status)) {
     return Status;
   }
@@ -117,7 +120,7 @@ PrintInfoFromSmm (
         if (Size > MaxSize) {
           MaxSize = Size;
           RealCommSize = MaxSize;
-          CommBuffer = (EFI_SMM_COMMUNICATE_HEADER *) (UINTN) Entry->PhysicalStart;
+          CommBuffer = (EFI_MM_COMMUNICATE_HEADER *) (UINTN) Entry->PhysicalStart;
         }
       }
     }
diff --git a/MdeModulePkg/Application/VariableInfo/VariableInfo.inf b/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
index 0706ea2ead59..f7c533b54641 100644
--- a/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
+++ b/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
@@ -41,7 +41,7 @@ [LibraryClasses]
   MemoryAllocationLib
 
 [Protocols]
-  gEfiSmmCommunicationProtocolGuid   ## SOMETIMES_CONSUMES
+  gEfiMmCommunication2ProtocolGuid   ## SOMETIMES_CONSUMES
 
   ## UNDEFINED            # Used to do smm communication
   ## SOMETIMES_CONSUMES
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH resend 5/7] MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2
  2020-05-06 17:27 [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Ard Biesheuvel
                   ` (3 preceding siblings ...)
  2020-05-06 17:27 ` [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate " Ard Biesheuvel
@ 2020-05-06 17:27 ` Ard Biesheuvel
  2020-05-12 17:10   ` [edk2-devel] " Sami Mujawar
  2020-05-06 17:27 ` [PATCH resend 6/7] MdeModulePkg/VariableSmmRuntimeDxe: " Ard Biesheuvel
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-06 17:27 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Michael D Kinney, Liming Gao, Jian J Wang,
	Hao A Wu, Leif Lindholm, Sami Mujawar, Jiewen Yao

Switch to the new MM communicate 2 protocol which supports both
traditional and standalone MM.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h |  2 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c    | 25 +++++++++++---------
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.h    |  2 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf  |  4 ++--
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
index 4546a1b445b9..5f0eec0506ed 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
@@ -29,7 +29,7 @@ typedef struct {
 ///
 /// Size of SMM communicate header, without including the payload.
 ///
-#define SMM_COMMUNICATE_HEADER_SIZE  (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data))
+#define SMM_COMMUNICATE_HEADER_SIZE  (OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data))
 
 ///
 /// Size of SMM FTW communicate function header, without including the payload.
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c
index 6e3eb3b58b09..24c20950296d 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c
@@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "FaultTolerantWriteSmmDxe.h"
 
 EFI_HANDLE                         mHandle                   = NULL;
-EFI_SMM_COMMUNICATION_PROTOCOL     *mSmmCommunication        = NULL;
+EFI_MM_COMMUNICATION2_PROTOCOL     *mMmCommunication2        = NULL;
 UINTN                              mPrivateDataSize          = 0;
 
 EFI_FAULT_TOLERANT_WRITE_PROTOCOL  mFaultTolerantWriteDriver = {
@@ -40,7 +40,7 @@ InitCommunicateBuffer (
   IN      UINTN                             Function
   )
 {
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
   SMM_FTW_COMMUNICATE_FUNCTION_HEADER       *SmmFtwFunctionHeader;
 
   //
@@ -74,7 +74,7 @@ InitCommunicateBuffer (
 **/
 EFI_STATUS
 SendCommunicateBuffer (
-  IN OUT  EFI_SMM_COMMUNICATE_HEADER        *SmmCommunicateHeader,
+  IN OUT  EFI_MM_COMMUNICATE_HEADER         *SmmCommunicateHeader,
   IN      UINTN                             DataSize
   )
 {
@@ -83,7 +83,10 @@ SendCommunicateBuffer (
   SMM_FTW_COMMUNICATE_FUNCTION_HEADER       *SmmFtwFunctionHeader;
 
   CommSize = DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_FTW_COMMUNICATE_HEADER_SIZE;
-  Status = mSmmCommunication->Communicate (mSmmCommunication, SmmCommunicateHeader, &CommSize);
+  Status = mMmCommunication2->Communicate (mMmCommunication2,
+                                           SmmCommunicateHeader,
+                                           SmmCommunicateHeader,
+                                           &CommSize);
   ASSERT_EFI_ERROR (Status);
 
   SmmFtwFunctionHeader = (SMM_FTW_COMMUNICATE_FUNCTION_HEADER *) SmmCommunicateHeader->Data;
@@ -148,7 +151,7 @@ FtwGetMaxBlockSize (
 {
   EFI_STATUS                                Status;
   UINTN                                     PayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
   SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER         *SmmFtwBlockSizeHeader;
 
   //
@@ -204,7 +207,7 @@ FtwAllocate (
 {
   EFI_STATUS                                Status;
   UINTN                                     PayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
   SMM_FTW_ALLOCATE_HEADER                   *SmmFtwAllocateHeader;
 
   //
@@ -270,7 +273,7 @@ FtwWrite (
 {
   EFI_STATUS                                Status;
   UINTN                                     PayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
   SMM_FTW_WRITE_HEADER                      *SmmFtwWriteHeader;
 
   //
@@ -336,7 +339,7 @@ FtwRestart (
 {
   EFI_STATUS                                Status;
   UINTN                                     PayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
   SMM_FTW_RESTART_HEADER                    *SmmFtwRestartHeader;
 
   //
@@ -381,7 +384,7 @@ FtwAbort (
   )
 {
   EFI_STATUS                                Status;
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
 
   //
   // Initialize the communicate buffer.
@@ -438,7 +441,7 @@ FtwGetLastWrite (
 {
   EFI_STATUS                                Status;
   UINTN                                     PayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
   SMM_FTW_GET_LAST_WRITE_HEADER             *SmmFtwGetLastWriteHeader;
 
   //
@@ -501,7 +504,7 @@ SmmFtwReady (
     return;
   }
 
-  Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication);
+  Status = gBS->LocateProtocol (&gEfiMmCommunication2ProtocolGuid, NULL, (VOID **) &mMmCommunication2);
   ASSERT_EFI_ERROR (Status);
 
   //
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.h b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.h
index 22df9103d21a..a15644abd731 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.h
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.h
@@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include <PiDxe.h>
 
-#include <Protocol/SmmCommunication.h>
+#include <Protocol/MmCommunication2.h>
 
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiDriverEntryPoint.h>
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf
index f5dc4bb4fee3..f0dd829653f1 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf
@@ -45,7 +45,7 @@ [LibraryClasses]
 
 [Protocols]
   gEfiFaultTolerantWriteProtocolGuid            ## PRODUCES
-  gEfiSmmCommunicationProtocolGuid              ## CONSUMES
+  gEfiMmCommunication2ProtocolGuid              ## CONSUMES
   ## NOTIFY
   ## UNDEFINED # Used to do smm communication
   ## CONSUMES
@@ -53,7 +53,7 @@ [Protocols]
   gEfiFirmwareVolumeBlockProtocolGuid           ## CONSUMES
 
 [Depex]
-  gEfiSmmCommunicationProtocolGuid
+  gEfiMmCommunication2ProtocolGuid
 
 [UserExtensions.TianoCore."ExtraFiles"]
   FaultTolerantWriteSmmDxeExtra.uni
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH resend 6/7] MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2
  2020-05-06 17:27 [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Ard Biesheuvel
                   ` (4 preceding siblings ...)
  2020-05-06 17:27 ` [PATCH resend 5/7] MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2 Ard Biesheuvel
@ 2020-05-06 17:27 ` Ard Biesheuvel
  2020-05-12 17:10   ` [edk2-devel] " Sami Mujawar
  2020-05-06 17:27 ` [PATCH resend 7/7] StandaloneMmPkg: switch to MM communicate 2 protocol Ard Biesheuvel
  2020-05-11 14:08 ` [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Liming Gao
  7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-06 17:27 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Michael D Kinney, Liming Gao, Jian J Wang,
	Hao A Wu, Leif Lindholm, Sami Mujawar, Jiewen Yao

Switch to the new MM communicate 2 protocol which supports both
traditional and standalone MM.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 MdeModulePkg/Include/Guid/SmmVariableCommon.h                        |  6 +--
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c   | 39 +++++++++++---------
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf |  4 +-
 3 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/MdeModulePkg/Include/Guid/SmmVariableCommon.h b/MdeModulePkg/Include/Guid/SmmVariableCommon.h
index ceef44dfd2d7..8ddc94b92da6 100644
--- a/MdeModulePkg/Include/Guid/SmmVariableCommon.h
+++ b/MdeModulePkg/Include/Guid/SmmVariableCommon.h
@@ -20,7 +20,7 @@ extern EFI_GUID gSmmVariableWriteGuid;
 //
 // This structure is used for SMM variable. the collected statistics data is saved in SMRAM. It can be got from
 // SMI handler. The communication buffer should be:
-// EFI_SMM_COMMUNICATE_HEADER + SMM_VARIABLE_COMMUNICATE_HEADER + payload.
+// EFI_MM_COMMUNICATE_HEADER + SMM_VARIABLE_COMMUNICATE_HEADER + payload.
 //
 typedef struct {
   UINTN       Function;
@@ -53,7 +53,7 @@ typedef struct {
 //
 #define SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE       6
 //
-// The payload for this function is VARIABLE_INFO_ENTRY. The GUID in EFI_SMM_COMMUNICATE_HEADER
+// The payload for this function is VARIABLE_INFO_ENTRY. The GUID in EFI_MM_COMMUNICATE_HEADER
 // is gEfiSmmVariableProtocolGuid.
 //
 #define SMM_VARIABLE_FUNCTION_GET_STATISTICS          7
@@ -81,7 +81,7 @@ typedef struct {
 ///
 /// Size of SMM communicate header, without including the payload.
 ///
-#define SMM_COMMUNICATE_HEADER_SIZE  (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data))
+#define SMM_COMMUNICATE_HEADER_SIZE  (OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data))
 
 ///
 /// Size of SMM variable communicate header, without including the payload.
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
index ca833fb0244d..663a1aaa128f 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
@@ -21,7 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <PiDxe.h>
 #include <Protocol/VariableWrite.h>
 #include <Protocol/Variable.h>
-#include <Protocol/SmmCommunication.h>
+#include <Protocol/MmCommunication2.h>
 #include <Protocol/SmmVariable.h>
 #include <Protocol/VariableLock.h>
 #include <Protocol/VarCheck.h>
@@ -45,7 +45,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 EFI_HANDLE                       mHandle                    = NULL;
 EFI_SMM_VARIABLE_PROTOCOL       *mSmmVariable               = NULL;
 EFI_EVENT                        mVirtualAddressChangeEvent = NULL;
-EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication          = NULL;
+EFI_MM_COMMUNICATION2_PROTOCOL  *mMmCommunication2          = NULL;
 UINT8                           *mVariableBuffer            = NULL;
 UINT8                           *mVariableBufferPhysical    = NULL;
 VARIABLE_INFO_ENTRY             *mVariableInfo              = NULL;
@@ -210,7 +210,7 @@ InitCommunicateBuffer (
   IN      UINTN                             Function
   )
 {
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
   SMM_VARIABLE_COMMUNICATE_HEADER           *SmmVariableFunctionHeader;
 
 
@@ -218,7 +218,7 @@ InitCommunicateBuffer (
     return EFI_INVALID_PARAMETER;
   }
 
-  SmmCommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *) mVariableBuffer;
+  SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *) mVariableBuffer;
   CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
   SmmCommunicateHeader->MessageLength = DataSize + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
 
@@ -248,14 +248,17 @@ SendCommunicateBuffer (
 {
   EFI_STATUS                                Status;
   UINTN                                     CommSize;
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
   SMM_VARIABLE_COMMUNICATE_HEADER           *SmmVariableFunctionHeader;
 
   CommSize = DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
-  Status = mSmmCommunication->Communicate (mSmmCommunication, mVariableBufferPhysical, &CommSize);
+  Status = mMmCommunication2->Communicate (mMmCommunication2,
+                                           mVariableBufferPhysical,
+                                           mVariableBuffer,
+                                           &CommSize);
   ASSERT_EFI_ERROR (Status);
 
-  SmmCommunicateHeader      = (EFI_SMM_COMMUNICATE_HEADER *) mVariableBuffer;
+  SmmCommunicateHeader      = (EFI_MM_COMMUNICATE_HEADER *) mVariableBuffer;
   SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
   return  SmmVariableFunctionHeader->ReturnStatus;
 }
@@ -1309,7 +1312,7 @@ VariableAddressChangeEvent (
   )
 {
   EfiConvertPointer (0x0, (VOID **) &mVariableBuffer);
-  EfiConvertPointer (0x0, (VOID **) &mSmmCommunication);
+  EfiConvertPointer (0x0, (VOID **) &mMmCommunication2);
   EfiConvertPointer (EFI_OPTIONAL_PTR, (VOID **) &mVariableRuntimeHobCacheBuffer);
   EfiConvertPointer (EFI_OPTIONAL_PTR, (VOID **) &mVariableRuntimeNvCacheBuffer);
   EfiConvertPointer (EFI_OPTIONAL_PTR, (VOID **) &mVariableRuntimeVolatileCacheBuffer);
@@ -1332,7 +1335,7 @@ GetVariablePayloadSize (
 {
   EFI_STATUS                                Status;
   SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE *SmmGetPayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                 *SmmCommunicateHeader;
   SMM_VARIABLE_COMMUNICATE_HEADER           *SmmVariableFunctionHeader;
   UINTN                                     CommSize;
   UINT8                                     *CommBuffer;
@@ -1357,7 +1360,7 @@ GetVariablePayloadSize (
     goto Done;
   }
 
-  SmmCommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *) CommBuffer;
+  SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *) CommBuffer;
   CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
   SmmCommunicateHeader->MessageLength = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE);
 
@@ -1368,7 +1371,7 @@ GetVariablePayloadSize (
   //
   // Send data to SMM.
   //
-  Status = mSmmCommunication->Communicate (mSmmCommunication, CommBuffer, &CommSize);
+  Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
   ASSERT_EFI_ERROR (Status);
 
   Status = SmmVariableFunctionHeader->ReturnStatus;
@@ -1413,7 +1416,7 @@ GetRuntimeCacheInfo (
 {
   EFI_STATUS                                          Status;
   SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO     *SmmGetRuntimeCacheInfo;
-  EFI_SMM_COMMUNICATE_HEADER                          *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                           *SmmCommunicateHeader;
   SMM_VARIABLE_COMMUNICATE_HEADER                     *SmmVariableFunctionHeader;
   UINTN                                               CommSize;
   UINT8                                               *CommBuffer;
@@ -1434,7 +1437,7 @@ GetRuntimeCacheInfo (
   CommSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO);
   ZeroMem (CommBuffer, CommSize);
 
-  SmmCommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *) CommBuffer;
+  SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *) CommBuffer;
   CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
   SmmCommunicateHeader->MessageLength = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO);
 
@@ -1445,7 +1448,7 @@ GetRuntimeCacheInfo (
   //
   // Send data to SMM.
   //
-  Status = mSmmCommunication->Communicate (mSmmCommunication, CommBuffer, &CommSize);
+  Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
   ASSERT_EFI_ERROR (Status);
   if (CommSize <= SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
     Status = EFI_BAD_BUFFER_SIZE;
@@ -1486,7 +1489,7 @@ SendRuntimeVariableCacheContextToSmm (
 {
   EFI_STATUS                                                Status;
   SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT   *SmmRuntimeVarCacheContext;
-  EFI_SMM_COMMUNICATE_HEADER                                *SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER                                 *SmmCommunicateHeader;
   SMM_VARIABLE_COMMUNICATE_HEADER                           *SmmVariableFunctionHeader;
   UINTN                                                     CommSize;
   UINT8                                                     *CommBuffer;
@@ -1507,7 +1510,7 @@ SendRuntimeVariableCacheContextToSmm (
   CommSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
   ZeroMem (CommBuffer, CommSize);
 
-  SmmCommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *) CommBuffer;
+  SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *) CommBuffer;
   CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
   SmmCommunicateHeader->MessageLength = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
 
@@ -1525,7 +1528,7 @@ SendRuntimeVariableCacheContextToSmm (
   //
   // Send data to SMM.
   //
-  Status = mSmmCommunication->Communicate (mSmmCommunication, CommBuffer, &CommSize);
+  Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
   ASSERT_EFI_ERROR (Status);
   if (CommSize <= SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
     Status = EFI_BAD_BUFFER_SIZE;
@@ -1563,7 +1566,7 @@ SmmVariableReady (
     return;
   }
 
-  Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication);
+  Status = gBS->LocateProtocol (&gEfiMmCommunication2ProtocolGuid, NULL, (VOID **) &mMmCommunication2);
   ASSERT_EFI_ERROR (Status);
 
   //
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
index 592862773390..01564e4c5068 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
@@ -60,7 +60,7 @@ [LibraryClasses]
 [Protocols]
   gEfiVariableWriteArchProtocolGuid             ## PRODUCES
   gEfiVariableArchProtocolGuid                  ## PRODUCES
-  gEfiSmmCommunicationProtocolGuid              ## CONSUMES
+  gEfiMmCommunication2ProtocolGuid              ## CONSUMES
   ## CONSUMES
   ## NOTIFY
   ## UNDEFINED # Used to do smm communication
@@ -100,7 +100,7 @@ [Guids]
   gEfiImageSecurityDatabaseGuid
 
 [Depex]
-  gEfiSmmCommunicationProtocolGuid
+  gEfiMmCommunication2ProtocolGuid
 
 [UserExtensions.TianoCore."ExtraFiles"]
   VariableSmmRuntimeDxeExtra.uni
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH resend 7/7] StandaloneMmPkg: switch to MM communicate 2 protocol
  2020-05-06 17:27 [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Ard Biesheuvel
                   ` (5 preceding siblings ...)
  2020-05-06 17:27 ` [PATCH resend 6/7] MdeModulePkg/VariableSmmRuntimeDxe: " Ard Biesheuvel
@ 2020-05-06 17:27 ` Ard Biesheuvel
  2020-05-12 17:10   ` [edk2-devel] " Sami Mujawar
  2020-05-11 14:08 ` [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Liming Gao
  7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-06 17:27 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Michael D Kinney, Liming Gao, Jian J Wang,
	Hao A Wu, Leif Lindholm, Sami Mujawar, Jiewen Yao

Update the reference to MM communicate to refer to the MM communicate 2
protocol instead. This makes no difference for the MM side of the
implementation, but is more accurate nonetheless, since the original MM
protocol does not work in combination with standalone MM.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 StandaloneMmPkg/Core/StandaloneMmCore.h                           | 2 +-
 StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.h b/StandaloneMmPkg/Core/StandaloneMmCore.h
index 86f6cfa55a35..96c195311add 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.h
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.h
@@ -18,7 +18,7 @@
 #include <Protocol/DxeMmReadyToLock.h>
 #include <Protocol/MmReadyToLock.h>
 #include <Protocol/MmEndOfDxe.h>
-#include <Protocol/MmCommunication.h>
+#include <Protocol/MmCommunication2.h>
 #include <Protocol/LoadedImage.h>
 #include <Protocol/MmConfiguration.h>
 
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h
index 71be5cf17272..47a020c27b95 100644
--- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h
+++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h
@@ -10,7 +10,7 @@
 #ifndef _ARM_TF_CPU_DRIVER_H_
 #define _ARM_TF_CPU_DRIVER_H_
 
-#include <Protocol/MmCommunication.h>
+#include <Protocol/MmCommunication2.h>
 #include <Protocol/MmConfiguration.h>
 #include <Protocol/MmCpu.h>
 #include <Guid/MpInformation.h>
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [EXTERNAL] [edk2-devel] [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol
  2020-05-06 17:27 ` [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate " Ard Biesheuvel
@ 2020-05-06 17:53   ` Bret Barkelew
  2020-05-12 17:10   ` Sami Mujawar
  1 sibling, 0 replies; 21+ messages in thread
From: Bret Barkelew @ 2020-05-06 17:53 UTC (permalink / raw)
  To: devel@edk2.groups.io, ard.biesheuvel@arm.com
  Cc: Ard Biesheuvel, Kinney, Michael D, Liming Gao, Jian J Wang,
	Hao A Wu, Leif Lindholm, Sami Mujawar, Yao, Jiewen

[-- Attachment #1: Type: text/plain, Size: 5051 bytes --]

Note that the VariablePolicy code that is still out for review also uses Mm communication and would need to be updated if it lands first.

- Bret

From: Ard Biesheuvel via groups.io<mailto:ard.biesheuvel=arm.com@groups.io>
Sent: Wednesday, May 6, 2020 10:28 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: Ard Biesheuvel<mailto:ard.biesheuvel@arm.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>; Liming Gao<mailto:liming.gao@intel.com>; Jian J Wang<mailto:jian.j.wang@intel.com>; Hao A Wu<mailto:hao.a.wu@intel.com>; Leif Lindholm<mailto:leif@nuviainc.com>; Sami Mujawar<mailto:sami.mujawar@arm.com>; Yao, Jiewen<mailto:jiewen.yao@intel.com>
Subject: [EXTERNAL] [edk2-devel] [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol

Switch to the new MM communicate 2 protocol which supports both
traditional and standalone MM.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 MdeModulePkg/Application/VariableInfo/VariableInfo.c   | 19 +++++++++++--------
 MdeModulePkg/Application/VariableInfo/VariableInfo.inf |  2 +-
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Application/VariableInfo/VariableInfo.c b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
index c04ba182132f..a7df365b5895 100644
--- a/MdeModulePkg/Application/VariableInfo/VariableInfo.c
+++ b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
@@ -20,10 +20,10 @@
 #include <Guid/VariableFormat.h>
 #include <Guid/SmmVariableCommon.h>
 #include <Guid/PiSmmCommunicationRegionTable.h>
-#include <Protocol/SmmCommunication.h>
+#include <Protocol/MmCommunication2.h>
 #include <Protocol/SmmVariable.h>

-EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication = NULL;
+EFI_MM_COMMUNICATION2_PROTOCOL  *mMmCommunication2 = NULL;

 /**
   This function get the variable statistics data from SMM variable driver.
@@ -41,7 +41,7 @@ EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication = NULL;
 EFI_STATUS
 EFIAPI
 GetVariableStatisticsData (
-  IN OUT  EFI_SMM_COMMUNICATE_HEADER  *SmmCommunicateHeader,
+  IN OUT  EFI_MM_COMMUNICATE_HEADER   *SmmCommunicateHeader,
   IN OUT  UINTN                       *SmmCommunicateSize
   )
 {
@@ -49,12 +49,15 @@ GetVariableStatisticsData (
   SMM_VARIABLE_COMMUNICATE_HEADER     *SmmVariableFunctionHeader;

   CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
-  SmmCommunicateHeader->MessageLength = *SmmCommunicateSize - OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
+  SmmCommunicateHeader->MessageLength = *SmmCommunicateSize - OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);

   SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) &SmmCommunicateHeader->Data[0];
   SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_STATISTICS;

-  Status = mSmmCommunication->Communicate (mSmmCommunication, SmmCommunicateHeader, SmmCommunicateSize);
+  Status = mMmCommunication2->Communicate (mMmCommunication2,
+                                           SmmCommunicateHeader,
+                                           SmmCommunicateHeader,
+                                           SmmCommunicateSize);
   ASSERT_EFI_ERROR (Status);

   Status = SmmVariableFunctionHeader->ReturnStatus;
@@ -76,7 +79,7 @@ PrintInfoFromSmm (
 {
   EFI_STATUS                                     Status;
   VARIABLE_INFO_ENTRY                            *VariableInfo;
-  EFI_SMM_COMMUNICATE_HEADER                     *CommBuffer;
+  EFI_MM_COMMUNICATE_HEADER                      *CommBuffer;
   UINTN                                          RealCommSize;
   UINTN                                          CommSize;
   SMM_VARIABLE_COMMUNICATE_HEADER                *FunctionHeader;
@@ -92,7 +95,7 @@ PrintInfoFromSmm (
     return Status;
   }

-  Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication);
+  Status = gBS->LocateProtocol (&gEfiMmCommunication2ProtocolGuid, NULL, (VOID **) &mMmCommunication2);
   if (EFI_ERROR (Status)) {
     return Status;
   }
@@ -117,7 +120,7 @@ PrintInfoFromSmm (
         if (Size > MaxSize) {
           MaxSize = Size;
           RealCommSize = MaxSize;
-          CommBuffer = (EFI_SMM_COMMUNICATE_HEADER *) (UINTN) Entry->PhysicalStart;
+          CommBuffer = (EFI_MM_COMMUNICATE_HEADER *) (UINTN) Entry->PhysicalStart;
         }
       }
     }
diff --git a/MdeModulePkg/Application/VariableInfo/VariableInfo.inf b/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
index 0706ea2ead59..f7c533b54641 100644
--- a/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
+++ b/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
@@ -41,7 +41,7 @@ [LibraryClasses]
   MemoryAllocationLib

 [Protocols]
-  gEfiSmmCommunicationProtocolGuid   ## SOMETIMES_CONSUMES
+  gEfiMmCommunication2ProtocolGuid   ## SOMETIMES_CONSUMES

   ## UNDEFINED            # Used to do smm communication
   ## SOMETIMES_CONSUMES
--
2.17.1





[-- Attachment #2: Type: text/html, Size: 10229 bytes --]

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
  2020-05-06 17:27 [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Ard Biesheuvel
                   ` (6 preceding siblings ...)
  2020-05-06 17:27 ` [PATCH resend 7/7] StandaloneMmPkg: switch to MM communicate 2 protocol Ard Biesheuvel
@ 2020-05-11 14:08 ` Liming Gao
  2020-05-11 14:09   ` Ard Biesheuvel
  7 siblings, 1 reply; 21+ messages in thread
From: Liming Gao @ 2020-05-11 14:08 UTC (permalink / raw)
  To: devel@edk2.groups.io, ard.biesheuvel@arm.com
  Cc: Kinney, Michael D, Wang, Jian J, Wu, Hao A, Leif Lindholm,
	Sami Mujawar, Yao, Jiewen

Ard:
  I see this change updates VariableSmmRuntimeDxe to consume mMmCommunication2 with mVariableBufferPhysical and mVariableBuffer for physical and virtual. 
  But, FaultTolerantWriteSmmDxe consumes mMmCommunication2 with the same SmmCommunicateHeader for physical and virtual. 

  Is there any difference between them?

Thanks
Liming
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ard Biesheuvel
> Sent: Thursday, May 7, 2020 1:27 AM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Leif Lindholm
> <leif@nuviainc.com>; Sami Mujawar <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
> 
> Now that version 1.7 errata A of the PI spec has finally been released,
> we can take another look at this series, which incorporates the new MM
> communicate2 protocol definition, updates the producers for conventional
> SMM and standalone MM, and updates the variable store components to consume
> the new version of the protocol. This solves a long standing compatibility
> issue which made standalone MM fundamentally incompatible with a virtually
> remapped address space as installed by SetVirtualAddressMap().
> 
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> 
> Ard Biesheuvel (7):
>   MdePkg: introduce MM communicate 2 protocol
>   MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
>   ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol
>   MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol
>   MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2
>   MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2
>   StandaloneMmPkg: switch to MM communicate 2 protocol
> 
>  .../MmCommunicationDxe/MmCommunication.c      | 81 +++++++++----------
>  .../MmCommunicationDxe/MmCommunication.inf    |  6 +-
>  .../Application/VariableInfo/VariableInfo.c   | 19 +++--
>  .../Application/VariableInfo/VariableInfo.inf |  2 +-
>  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c        | 80 ++++++++++++++++++
>  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf      |  1 +
>  MdeModulePkg/Include/Guid/SmmVariableCommon.h |  6 +-
>  .../FaultTolerantWriteSmmCommon.h             |  2 +-
>  .../FaultTolerantWriteSmmDxe.c                | 25 +++---
>  .../FaultTolerantWriteSmmDxe.h                |  2 +-
>  .../FaultTolerantWriteSmmDxe.inf              |  4 +-
>  .../RuntimeDxe/VariableSmmRuntimeDxe.c        | 39 ++++-----
>  .../RuntimeDxe/VariableSmmRuntimeDxe.inf      |  4 +-
>  MdePkg/Include/Protocol/MmCommunication2.h    | 69 ++++++++++++++++
>  MdePkg/MdePkg.dec                             |  7 ++
>  StandaloneMmPkg/Core/StandaloneMmCore.h       |  2 +-
>  .../StandaloneMmCpu/AArch64/StandaloneMmCpu.h |  2 +-
>  17 files changed, 256 insertions(+), 95 deletions(-)
>  create mode 100644 MdePkg/Include/Protocol/MmCommunication2.h
> 
> --
> 2.17.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
  2020-05-11 14:08 ` [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Liming Gao
@ 2020-05-11 14:09   ` Ard Biesheuvel
  2020-05-11 14:32     ` Liming Gao
  0 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-11 14:09 UTC (permalink / raw)
  To: Gao, Liming, devel@edk2.groups.io
  Cc: Kinney, Michael D, Wang, Jian J, Wu, Hao A, Leif Lindholm,
	Sami Mujawar, Yao, Jiewen

On 5/11/20 4:08 PM, Gao, Liming wrote:
> Ard:
>    I see this change updates VariableSmmRuntimeDxe to consume mMmCommunication2 with mVariableBufferPhysical and mVariableBuffer for physical and virtual.
>    But, FaultTolerantWriteSmmDxe consumes mMmCommunication2 with the same SmmCommunicateHeader for physical and virtual.
> 
>    Is there any difference between them?
> 

Yes. The FTW code never executes at runtime, so it is guaranteed that 
physical == virtual.


>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ard Biesheuvel
>> Sent: Thursday, May 7, 2020 1:27 AM
>> To: devel@edk2.groups.io
>> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
>> <liming.gao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Leif Lindholm
>> <leif@nuviainc.com>; Sami Mujawar <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>
>> Subject: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
>>
>> Now that version 1.7 errata A of the PI spec has finally been released,
>> we can take another look at this series, which incorporates the new MM
>> communicate2 protocol definition, updates the producers for conventional
>> SMM and standalone MM, and updates the variable store components to consume
>> the new version of the protocol. This solves a long standing compatibility
>> issue which made standalone MM fundamentally incompatible with a virtually
>> remapped address space as installed by SetVirtualAddressMap().
>>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Jian J Wang <jian.j.wang@intel.com>
>> Cc: Hao A Wu <hao.a.wu@intel.com>
>> Cc: Leif Lindholm <leif@nuviainc.com>
>> Cc: Sami Mujawar <sami.mujawar@arm.com>
>> Cc: Jiewen Yao <jiewen.yao@intel.com>
>>
>> Ard Biesheuvel (7):
>>    MdePkg: introduce MM communicate 2 protocol
>>    MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
>>    ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol
>>    MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol
>>    MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2
>>    MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2
>>    StandaloneMmPkg: switch to MM communicate 2 protocol
>>
>>   .../MmCommunicationDxe/MmCommunication.c      | 81 +++++++++----------
>>   .../MmCommunicationDxe/MmCommunication.inf    |  6 +-
>>   .../Application/VariableInfo/VariableInfo.c   | 19 +++--
>>   .../Application/VariableInfo/VariableInfo.inf |  2 +-
>>   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c        | 80 ++++++++++++++++++
>>   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf      |  1 +
>>   MdeModulePkg/Include/Guid/SmmVariableCommon.h |  6 +-
>>   .../FaultTolerantWriteSmmCommon.h             |  2 +-
>>   .../FaultTolerantWriteSmmDxe.c                | 25 +++---
>>   .../FaultTolerantWriteSmmDxe.h                |  2 +-
>>   .../FaultTolerantWriteSmmDxe.inf              |  4 +-
>>   .../RuntimeDxe/VariableSmmRuntimeDxe.c        | 39 ++++-----
>>   .../RuntimeDxe/VariableSmmRuntimeDxe.inf      |  4 +-
>>   MdePkg/Include/Protocol/MmCommunication2.h    | 69 ++++++++++++++++
>>   MdePkg/MdePkg.dec                             |  7 ++
>>   StandaloneMmPkg/Core/StandaloneMmCore.h       |  2 +-
>>   .../StandaloneMmCpu/AArch64/StandaloneMmCpu.h |  2 +-
>>   17 files changed, 256 insertions(+), 95 deletions(-)
>>   create mode 100644 MdePkg/Include/Protocol/MmCommunication2.h
>>
>> --
>> 2.17.1
>>
>>
>> 
> 


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
  2020-05-11 14:09   ` Ard Biesheuvel
@ 2020-05-11 14:32     ` Liming Gao
  2020-05-12 21:52       ` Ard Biesheuvel
  0 siblings, 1 reply; 21+ messages in thread
From: Liming Gao @ 2020-05-11 14:32 UTC (permalink / raw)
  To: Ard Biesheuvel, devel@edk2.groups.io
  Cc: Kinney, Michael D, Wang, Jian J, Wu, Hao A, Leif Lindholm,
	Sami Mujawar, Yao, Jiewen

OK. I have no other comment. This patch set is good to me. Reviewed-by: Liming Gao <liming.gao@intel.com>

Thanks
Liming
> -----Original Message-----
> From: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Sent: Monday, May 11, 2020 10:10 PM
> To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Leif
> Lindholm <leif@nuviainc.com>; Sami Mujawar <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: Re: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
> 
> On 5/11/20 4:08 PM, Gao, Liming wrote:
> > Ard:
> >    I see this change updates VariableSmmRuntimeDxe to consume mMmCommunication2 with mVariableBufferPhysical and
> mVariableBuffer for physical and virtual.
> >    But, FaultTolerantWriteSmmDxe consumes mMmCommunication2 with the same SmmCommunicateHeader for physical and
> virtual.
> >
> >    Is there any difference between them?
> >
> 
> Yes. The FTW code never executes at runtime, so it is guaranteed that
> physical == virtual.
> 
> 
> >> -----Original Message-----
> >> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ard Biesheuvel
> >> Sent: Thursday, May 7, 2020 1:27 AM
> >> To: devel@edk2.groups.io
> >> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
> >> <liming.gao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Leif Lindholm
> >> <leif@nuviainc.com>; Sami Mujawar <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>
> >> Subject: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
> >>
> >> Now that version 1.7 errata A of the PI spec has finally been released,
> >> we can take another look at this series, which incorporates the new MM
> >> communicate2 protocol definition, updates the producers for conventional
> >> SMM and standalone MM, and updates the variable store components to consume
> >> the new version of the protocol. This solves a long standing compatibility
> >> issue which made standalone MM fundamentally incompatible with a virtually
> >> remapped address space as installed by SetVirtualAddressMap().
> >>
> >> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> >> Cc: Liming Gao <liming.gao@intel.com>
> >> Cc: Jian J Wang <jian.j.wang@intel.com>
> >> Cc: Hao A Wu <hao.a.wu@intel.com>
> >> Cc: Leif Lindholm <leif@nuviainc.com>
> >> Cc: Sami Mujawar <sami.mujawar@arm.com>
> >> Cc: Jiewen Yao <jiewen.yao@intel.com>
> >>
> >> Ard Biesheuvel (7):
> >>    MdePkg: introduce MM communicate 2 protocol
> >>    MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
> >>    ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol
> >>    MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol
> >>    MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2
> >>    MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2
> >>    StandaloneMmPkg: switch to MM communicate 2 protocol
> >>
> >>   .../MmCommunicationDxe/MmCommunication.c      | 81 +++++++++----------
> >>   .../MmCommunicationDxe/MmCommunication.inf    |  6 +-
> >>   .../Application/VariableInfo/VariableInfo.c   | 19 +++--
> >>   .../Application/VariableInfo/VariableInfo.inf |  2 +-
> >>   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c        | 80 ++++++++++++++++++
> >>   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf      |  1 +
> >>   MdeModulePkg/Include/Guid/SmmVariableCommon.h |  6 +-
> >>   .../FaultTolerantWriteSmmCommon.h             |  2 +-
> >>   .../FaultTolerantWriteSmmDxe.c                | 25 +++---
> >>   .../FaultTolerantWriteSmmDxe.h                |  2 +-
> >>   .../FaultTolerantWriteSmmDxe.inf              |  4 +-
> >>   .../RuntimeDxe/VariableSmmRuntimeDxe.c        | 39 ++++-----
> >>   .../RuntimeDxe/VariableSmmRuntimeDxe.inf      |  4 +-
> >>   MdePkg/Include/Protocol/MmCommunication2.h    | 69 ++++++++++++++++
> >>   MdePkg/MdePkg.dec                             |  7 ++
> >>   StandaloneMmPkg/Core/StandaloneMmCore.h       |  2 +-
> >>   .../StandaloneMmCpu/AArch64/StandaloneMmCpu.h |  2 +-
> >>   17 files changed, 256 insertions(+), 95 deletions(-)
> >>   create mode 100644 MdePkg/Include/Protocol/MmCommunication2.h
> >>
> >> --
> >> 2.17.1
> >>
> >>
> >> 
> >


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol
  2020-05-06 17:27 ` [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate " Ard Biesheuvel
@ 2020-05-12  9:30   ` Leif Lindholm
  2020-05-12 17:21   ` [edk2-devel] " Sami Mujawar
  1 sibling, 0 replies; 21+ messages in thread
From: Leif Lindholm @ 2020-05-12  9:30 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: devel, Michael D Kinney, Liming Gao, Jian J Wang, Hao A Wu,
	Sami Mujawar, Jiewen Yao

On Wed, May 06, 2020 at 19:27:30 +0200, Ard Biesheuvel wrote:
> Implement the new MmCommunication2 protocol which supports the use
> of standalone MM at runtime inside an address space that has been
> virtually remapped by the OS.
> 
> Note that the implementation of the old MM Communicate protocol is
> removed: it never worked correctly so there is no point in keeping it.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>

Reviewed-by: Leif Lindholm <leif@nuviainc.com>
I agree the old protocol should be dropped. Any current users would be
well warned that their foundation is a swamp.

/
    Leif

> ---
>  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c   | 81 +++++++++-----------
>  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf |  6 +-
>  2 files changed, 41 insertions(+), 46 deletions(-)
> 
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> index a9e06be1adc2..9457eaf1d809 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> @@ -1,6 +1,6 @@
>  /** @file
>  
> -  Copyright (c) 2016-2018, ARM Limited. All rights reserved.
> +  Copyright (c) 2016-2020, ARM Limited. All rights reserved.
>  
>    SPDX-License-Identifier: BSD-2-Clause-Patent
>  
> @@ -16,7 +16,7 @@
>  #include <Library/UefiBootServicesTableLib.h>
>  #include <Library/UefiRuntimeServicesTableLib.h>
>  
> -#include <Protocol/MmCommunication.h>
> +#include <Protocol/MmCommunication2.h>
>  
>  #include <IndustryStandard/ArmStdSmc.h>
>  
> @@ -39,39 +39,34 @@ STATIC EFI_HANDLE  mMmCommunicateHandle;
>  /**
>    Communicates with a registered handler.
>  
> -  This function provides an interface to send and receive messages to the
> -  Standalone MM environment on behalf of UEFI services.  This function is part
> -  of the MM Communication Protocol that may be called in physical mode prior to
> -  SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap().
> +  This function provides a service to send and receive messages from a registered UEFI service.
>  
> -  @param[in]      This                The EFI_MM_COMMUNICATION_PROTOCOL
> -                                      instance.
> -  @param[in, out] CommBuffer          A pointer to the buffer to convey
> -                                      into MMRAM.
> -  @param[in, out] CommSize            The size of the data buffer being
> -                                      passed in. This is optional.
> +  @param[in] This                The EFI_MM_COMMUNICATION_PROTOCOL instance.
> +  @param[in] CommBufferPhysical  Physical address of the MM communication buffer
> +  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer
> +  @param[in] CommSize            The size of the data buffer being passed in. On exit, the size of data
> +                                 being returned. Zero if the handler does not wish to reply with any data.
> +                                 This parameter is optional and may be NULL.
> +
> +  @retval EFI_SUCCESS            The message was successfully posted.
> +  @retval EFI_INVALID_PARAMETER  CommBufferPhysical was NULL or CommBufferVirtual was NULL.
> +  @retval EFI_BAD_BUFFER_SIZE    The buffer is too large for the MM implementation.
> +                                 If this error is returned, the MessageLength field
> +                                 in the CommBuffer header or the integer pointed by
> +                                 CommSize, are updated to reflect the maximum payload
> +                                 size the implementation can accommodate.
> +  @retval EFI_ACCESS_DENIED      The CommunicateBuffer parameter or CommSize parameter,
> +                                 if not omitted, are in address range that cannot be
> +                                 accessed by the MM environment.
>  
> -  @retval EFI_SUCCESS                 The message was successfully posted.
> -  @retval EFI_INVALID_PARAMETER       The CommBuffer was NULL.
> -  @retval EFI_BAD_BUFFER_SIZE         The buffer size is incorrect for the MM
> -                                      implementation. If this error is
> -                                      returned, the MessageLength field in
> -                                      the CommBuffer header or the integer
> -                                      pointed by CommSize are updated to reflect
> -                                      the maximum payload size the
> -                                      implementation can accommodate.
> -  @retval EFI_ACCESS_DENIED           The CommunicateBuffer parameter
> -                                      or CommSize parameter, if not omitted,
> -                                      are in address range that cannot be
> -                                      accessed by the MM environment
>  **/
> -STATIC
>  EFI_STATUS
>  EFIAPI
> -MmCommunicationCommunicate (
> -  IN CONST EFI_MM_COMMUNICATION_PROTOCOL  *This,
> -  IN OUT VOID                             *CommBuffer,
> -  IN OUT UINTN                            *CommSize OPTIONAL
> +MmCommunication2Communicate (
> +  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,
> +  IN OUT VOID                               *CommBufferPhysical,
> +  IN OUT VOID                               *CommBufferVirtual,
> +  IN OUT UINTN                              *CommSize OPTIONAL
>    )
>  {
>    EFI_MM_COMMUNICATE_HEADER   *CommunicateHeader;
> @@ -87,11 +82,11 @@ MmCommunicationCommunicate (
>    //
>    // Check parameters
>    //
> -  if (CommBuffer == NULL) {
> +  if (CommBufferVirtual == NULL) {
>      return EFI_INVALID_PARAMETER;
>    }
>  
> -  CommunicateHeader = CommBuffer;
> +  CommunicateHeader = CommBufferVirtual;
>    // CommBuffer is a mandatory parameter. Hence, Rely on
>    // MessageLength + Header to ascertain the
>    // total size of the communication payload rather than
> @@ -136,7 +131,7 @@ MmCommunicationCommunicate (
>    CommunicateSmcArgs.Arg1 = 0;
>  
>    // Copy Communication Payload
> -  CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBuffer, BufferSize);
> +  CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBufferVirtual, BufferSize);
>  
>    // comm_buffer_address (64-bit physical address)
>    CommunicateSmcArgs.Arg2 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
> @@ -149,7 +144,7 @@ MmCommunicationCommunicate (
>  
>    switch (CommunicateSmcArgs.Arg0) {
>    case ARM_SMC_MM_RET_SUCCESS:
> -    ZeroMem (CommBuffer, BufferSize);
> +    ZeroMem (CommBufferVirtual, BufferSize);
>      // On successful return, the size of data being returned is inferred from
>      // MessageLength + Header.
>      CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
> @@ -158,7 +153,7 @@ MmCommunicationCommunicate (
>                   sizeof (CommunicateHeader->MessageLength);
>  
>      CopyMem (
> -      CommBuffer,
> +      CommBufferVirtual,
>        (VOID *)mNsCommBuffMemRegion.VirtualBase,
>        BufferSize
>        );
> @@ -191,8 +186,8 @@ MmCommunicationCommunicate (
>  //
>  // MM Communication Protocol instance
>  //
> -EFI_MM_COMMUNICATION_PROTOCOL  mMmCommunication = {
> -  MmCommunicationCommunicate
> +STATIC EFI_MM_COMMUNICATION2_PROTOCOL  mMmCommunication2 = {
> +  MmCommunication2Communicate
>  };
>  
>  /**
> @@ -293,7 +288,7 @@ MmGuidedEventNotify (
>    Header.Data[0] = 0;
>  
>    Size = sizeof (Header);
> -  MmCommunicationCommunicate (&mMmCommunication, &Header, &Size);
> +  MmCommunication2Communicate (&mMmCommunication2, &Header, &Header, &Size);
>  }
>  
>  /**
> @@ -312,7 +307,7 @@ MmGuidedEventNotify (
>  **/
>  EFI_STATUS
>  EFIAPI
> -MmCommunicationInitialize (
> +MmCommunication2Initialize (
>    IN EFI_HANDLE         ImageHandle,
>    IN EFI_SYSTEM_TABLE  *SystemTable
>    )
> @@ -363,9 +358,9 @@ MmCommunicationInitialize (
>    // Install the communication protocol
>    Status = gBS->InstallProtocolInterface (
>                    &mMmCommunicateHandle,
> -                  &gEfiMmCommunicationProtocolGuid,
> +                  &gEfiMmCommunication2ProtocolGuid,
>                    EFI_NATIVE_INTERFACE,
> -                  &mMmCommunication
> +                  &mMmCommunication2
>                    );
>    if (EFI_ERROR(Status)) {
>      DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: "
> @@ -402,8 +397,8 @@ MmCommunicationInitialize (
>  UninstallProtocol:
>    gBS->UninstallProtocolInterface (
>           mMmCommunicateHandle,
> -         &gEfiMmCommunicationProtocolGuid,
> -         &mMmCommunication
> +         &gEfiMmCommunication2ProtocolGuid,
> +         &mMmCommunication2
>           );
>  
>  CleanAddedMemorySpace:
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> index 505228704ea5..2465fb77c58e 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> @@ -2,7 +2,7 @@
>  #
>  #  DXE MM Communicate driver
>  #
> -#  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> +#  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -14,7 +14,7 @@ [Defines]
>    FILE_GUID                      = 09EE81D3-F15E-43F4-85B4-CB9873DA5D6B
>    MODULE_TYPE                    = DXE_RUNTIME_DRIVER
>    VERSION_STRING                 = 1.0
> -  ENTRY_POINT                    = MmCommunicationInitialize
> +  ENTRY_POINT                    = MmCommunication2Initialize
>  
>  #
>  # The following is for reference only and not required by
> @@ -40,7 +40,7 @@ [LibraryClasses]
>    UefiDriverEntryPoint
>  
>  [Protocols]
> -  gEfiMmCommunicationProtocolGuid              ## PRODUCES
> +  gEfiMmCommunication2ProtocolGuid              ## PRODUCES
>  
>  [Guids]
>    gEfiEndOfDxeEventGroupGuid
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 1/7] MdePkg: introduce MM communicate 2 protocol
  2020-05-06 17:27 ` [PATCH resend 1/7] MdePkg: introduce MM communicate 2 protocol Ard Biesheuvel
@ 2020-05-12 17:09   ` Sami Mujawar
  0 siblings, 0 replies; 21+ messages in thread
From: Sami Mujawar @ 2020-05-12 17:09 UTC (permalink / raw)
  To: Ard Biesheuvel, devel

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

[-- Attachment #2: Type: text/html, Size: 100 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 2/7] MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
  2020-05-06 17:27 ` [PATCH resend 2/7] MdeModulePkg/SmmIpl: expose " Ard Biesheuvel
@ 2020-05-12 17:09   ` Sami Mujawar
  0 siblings, 0 replies; 21+ messages in thread
From: Sami Mujawar @ 2020-05-12 17:09 UTC (permalink / raw)
  To: Ard Biesheuvel, devel

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

[-- Attachment #2: Type: text/html, Size: 100 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol
  2020-05-06 17:27 ` [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate " Ard Biesheuvel
  2020-05-06 17:53   ` [EXTERNAL] [edk2-devel] " Bret Barkelew
@ 2020-05-12 17:10   ` Sami Mujawar
  1 sibling, 0 replies; 21+ messages in thread
From: Sami Mujawar @ 2020-05-12 17:10 UTC (permalink / raw)
  To: Ard Biesheuvel, devel

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

[-- Attachment #2: Type: text/html, Size: 100 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 5/7] MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2
  2020-05-06 17:27 ` [PATCH resend 5/7] MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2 Ard Biesheuvel
@ 2020-05-12 17:10   ` Sami Mujawar
  0 siblings, 0 replies; 21+ messages in thread
From: Sami Mujawar @ 2020-05-12 17:10 UTC (permalink / raw)
  To: Ard Biesheuvel, devel

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

[-- Attachment #2: Type: text/html, Size: 100 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 6/7] MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2
  2020-05-06 17:27 ` [PATCH resend 6/7] MdeModulePkg/VariableSmmRuntimeDxe: " Ard Biesheuvel
@ 2020-05-12 17:10   ` Sami Mujawar
  0 siblings, 0 replies; 21+ messages in thread
From: Sami Mujawar @ 2020-05-12 17:10 UTC (permalink / raw)
  To: Ard Biesheuvel, devel

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

[-- Attachment #2: Type: text/html, Size: 100 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 7/7] StandaloneMmPkg: switch to MM communicate 2 protocol
  2020-05-06 17:27 ` [PATCH resend 7/7] StandaloneMmPkg: switch to MM communicate 2 protocol Ard Biesheuvel
@ 2020-05-12 17:10   ` Sami Mujawar
  0 siblings, 0 replies; 21+ messages in thread
From: Sami Mujawar @ 2020-05-12 17:10 UTC (permalink / raw)
  To: Ard Biesheuvel, devel

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

[-- Attachment #2: Type: text/html, Size: 100 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol
  2020-05-06 17:27 ` [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate " Ard Biesheuvel
  2020-05-12  9:30   ` Leif Lindholm
@ 2020-05-12 17:21   ` Sami Mujawar
  1 sibling, 0 replies; 21+ messages in thread
From: Sami Mujawar @ 2020-05-12 17:21 UTC (permalink / raw)
  To: Ard Biesheuvel, devel

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

[-- Attachment #2: Type: text/html, Size: 101 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
  2020-05-11 14:32     ` Liming Gao
@ 2020-05-12 21:52       ` Ard Biesheuvel
  0 siblings, 0 replies; 21+ messages in thread
From: Ard Biesheuvel @ 2020-05-12 21:52 UTC (permalink / raw)
  To: Gao, Liming, devel@edk2.groups.io
  Cc: Kinney, Michael D, Wang, Jian J, Wu, Hao A, Leif Lindholm,
	Sami Mujawar, Yao, Jiewen

On 5/11/20 4:32 PM, Gao, Liming wrote:
> OK. I have no other comment. This patch set is good to me. Reviewed-by: Liming Gao <liming.gao@intel.com>
> 

Series pushed as PR #606

Thanks all!


>> -----Original Message-----
>> From: Ard Biesheuvel <ard.biesheuvel@arm.com>
>> Sent: Monday, May 11, 2020 10:10 PM
>> To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
>> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Leif
>> Lindholm <leif@nuviainc.com>; Sami Mujawar <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>
>> Subject: Re: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
>>
>> On 5/11/20 4:08 PM, Gao, Liming wrote:
>>> Ard:
>>>     I see this change updates VariableSmmRuntimeDxe to consume mMmCommunication2 with mVariableBufferPhysical and
>> mVariableBuffer for physical and virtual.
>>>     But, FaultTolerantWriteSmmDxe consumes mMmCommunication2 with the same SmmCommunicateHeader for physical and
>> virtual.
>>>
>>>     Is there any difference between them?
>>>
>>
>> Yes. The FTW code never executes at runtime, so it is guaranteed that
>> physical == virtual.
>>
>>
>>>> -----Original Message-----
>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ard Biesheuvel
>>>> Sent: Thursday, May 7, 2020 1:27 AM
>>>> To: devel@edk2.groups.io
>>>> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
>>>> <liming.gao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Leif Lindholm
>>>> <leif@nuviainc.com>; Sami Mujawar <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>
>>>> Subject: [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)
>>>>
>>>> Now that version 1.7 errata A of the PI spec has finally been released,
>>>> we can take another look at this series, which incorporates the new MM
>>>> communicate2 protocol definition, updates the producers for conventional
>>>> SMM and standalone MM, and updates the variable store components to consume
>>>> the new version of the protocol. This solves a long standing compatibility
>>>> issue which made standalone MM fundamentally incompatible with a virtually
>>>> remapped address space as installed by SetVirtualAddressMap().
>>>>
>>>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>>>> Cc: Liming Gao <liming.gao@intel.com>
>>>> Cc: Jian J Wang <jian.j.wang@intel.com>
>>>> Cc: Hao A Wu <hao.a.wu@intel.com>
>>>> Cc: Leif Lindholm <leif@nuviainc.com>
>>>> Cc: Sami Mujawar <sami.mujawar@arm.com>
>>>> Cc: Jiewen Yao <jiewen.yao@intel.com>
>>>>
>>>> Ard Biesheuvel (7):
>>>>     MdePkg: introduce MM communicate 2 protocol
>>>>     MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
>>>>     ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol
>>>>     MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol
>>>>     MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2
>>>>     MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2
>>>>     StandaloneMmPkg: switch to MM communicate 2 protocol
>>>>
>>>>    .../MmCommunicationDxe/MmCommunication.c      | 81 +++++++++----------
>>>>    .../MmCommunicationDxe/MmCommunication.inf    |  6 +-
>>>>    .../Application/VariableInfo/VariableInfo.c   | 19 +++--
>>>>    .../Application/VariableInfo/VariableInfo.inf |  2 +-
>>>>    MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c        | 80 ++++++++++++++++++
>>>>    MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf      |  1 +
>>>>    MdeModulePkg/Include/Guid/SmmVariableCommon.h |  6 +-
>>>>    .../FaultTolerantWriteSmmCommon.h             |  2 +-
>>>>    .../FaultTolerantWriteSmmDxe.c                | 25 +++---
>>>>    .../FaultTolerantWriteSmmDxe.h                |  2 +-
>>>>    .../FaultTolerantWriteSmmDxe.inf              |  4 +-
>>>>    .../RuntimeDxe/VariableSmmRuntimeDxe.c        | 39 ++++-----
>>>>    .../RuntimeDxe/VariableSmmRuntimeDxe.inf      |  4 +-
>>>>    MdePkg/Include/Protocol/MmCommunication2.h    | 69 ++++++++++++++++
>>>>    MdePkg/MdePkg.dec                             |  7 ++
>>>>    StandaloneMmPkg/Core/StandaloneMmCore.h       |  2 +-
>>>>    .../StandaloneMmCpu/AArch64/StandaloneMmCpu.h |  2 +-
>>>>    17 files changed, 256 insertions(+), 95 deletions(-)
>>>>    create mode 100644 MdePkg/Include/Protocol/MmCommunication2.h
>>>>
>>>> --
>>>> 2.17.1
>>>>
>>>>
>>>> 
>>>
> 


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2020-05-12 21:52 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-06 17:27 [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Ard Biesheuvel
2020-05-06 17:27 ` [PATCH resend 1/7] MdePkg: introduce MM communicate 2 protocol Ard Biesheuvel
2020-05-12 17:09   ` [edk2-devel] " Sami Mujawar
2020-05-06 17:27 ` [PATCH resend 2/7] MdeModulePkg/SmmIpl: expose " Ard Biesheuvel
2020-05-12 17:09   ` [edk2-devel] " Sami Mujawar
2020-05-06 17:27 ` [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate " Ard Biesheuvel
2020-05-12  9:30   ` Leif Lindholm
2020-05-12 17:21   ` [edk2-devel] " Sami Mujawar
2020-05-06 17:27 ` [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate " Ard Biesheuvel
2020-05-06 17:53   ` [EXTERNAL] [edk2-devel] " Bret Barkelew
2020-05-12 17:10   ` Sami Mujawar
2020-05-06 17:27 ` [PATCH resend 5/7] MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2 Ard Biesheuvel
2020-05-12 17:10   ` [edk2-devel] " Sami Mujawar
2020-05-06 17:27 ` [PATCH resend 6/7] MdeModulePkg/VariableSmmRuntimeDxe: " Ard Biesheuvel
2020-05-12 17:10   ` [edk2-devel] " Sami Mujawar
2020-05-06 17:27 ` [PATCH resend 7/7] StandaloneMmPkg: switch to MM communicate 2 protocol Ard Biesheuvel
2020-05-12 17:10   ` [edk2-devel] " Sami Mujawar
2020-05-11 14:08 ` [edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a) Liming Gao
2020-05-11 14:09   ` Ard Biesheuvel
2020-05-11 14:32     ` Liming Gao
2020-05-12 21:52       ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox