diff --git a/StandaloneMmPkg/Core/Dispatcher.c b/StandaloneMmPkg/Core/Dispatcher.c index e55fdbabf2..8e6b85caee 100644 --- a/StandaloneMmPkg/Core/Dispatcher.c +++ b/StandaloneMmPkg/Core/Dispatcher.c @@ -766,6 +766,13 @@ MmDriverDispatchHandler ( MmiHandlerUnRegister (DispatchHandle); + // + // Free shadowed standalone BFV + // + if (mBfv != NULL) { + FreePool (mBfv); + } + return EFI_SUCCESS; } diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c index 970a06045b..127248afab 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.c +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c @@ -83,9 +83,10 @@ MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = { { NULL, NULL, NULL, FALSE }, }; -BOOLEAN mMmEntryPointRegistered = FALSE; -MM_COMM_BUFFER *mMmCommunicationBuffer; -VOID *mInternalCommBufferCopy; +BOOLEAN mMmEntryPointRegistered = FALSE; +MM_COMM_BUFFER *mMmCommunicationBuffer; +VOID *mInternalCommBufferCopy; +EFI_FIRMWARE_VOLUME_HEADER *mBfv = NULL; /** Place holder function until all the MM System Table Service are available. @@ -844,9 +845,19 @@ StandaloneMmMain ( // Dispatch standalone BFV // if (BfvHob->BaseAddress != 0) { - DEBUG ((DEBUG_INFO, "Mm Dispatch StandaloneBfvAddress - 0x%08x\n", BfvHob->BaseAddress)); - MmCoreFfsFindMmDriver ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BfvHob->BaseAddress, 0); - MmDispatcher (); + // + // Shadow standalone BFV into MMRAM + // + mBfv = AllocatePool (BfvHob->Length); + if (mBfv != NULL) { + CopyMem ((VOID *)mBfv, (VOID *)(UINTN)BfvHob->BaseAddress, BfvHob->Length); + DEBUG ((DEBUG_INFO, "Mm Dispatch StandaloneBfvAddress - 0x%08x\n", mBfv)); + MmCoreFfsFindMmDriver (mBfv, 0); + MmDispatcher (); + if (!FeaturePcdGet (PcdRestartMmDispatcherOnceMmEntryRegistered)) { + FreePool (mBfv); + } + } } } diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.h b/StandaloneMmPkg/Core/StandaloneMmCore.h index 093a35fb56..7bff1cde14 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.h +++ b/StandaloneMmPkg/Core/StandaloneMmCore.h @@ -178,9 +178,10 @@ typedef struct { // // MM Core Global Variables // -extern EFI_MM_SYSTEM_TABLE gMmCoreMmst; -extern LIST_ENTRY gHandleList; -extern BOOLEAN mMmEntryPointRegistered; +extern EFI_MM_SYSTEM_TABLE gMmCoreMmst; +extern LIST_ENTRY gHandleList; +extern BOOLEAN mMmEntryPointRegistered; +extern EFI_FIRMWARE_VOLUME_HEADER *mBfv; /** Called to initialize the memory service. diff --git a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c index b1cd3c1d81..1a01d7a465 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c @@ -513,14 +513,6 @@ ExecuteMmCoreFromMmram ( Status = LocateMmCoreFv (&MmFvBase, &MmFvSize, &MmCoreFileName, &ImageContext.Handle); ASSERT_EFI_ERROR (Status); - // - // Unblock the MM FV range to be accessible from inside MM - // - if ((MmFvBase != 0) && (MmFvSize != 0)) { - Status = MmUnblockMemoryRequest (MmFvBase, EFI_SIZE_TO_PAGES (MmFvSize)); - ASSERT_EFI_ERROR (Status); - } - // // Initialize ImageContext //