StandaloneMmPkg/Core: Remove traditional MM driver support

StandaloneMmCore should not support dispatching traditional MM
driver which has dependency on UEFI services. Therefore, remove
the related code that supports traditional MM driver.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
This commit is contained in:
Wei6 Xu 2024-05-06 23:45:05 +08:00 committed by mergify[bot]
parent 6855567d52
commit 6dc14fb5b4
5 changed files with 14 additions and 88 deletions

View File

@ -231,13 +231,6 @@ MmIsSchedulable (
CopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));
Status = MmLocateProtocol (&DriverGuid, NULL, &Interface);
if (EFI_ERROR (Status) && (mEfiSystemTable != NULL)) {
//
// For MM Driver, it may depend on uefi protocols
//
Status = mEfiSystemTable->BootServices->LocateProtocol (&DriverGuid, NULL, &Interface);
}
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = FALSE\n", &DriverGuid));
Status = PushBool (FALSE);

View File

@ -185,45 +185,6 @@ MmLoadImage (
DriverEntry->ImageBuffer = DstBuffer;
DriverEntry->NumberOfPage = PageCount;
if (mEfiSystemTable != NULL) {
Status = mEfiSystemTable->BootServices->AllocatePool (
EfiBootServicesData,
sizeof (EFI_LOADED_IMAGE_PROTOCOL),
(VOID **)&DriverEntry->LoadedImage
);
if (EFI_ERROR (Status)) {
MmFreePages (DstBuffer, PageCount);
return Status;
}
ZeroMem (DriverEntry->LoadedImage, sizeof (EFI_LOADED_IMAGE_PROTOCOL));
//
// Fill in the remaining fields of the Loaded Image Protocol instance.
// Note: ImageBase is an SMRAM address that can not be accessed outside of SMRAM if SMRAM window is closed.
//
DriverEntry->LoadedImage->Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
DriverEntry->LoadedImage->ParentHandle = NULL;
DriverEntry->LoadedImage->SystemTable = mEfiSystemTable;
DriverEntry->LoadedImage->DeviceHandle = NULL;
DriverEntry->LoadedImage->FilePath = NULL;
DriverEntry->LoadedImage->ImageBase = (VOID *)(UINTN)DriverEntry->ImageBuffer;
DriverEntry->LoadedImage->ImageSize = ImageContext.ImageSize;
DriverEntry->LoadedImage->ImageCodeType = EfiRuntimeServicesCode;
DriverEntry->LoadedImage->ImageDataType = EfiRuntimeServicesData;
//
// Create a new image handle in the UEFI handle database for the MM Driver
//
DriverEntry->ImageHandle = NULL;
Status = mEfiSystemTable->BootServices->InstallMultipleProtocolInterfaces (
&DriverEntry->ImageHandle,
&gEfiLoadedImageProtocolGuid,
DriverEntry->LoadedImage,
NULL
);
}
//
// Print the load address and the PDB file name if it is available
//
@ -464,17 +425,8 @@ MmDispatcher (
//
// For each MM driver, pass NULL as ImageHandle
//
if (mEfiSystemTable == NULL) {
DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Standalone Mode)\n", DriverEntry->ImageEntryPoint));
Status = ((MM_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint)(DriverEntry->ImageHandle, &gMmCoreMmst);
} else {
DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Tradition Mode)\n", DriverEntry->ImageEntryPoint));
Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint)(
DriverEntry->ImageHandle,
mEfiSystemTable
);
}
DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Standalone Mode)\n", DriverEntry->ImageEntryPoint));
Status = ((MM_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint)(DriverEntry->ImageHandle, &gMmCoreMmst);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "StartImage Status - %r\n", Status));
MmFreePages (DriverEntry->ImageBuffer, DriverEntry->NumberOfPage);

View File

@ -11,18 +11,6 @@
#include <Library/FvLib.h>
#include <Library/ExtractGuidedSectionLib.h>
//
// List of file types supported by dispatcher
//
EFI_FV_FILETYPE mMmFileTypes[] = {
EFI_FV_FILETYPE_MM,
0xE, // EFI_FV_FILETYPE_MM_STANDALONE,
//
// Note: DXE core will process the FV image file, so skip it in MM core
// EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
//
};
EFI_STATUS
MmAddToDriverList (
IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
@ -72,12 +60,10 @@ MmCoreFfsFindMmDriver (
EFI_STATUS Status;
EFI_STATUS DepexStatus;
EFI_FFS_FILE_HEADER *FileHeader;
EFI_FV_FILETYPE FileType;
VOID *Pe32Data;
UINTN Pe32DataSize;
VOID *Depex;
UINTN DepexSize;
UINTN Index;
EFI_COMMON_SECTION_HEADER *Section;
VOID *SectionData;
UINTN SectionDataSize;
@ -224,22 +210,19 @@ MmCoreFfsFindMmDriver (
}
} while (TRUE);
for (Index = 0; Index < sizeof (mMmFileTypes) / sizeof (mMmFileTypes[0]); Index++) {
DEBUG ((DEBUG_INFO, "Check MmFileTypes - 0x%x\n", mMmFileTypes[Index]));
FileType = mMmFileTypes[Index];
FileHeader = NULL;
do {
Status = FfsFindNextFile (FileType, FwVolHeader, &FileHeader);
if (!EFI_ERROR (Status)) {
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHeader, &Pe32Data, &Pe32DataSize);
DEBUG ((DEBUG_INFO, "Find PE data - 0x%x\n", Pe32Data));
DepexStatus = FfsFindSectionData (EFI_SECTION_MM_DEPEX, FileHeader, &Depex, &DepexSize);
if (!EFI_ERROR (DepexStatus)) {
MmAddToDriverList (FwVolHeader, Pe32Data, Pe32DataSize, Depex, DepexSize, &FileHeader->Name);
}
DEBUG ((DEBUG_INFO, "Check MmFileTypes - 0x%x\n", EFI_FV_FILETYPE_MM_STANDALONE));
FileHeader = NULL;
do {
Status = FfsFindNextFile (EFI_FV_FILETYPE_MM_STANDALONE, FwVolHeader, &FileHeader);
if (!EFI_ERROR (Status)) {
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHeader, &Pe32Data, &Pe32DataSize);
DEBUG ((DEBUG_INFO, "Find PE data - 0x%x\n", Pe32Data));
DepexStatus = FfsFindSectionData (EFI_SECTION_MM_DEPEX, FileHeader, &Depex, &DepexSize);
if (!EFI_ERROR (DepexStatus)) {
MmAddToDriverList (FwVolHeader, Pe32Data, Pe32DataSize, Depex, DepexSize, &FileHeader->Name);
}
} while (!EFI_ERROR (Status));
}
}
} while (!EFI_ERROR (Status));
return EFI_SUCCESS;

View File

@ -86,7 +86,6 @@ MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = {
{ NULL, NULL, NULL, FALSE },
};
EFI_SYSTEM_TABLE *mEfiSystemTable;
UINTN mMmramRangeCount;
EFI_MMRAM_DESCRIPTOR *mMmramRanges;

View File

@ -873,6 +873,5 @@ MmCoreFfsFindMmDriver (
extern UINTN mMmramRangeCount;
extern EFI_MMRAM_DESCRIPTOR *mMmramRanges;
extern EFI_SYSTEM_TABLE *mEfiSystemTable;
#endif