From: "Ard Biesheuvel" <ard.biesheuvel@arm.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <liming.gao@intel.com>,
Jian J Wang <jian.j.wang@intel.com>,
Hao A Wu <hao.a.wu@intel.com>, Leif Lindholm <leif@nuviainc.com>,
Sami Mujawar <sami.mujawar@arm.com>,
Jiewen Yao <jiewen.yao@intel.com>
Subject: [PATCH resend 6/7] MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2
Date: Wed, 6 May 2020 19:27:33 +0200 [thread overview]
Message-ID: <20200506172734.2475-7-ard.biesheuvel@arm.com> (raw)
In-Reply-To: <20200506172734.2475-1-ard.biesheuvel@arm.com>
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
next prev parent reply other threads:[~2020-05-06 17:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Ard Biesheuvel [this message]
2020-05-12 17:10 ` [edk2-devel] [PATCH resend 6/7] MdeModulePkg/VariableSmmRuntimeDxe: " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200506172734.2475-7-ard.biesheuvel@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox