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>
This commit is contained in:
Kun Qin
2025-05-14 13:22:26 -07:00
committed by mergify[bot]
parent 6b7a3e05f0
commit 9752e69927
2 changed files with 50 additions and 15 deletions

View File

@ -40,6 +40,7 @@ MmFoundationEntryRegister (
// (which means it cannot run concurrently) // (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 = { EFI_MM_CONFIGURATION_PROTOCOL mMmConfig = {
0, 0,
@ -88,9 +89,20 @@ PiMmStandaloneMmCpuDriverEntry (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// Find out the size of the buffer passed
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 // Find out the size of the buffer passed
CommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *)CommBufferAddr)->MessageLength + CommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *)CommBufferAddr)->MessageLength +
sizeof (EFI_MM_COMMUNICATE_HEADER); OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);
}
// Now that the secure world can see the normal world buffer, allocate // Now that the secure world can see the normal world buffer, allocate
// memory to copy the communication buffer to the secure world. // memory to copy the communication buffer to the secure world.
@ -188,6 +200,27 @@ PiMmCpuTpFwRootMmiHandler (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
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 ((
DEBUG_INFO, DEBUG_INFO,
"CommBuffer - 0x%x, CommBufferSize - 0x%x\n", "CommBuffer - 0x%x, CommBufferSize - 0x%x\n",
@ -199,8 +232,9 @@ PiMmCpuTpFwRootMmiHandler (
&gGuidedEventContext->HeaderGuid, &gGuidedEventContext->HeaderGuid,
NULL, NULL,
gGuidedEventContext->Data, gGuidedEventContext->Data,
&gGuidedEventContext->MessageLength (UINTN *)(&gGuidedEventContext->MessageLength)
); );
}
if (Status != EFI_SUCCESS) { if (Status != EFI_SUCCESS) {
DEBUG ((DEBUG_WARN, "Unable to manage Guided Event - %d\n", Status)); DEBUG ((DEBUG_WARN, "Unable to manage Guided Event - %d\n", Status));

View File

@ -46,6 +46,7 @@
gZeroGuid gZeroGuid
gMpInformationHobGuid gMpInformationHobGuid
gEfiStandaloneMmNonSecureBufferGuid gEfiStandaloneMmNonSecureBufferGuid
gEfiMmCommunicateHeaderV3Guid
[Depex] [Depex]
TRUE TRUE