diff options
author | Kun Qin <kuqin@microsoft.com> | 2025-05-14 13:22:26 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2025-06-26 21:43:56 +0000 |
commit | 9752e69927ce8e42a4b4602ae628dcfd9891d5cb (patch) | |
tree | 54c519964e9a49c2faa75ab40aa7e1a6097c8604 | |
parent | 6b7a3e05f06843af98d91d76f2c80bbb73780647 (diff) | |
download | edk2-9752e69927ce8e42a4b4602ae628dcfd9891d5cb.zip edk2-9752e69927ce8e42a4b4602ae628dcfd9891d5cb.tar.gz edk2-9752e69927ce8e42a4b4602ae628dcfd9891d5cb.tar.bz2 |
ArmPkg: StandaloneMmCpu: Add MM communicate v3 support
As the standalone MM core begins supporting MM Communicate v3, this
update extends its functionality to incorporate MM Communicate v3 headers
format, enabling compatibility with the new protocol.
Signed-off-by: Kun Qin <kun.qin@microsoft.com>
-rw-r--r-- | ArmPkg/Drivers/StandaloneMmCpu/EventHandle.c | 66 | ||||
-rw-r--r-- | ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf | 1 |
2 files changed, 51 insertions, 16 deletions
diff --git a/ArmPkg/Drivers/StandaloneMmCpu/EventHandle.c b/ArmPkg/Drivers/StandaloneMmCpu/EventHandle.c index b6cecd1..99445d5 100644 --- a/ArmPkg/Drivers/StandaloneMmCpu/EventHandle.c +++ b/ArmPkg/Drivers/StandaloneMmCpu/EventHandle.c @@ -39,7 +39,8 @@ MmFoundationEntryRegister ( // maintained in single global variable because StandaloneMm is UP-migratable
// (which means it cannot run concurrently)
//
-EFI_MM_COMMUNICATE_HEADER *gGuidedEventContext = NULL;
+EFI_MM_COMMUNICATE_HEADER *gGuidedEventContext = NULL;
+EFI_MM_COMMUNICATE_HEADER_V3 *gGuidedEventContextV3 = NULL;
EFI_MM_CONFIGURATION_PROTOCOL mMmConfig = {
0,
@@ -89,8 +90,19 @@ PiMmStandaloneMmCpuDriverEntry ( }
// Find out the size of the buffer passed
- CommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *)CommBufferAddr)->MessageLength +
- sizeof (EFI_MM_COMMUNICATE_HEADER);
+ if (CompareGuid (
+ &((EFI_MM_COMMUNICATE_HEADER *)CommBufferAddr)->HeaderGuid,
+ &gEfiMmCommunicateHeaderV3Guid
+ ))
+ {
+ // This is a v3 header
+ CommBufferSize = ((EFI_MM_COMMUNICATE_HEADER_V3 *)CommBufferAddr)->BufferSize;
+ } else {
+ // This is a v1 header
+ // Find out the size of the buffer passed
+ CommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *)CommBufferAddr)->MessageLength +
+ OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);
+ }
// Now that the secure world can see the normal world buffer, allocate
// memory to copy the communication buffer to the secure world.
@@ -188,19 +200,41 @@ PiMmCpuTpFwRootMmiHandler ( return EFI_NOT_FOUND;
}
- DEBUG ((
- DEBUG_INFO,
- "CommBuffer - 0x%x, CommBufferSize - 0x%x\n",
- gGuidedEventContext,
- gGuidedEventContext->MessageLength
- ));
-
- Status = mMmst->MmiManage (
- &gGuidedEventContext->HeaderGuid,
- NULL,
- gGuidedEventContext->Data,
- &gGuidedEventContext->MessageLength
- );
+ if (CompareGuid (
+ &gGuidedEventContext->HeaderGuid,
+ &gEfiMmCommunicateHeaderV3Guid
+ ))
+ {
+ gGuidedEventContextV3 = (EFI_MM_COMMUNICATE_HEADER_V3 *)gGuidedEventContext;
+ DEBUG ((
+ DEBUG_INFO,
+ "CommBuffer - 0x%x, CommBufferSize - 0x%llx, MessageSize - 0x%llx\n",
+ gGuidedEventContextV3,
+ gGuidedEventContextV3->BufferSize,
+ gGuidedEventContextV3->MessageSize
+ ));
+
+ Status = mMmst->MmiManage (
+ &gGuidedEventContextV3->MessageGuid,
+ NULL,
+ gGuidedEventContextV3->MessageData,
+ (UINTN *)(&gGuidedEventContextV3->MessageSize)
+ );
+ } else {
+ DEBUG ((
+ DEBUG_INFO,
+ "CommBuffer - 0x%x, CommBufferSize - 0x%x\n",
+ gGuidedEventContext,
+ gGuidedEventContext->MessageLength
+ ));
+
+ Status = mMmst->MmiManage (
+ &gGuidedEventContext->HeaderGuid,
+ NULL,
+ gGuidedEventContext->Data,
+ (UINTN *)(&gGuidedEventContext->MessageLength)
+ );
+ }
if (Status != EFI_SUCCESS) {
DEBUG ((DEBUG_WARN, "Unable to manage Guided Event - %d\n", Status));
diff --git a/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf b/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf index dcf94d5..5f8bf90 100644 --- a/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf +++ b/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf @@ -46,6 +46,7 @@ gZeroGuid
gMpInformationHobGuid
gEfiStandaloneMmNonSecureBufferGuid
+ gEfiMmCommunicateHeaderV3Guid
[Depex]
TRUE
|