StandaloneMmPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the StandaloneMmPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:16 -08:00
committed by mergify[bot]
parent c1e126b119
commit 91415a36ae
41 changed files with 1828 additions and 1565 deletions

View File

@@ -206,7 +206,6 @@ MmIsSchedulable (
//
mDepexEvaluationStackPointer = mDepexEvaluationStack;
Iterator = DriverEntry->Depex;
while (TRUE) {
@@ -257,6 +256,7 @@ MmIsSchedulable (
*Iterator = EFI_DEP_REPLACE_TRUE;
Status = PushBool (TRUE);
}
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE;
@@ -284,6 +284,7 @@ MmIsSchedulable (
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE;
}
break;
case EFI_DEP_OR:
@@ -305,6 +306,7 @@ MmIsSchedulable (
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE;
}
break;
case EFI_DEP_NOT:
@@ -320,6 +322,7 @@ MmIsSchedulable (
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE;
}
break;
case EFI_DEP_TRUE:
@@ -329,6 +332,7 @@ MmIsSchedulable (
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE;
}
break;
case EFI_DEP_FALSE:
@@ -338,6 +342,7 @@ MmIsSchedulable (
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE;
}
break;
case EFI_DEP_END:
@@ -347,6 +352,7 @@ MmIsSchedulable (
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE;
}
DEBUG ((DEBUG_DISPATCH, " RESULT = %a\n", Operator ? "TRUE" : "FALSE"));
return Operator;

View File

@@ -159,7 +159,7 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
//
// see if the memory range for loading the image is in the MM code range.
//
if (MmCodeBase + MmCodeSize < ImageBase + ImageSize || MmCodeBase > ImageBase) {
if ((MmCodeBase + MmCodeSize < ImageBase + ImageSize) || (MmCodeBase > ImageBase)) {
return EFI_NOT_FOUND;
}
@@ -183,6 +183,7 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index++) {
mMmCodeMemoryRangeUsageBitMap[Index / 64] |= LShiftU64 (1, (Index % 64));
}
return EFI_SUCCESS;
}
@@ -268,14 +269,22 @@ GetPeCoffImageFixLoadingAssignedAddress(
ImageContext->ImageAddress = FixLoadingAddress;
}
}
break;
}
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
}
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r\n",
FixLoadingAddress, Status));
DEBUG ((
DEBUG_INFO|DEBUG_LOAD,
"LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r\n",
FixLoadingAddress,
Status
));
return Status;
}
/**
Loads an EFI image into SMRAM.
@@ -412,10 +421,12 @@ MmLoadImage (
UINTN StartIndex;
CHAR8 EfiFileName[256];
DEBUG ((DEBUG_INFO | DEBUG_LOAD,
DEBUG ((
DEBUG_INFO | DEBUG_LOAD,
"Loading MM driver at 0x%11p EntryPoint=0x%11p ",
(VOID *)(UINTN)ImageContext.ImageAddress,
FUNCTION_ENTRY_POINT (ImageContext.EntryPoint)));
FUNCTION_ENTRY_POINT (ImageContext.EntryPoint)
));
//
// Print Module Name by Pdb file path.
@@ -439,6 +450,7 @@ MmLoadImage (
if (EfiFileName[Index] == 0) {
EfiFileName[Index] = '.';
}
if (EfiFileName[Index] == '.') {
EfiFileName[Index + 1] = 'e';
EfiFileName[Index + 2] = 'f';
@@ -451,8 +463,10 @@ MmLoadImage (
if (Index == sizeof (EfiFileName) - 4) {
EfiFileName[Index] = 0;
}
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName));
}
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n"));
DEBUG_CODE_END ();
@@ -520,6 +534,7 @@ MmGetDepexSectionAndPreProccess (
} else {
Status = EFI_SUCCESS;
}
if (EFI_ERROR (Status)) {
if (Status == EFI_PROTOCOL_ERROR) {
//
@@ -647,6 +662,7 @@ MmDispatcher (
mEfiSystemTable
);
}
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "StartImage Status - %r\n", Status));
MmFreePages (DriverEntry->ImageBuffer, DriverEntry->NumberOfPage);
@@ -725,7 +741,7 @@ MmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
//
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
DriverEntry = CR (Link, EFI_MM_DRIVER_ENTRY, Link, EFI_MM_DRIVER_ENTRY_SIGNATURE);
if (DriverEntry->Before && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {
if (DriverEntry->Before && DriverEntry->Dependent && (DriverEntry != InsertedDriverEntry)) {
DEBUG ((DEBUG_DISPATCH, "Evaluate MM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " BEFORE FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
@@ -748,13 +764,12 @@ MmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
InsertedDriverEntry->Scheduled = TRUE;
InsertTailList (&mScheduledQueue, &InsertedDriverEntry->ScheduledLink);
//
// Process After Dependency
//
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
DriverEntry = CR (Link, EFI_MM_DRIVER_ENTRY, Link, EFI_MM_DRIVER_ENTRY_SIGNATURE);
if (DriverEntry->After && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {
if (DriverEntry->After && DriverEntry->Dependent && (DriverEntry != InsertedDriverEntry)) {
DEBUG ((DEBUG_DISPATCH, "Evaluate MM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " AFTER FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
@@ -792,12 +807,14 @@ FvHasBeenProcessed (
for (Link = mFwVolList.ForwardLink;
Link != &mFwVolList;
Link = Link->ForwardLink) {
Link = Link->ForwardLink)
{
KnownFwVol = CR (Link, KNOWN_FWVOL, Link, KNOWN_FWVOL_SIGNATURE);
if (KnownFwVol->FwVolHeader == FwVolHeader) {
return TRUE;
}
}
return FALSE;
}

View File

@@ -95,19 +95,32 @@ MmCoreFfsFindMmDriver (
//
FileHeader = NULL;
do {
Status = FfsFindNextFile (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,
FwVolHeader, &FileHeader);
Status = FfsFindNextFile (
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,
FwVolHeader,
&FileHeader
);
if (EFI_ERROR (Status)) {
break;
}
Status = FfsFindSectionData (EFI_SECTION_GUID_DEFINED, FileHeader,
&SectionData, &SectionDataSize);
Status = FfsFindSectionData (
EFI_SECTION_GUID_DEFINED,
FileHeader,
&SectionData,
&SectionDataSize
);
if (EFI_ERROR (Status)) {
break;
}
Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1);
Status = ExtractGuidedSectionGetInfo (Section, &DstBufferSize,
&ScratchBufferSize, &SectionAttribute);
Status = ExtractGuidedSectionGetInfo (
Section,
&DstBufferSize,
&ScratchBufferSize,
&SectionAttribute
);
if (EFI_ERROR (Status)) {
break;
}
@@ -131,19 +144,29 @@ MmCoreFfsFindMmDriver (
//
// Call decompress function
//
Status = ExtractGuidedSectionDecode (Section, &DstBuffer, ScratchBuffer,
&AuthenticationStatus);
Status = ExtractGuidedSectionDecode (
Section,
&DstBuffer,
ScratchBuffer,
&AuthenticationStatus
);
FreePages (ScratchBuffer, EFI_SIZE_TO_PAGES (ScratchBufferSize));
if (EFI_ERROR (Status)) {
goto FreeDstBuffer;
}
DEBUG ((DEBUG_INFO,
DEBUG ((
DEBUG_INFO,
"Processing compressed firmware volume (AuthenticationStatus == %x)\n",
AuthenticationStatus));
AuthenticationStatus
));
Status = FindFfsSectionInSections (DstBuffer, DstBufferSize,
EFI_SECTION_FIRMWARE_VOLUME_IMAGE, &Section);
Status = FindFfsSectionInSections (
DstBuffer,
DstBufferSize,
EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
&Section
);
if (EFI_ERROR (Status)) {
goto FreeDstBuffer;
}

View File

@@ -36,9 +36,11 @@ MmValidateHandle (
if (Handle == NULL) {
return EFI_INVALID_PARAMETER;
}
if (Handle->Signature != EFI_HANDLE_SIGNATURE) {
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
@@ -68,8 +70,8 @@ MmFindProtocolEntry (
ProtEntry = NULL;
for (Link = mProtocolDatabase.ForwardLink;
Link != &mProtocolDatabase;
Link = Link->ForwardLink) {
Link = Link->ForwardLink)
{
Item = CR (Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
if (CompareGuid (&Item->ProtocolID, Protocol)) {
//
@@ -101,6 +103,7 @@ MmFindProtocolEntry (
InsertTailList (&mProtocolDatabase, &ProtEntry->AllEntries);
}
}
return ProtEntry;
}
@@ -142,12 +145,14 @@ MmFindProtocolInterface (
// If this protocol interface matches, remove it
//
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
if (Prot->Interface == Interface && Prot->Protocol == ProtEntry) {
if ((Prot->Interface == Interface) && (Prot->Protocol == ProtEntry)) {
break;
}
Prot = NULL;
}
}
return Prot;
}
@@ -219,7 +224,7 @@ MmInstallProtocolInterfaceNotify (
// returns EFI_INVALID_PARAMETER if InterfaceType is invalid.
// Also added check for invalid UserHandle and Protocol pointers.
//
if (UserHandle == NULL || Protocol == NULL) {
if ((UserHandle == NULL) || (Protocol == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -320,6 +325,7 @@ MmInstallProtocolInterfaceNotify (
if (Notify) {
MmNotifyProtocol (Prot);
}
Status = EFI_SUCCESS;
Done:
@@ -336,6 +342,7 @@ Done:
FreePool (Prot);
}
}
return Status;
}
@@ -416,6 +423,7 @@ MmUninstallProtocolInterface (
RemoveEntryList (&Handle->AllHandles);
FreePool (Handle);
}
return Status;
}
@@ -457,6 +465,7 @@ MmGetProtocolInterface (
return Prot;
}
}
return NULL;
}

View File

@@ -87,7 +87,6 @@ MmInstallConfigurationTable (
&(ConfigurationTable[Index + 1]),
(gMmCoreMmst.NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)
);
} else {
//
// No matching GUIDs were found, so this is an add operation.

View File

@@ -64,6 +64,7 @@ MmGetNextLocateAllHandles (
if (Position->Position != &gHandleList) {
Handle = CR (Position->Position, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
}
return Handle;
}
@@ -111,6 +112,7 @@ MmGetNextLocateByRegisterNotify (
*Interface = Prot->Interface;
}
}
return Handle;
}
@@ -168,6 +170,7 @@ MmGetNextLocateByProtocol (
break;
}
}
return Handle;
}
@@ -224,6 +227,7 @@ MmLocateProtocol (
if (Position.ProtEntry == NULL) {
return EFI_NOT_FOUND;
}
Position.Position = &Position.ProtEntry->Protocols;
Handle = MmGetNextLocateByProtocol (&Position, Interface);
@@ -319,6 +323,7 @@ MmLocateHandle (
if (SearchKey == NULL) {
Status = EFI_INVALID_PARAMETER;
}
break;
case ByProtocol:
@@ -327,6 +332,7 @@ MmLocateHandle (
Status = EFI_INVALID_PARAMETER;
break;
}
//
// Look up the protocol entry and set the head pointer
//
@@ -335,6 +341,7 @@ MmLocateHandle (
Status = EFI_NOT_FOUND;
break;
}
Position.Position = &Position.ProtEntry->Protocols;
break;
@@ -388,7 +395,7 @@ MmLocateHandle (
*BufferSize = ResultSize;
if (SearchType == ByRegisterNotify && !EFI_ERROR (Status)) {
if ((SearchType == ByRegisterNotify) && !EFI_ERROR (Status)) {
ASSERT (SearchKey != NULL);
//
// If this is a search by register notify and a handle was
@@ -461,10 +468,11 @@ MmLocateHandleBuffer (
//
// Add code to correctly handle expected errors from MmLocateHandle().
//
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
if (Status != EFI_INVALID_PARAMETER) {
Status = EFI_NOT_FOUND;
}
return Status;
}

View File

@@ -65,8 +65,8 @@ MmCoreFindMmiEntry (
MmiEntry = NULL;
for (Link = mMmiEntryList.ForwardLink;
Link != &mMmiEntryList;
Link = Link->ForwardLink) {
Link = Link->ForwardLink)
{
Item = CR (Link, MMI_ENTRY, AllEntries, MMI_ENTRY_SIGNATURE);
if (CompareGuid (&Item->HandlerType, HandlerType)) {
//
@@ -97,6 +97,7 @@ MmCoreFindMmiEntry (
InsertTailList (&mMmiEntryList, &MmiEntry->AllEntries);
}
}
return MmiEntry;
}
@@ -172,6 +173,7 @@ MmiManage (
if (HandlerType != NULL) {
return EFI_INTERRUPT_PENDING;
}
break;
case EFI_SUCCESS:
@@ -183,6 +185,7 @@ MmiManage (
if (HandlerType != NULL) {
return EFI_SUCCESS;
}
SuccessReturn = TRUE;
break;
@@ -240,7 +243,7 @@ MmiHandlerRegister (
MMI_ENTRY *MmiEntry;
LIST_ENTRY *List;
if (Handler == NULL || DispatchHandle == NULL) {
if ((Handler == NULL) || (DispatchHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}

View File

@@ -55,7 +55,6 @@ MmRemoveInterfaceFromProtocol (
Prot = MmFindProtocolInterface (Handle, Protocol, Interface);
if (Prot != NULL) {
ProtEntry = Prot->Protocol;
//
@@ -106,7 +105,7 @@ MmRegisterProtocolNotify (
LIST_ENTRY *Link;
EFI_STATUS Status;
if (Protocol == NULL || Registration == NULL) {
if ((Protocol == NULL) || (Registration == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -119,7 +118,8 @@ MmRegisterProtocolNotify (
ProtNotify = (PROTOCOL_NOTIFY *)*Registration;
for (Link = ProtEntry->Notify.ForwardLink;
Link != &ProtEntry->Notify;
Link = Link->ForwardLink) {
Link = Link->ForwardLink)
{
//
// Compare the notification record
//
@@ -134,6 +134,7 @@ MmRegisterProtocolNotify (
}
}
}
//
// If the registration is not found
//
@@ -152,12 +153,12 @@ MmRegisterProtocolNotify (
//
for (Link = ProtEntry->Notify.ForwardLink;
Link != &ProtEntry->Notify;
Link = Link->ForwardLink) {
Link = Link->ForwardLink)
{
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
if (CompareGuid (&ProtNotify->Protocol->ProtocolID, Protocol) &&
(ProtNotify->Function == Function)) {
(ProtNotify->Function == Function))
{
//
// Notification already exist
//
@@ -193,5 +194,6 @@ MmRegisterProtocolNotify (
*Registration = ProtNotify;
Status = EFI_SUCCESS;
}
return Status;
}

View File

@@ -43,6 +43,7 @@ InternalAllocPagesOnOneNode (
if (Top > Pages->NumberOfPages) {
Top = Pages->NumberOfPages;
}
Bottom = Top - NumberOfPages;
if (Top < Pages->NumberOfPages) {
@@ -82,11 +83,13 @@ InternalAllocMaxAddress (
for (Node = FreePageList->BackLink; Node != FreePageList; Node = Node->BackLink) {
Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
if (Pages->NumberOfPages >= NumberOfPages &&
(UINTN)Pages + EFI_PAGES_TO_SIZE (NumberOfPages) - 1 <= MaxAddress) {
if ((Pages->NumberOfPages >= NumberOfPages) &&
((UINTN)Pages + EFI_PAGES_TO_SIZE (NumberOfPages) - 1 <= MaxAddress))
{
return InternalAllocPagesOnOneNode (Pages, NumberOfPages, MaxAddress);
}
}
return (UINTN)(-1);
}
@@ -122,9 +125,11 @@ InternalAllocAddress (
if ((UINTN)Pages + EFI_PAGES_TO_SIZE (Pages->NumberOfPages) < EndAddress) {
break;
}
return InternalAllocPagesOnOneNode (Pages, NumberOfPages, EndAddress);
}
}
return ~Address;
}
@@ -155,8 +160,9 @@ MmInternalAllocatePages (
{
UINTN RequestedAddress;
if (MemoryType != EfiRuntimeServicesCode &&
MemoryType != EfiRuntimeServicesData) {
if ((MemoryType != EfiRuntimeServicesCode) &&
(MemoryType != EfiRuntimeServicesData))
{
return EFI_INVALID_PARAMETER;
}
@@ -180,6 +186,7 @@ MmInternalAllocatePages (
if (*Memory == (UINTN)-1) {
return EFI_OUT_OF_RESOURCES;
}
break;
case AllocateAddress:
*Memory = InternalAllocAddress (
@@ -190,10 +197,12 @@ MmInternalAllocatePages (
if (*Memory != RequestedAddress) {
return EFI_NOT_FOUND;
}
break;
default:
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
@@ -245,13 +254,15 @@ InternalMergeNodes (
Next = BASE_CR (First->Link.ForwardLink, FREE_PAGE_LIST, Link);
ASSERT (
TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) >= First->NumberOfPages);
TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) >= First->NumberOfPages
);
if (TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) == First->NumberOfPages) {
First->NumberOfPages += Next->NumberOfPages;
RemoveEntryList (&Next->Link);
Next = First;
}
return Next;
}
@@ -287,11 +298,13 @@ MmInternalFreePages (
if (Memory < (UINTN)Pages) {
break;
}
Node = Node->ForwardLink;
}
if (Node != &mMmMemoryMap &&
Memory + EFI_PAGES_TO_SIZE (NumberOfPages) > (UINTN)Pages) {
if ((Node != &mMmMemoryMap) &&
(Memory + EFI_PAGES_TO_SIZE (NumberOfPages) > (UINTN)Pages))
{
return EFI_INVALID_PARAMETER;
}

View File

@@ -38,7 +38,6 @@ MmInitializeMemoryServices (
InitializeListHead (&mMmPoolLists[--Index]);
}
//
// Initialize free MMRAM regions
//
@@ -49,8 +48,14 @@ MmInitializeMemoryServices (
if (MmramRanges[Index].CpuStart < BASE_1MB) {
continue;
}
DEBUG ((DEBUG_INFO, "MmAddMemoryRegion %d : 0x%016lx - 0x%016lx\n",
Index, MmramRanges[Index].CpuStart, MmramRanges[Index].PhysicalSize));
DEBUG ((
DEBUG_INFO,
"MmAddMemoryRegion %d : 0x%016lx - 0x%016lx\n",
Index,
MmramRanges[Index].CpuStart,
MmramRanges[Index].PhysicalSize
));
MmAddMemoryRegion (
MmramRanges[Index].CpuStart,
MmramRanges[Index].PhysicalSize,
@@ -58,7 +63,6 @@ MmInitializeMemoryServices (
MmramRanges[Index].RegionState
);
}
}
/**
@@ -94,6 +98,7 @@ InternalAllocPoolByIndex (
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
Hdr = (FREE_POOL_HEADER *)(UINTN)Address;
} else if (!IsListEmpty (&mMmPoolLists[PoolIndex])) {
Hdr = BASE_CR (GetFirstNode (&mMmPoolLists[PoolIndex]), FREE_POOL_HEADER, Link);
@@ -170,8 +175,9 @@ MmInternalAllocatePool (
EFI_PHYSICAL_ADDRESS Address;
UINTN PoolIndex;
if (PoolType != EfiRuntimeServicesCode &&
PoolType != EfiRuntimeServicesData) {
if ((PoolType != EfiRuntimeServicesCode) &&
(PoolType != EfiRuntimeServicesData))
{
return EFI_INVALID_PARAMETER;
}
@@ -200,6 +206,7 @@ MmInternalAllocatePool (
if (!EFI_ERROR (Status)) {
*Buffer = &FreePoolHdr->Header + 1;
}
return Status;
}
@@ -262,6 +269,7 @@ MmInternalFreePool (
EFI_SIZE_TO_PAGES (FreePoolHdr->Header.Size)
);
}
return InternalFreePoolByIndex (FreePoolHdr);
}

View File

@@ -33,7 +33,6 @@ MM_CORE_PRIVATE_DATA *gMmCorePrivate;
// MM Core global variable for MM System Table. Only accessed as a physical structure in MMRAM.
//
EFI_MM_SYSTEM_TABLE gMmCoreMmst = {
// The table header for the MMST.
{
MM_MMST_SIGNATURE,
@@ -162,6 +161,7 @@ MmExitBootServiceHandler (
NULL
);
}
mInExitBootServices = TRUE;
return Status;
}
@@ -201,6 +201,7 @@ MmReadyToBootHandler (
NULL
);
}
mInReadyToBoot = TRUE;
return Status;
}
@@ -268,7 +269,6 @@ MmReadyToLockHandler (
// DEBUG ((DEBUG_ERROR, "\nSMM: SmmCpuIo Arch Protocol not present!!\n"));
// }
//
// Assert if the CPU I/O 2 Protocol is not installed
//
@@ -323,8 +323,6 @@ MmEndOfDxeHandler (
return Status;
}
/**
The main entry point to MM Foundation.
@@ -476,6 +474,7 @@ GetHobListSize (
while (!END_OF_HOB_LIST (Hob)) {
Hob.Raw = GET_NEXT_HOB (Hob);
}
//
// Need plus END_OF_HOB_LIST
//
@@ -540,8 +539,9 @@ StandaloneMmMain (
// Extract the MMRAM ranges from the MMRAM descriptor HOB
//
MmramRangesHob = GetNextGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, HobStart);
if (MmramRangesHob == NULL)
if (MmramRangesHob == NULL) {
return EFI_UNSUPPORTED;
}
MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
ASSERT (MmramRangesHobData != NULL);
@@ -575,9 +575,13 @@ StandaloneMmMain (
//
DEBUG ((DEBUG_INFO, "MmramRangeCount - 0x%x\n", MmramRangeCount));
for (Index = 0; Index < MmramRangeCount; Index++) {
DEBUG ((DEBUG_INFO, "MmramRanges[%d]: 0x%016lx - 0x%lx\n", Index,
DEBUG ((
DEBUG_INFO,
"MmramRanges[%d]: 0x%016lx - 0x%lx\n",
Index,
MmramRanges[Index].CpuStart,
MmramRanges[Index].PhysicalSize));
MmramRanges[Index].PhysicalSize
));
}
//

View File

@@ -11,7 +11,6 @@
#include <Base.h>
#include <Pi/PiMmCis.h>
#include <Library/ArmSvcLib.h>
#include <Library/ArmLib.h>
#include <Library/BaseMemoryLib.h>
@@ -94,7 +93,8 @@ PiMmStandaloneArmTfCpuDriverEntry (
// between synchronous and asynchronous events.
//
if ((ARM_SMC_ID_MM_COMMUNICATE != EventId) &&
(ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ != EventId)) {
(ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ != EventId))
{
DEBUG ((DEBUG_INFO, "UnRecognized Event - 0x%x\n", EventId));
return EFI_INVALID_PARAMETER;
}
@@ -109,7 +109,8 @@ PiMmStandaloneArmTfCpuDriverEntry (
}
if ((NsCommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=
(mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)) {
(mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize))
{
return EFI_INVALID_PARAMETER;
}
@@ -119,7 +120,8 @@ PiMmStandaloneArmTfCpuDriverEntry (
// perform bounds check.
if (NsCommBufferAddr + NsCommBufferSize >=
mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize) {
mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)
{
return EFI_ACCESS_DENIED;
}
@@ -170,6 +172,7 @@ PiMmStandaloneArmTfCpuDriverEntry (
if (Status != EFI_SUCCESS) {
return EFI_OUT_OF_RESOURCES;
}
PerCpuGuidedEventContext[CpuNumber] = NULL;
return Status;
@@ -232,9 +235,12 @@ PiMmCpuTpFwRootMmiHandler (
return EFI_NOT_FOUND;
}
DEBUG ((DEBUG_INFO, "CommBuffer - 0x%x, CommBufferSize - 0x%x\n",
DEBUG ((
DEBUG_INFO,
"CommBuffer - 0x%x, CommBufferSize - 0x%x\n",
PerCpuGuidedEventContext[CpuNumber],
PerCpuGuidedEventContext[CpuNumber]->MessageLength));
PerCpuGuidedEventContext[CpuNumber]->MessageLength
));
Status = mMmst->MmiManage (
&PerCpuGuidedEventContext[CpuNumber]->HeaderGuid,

View File

@@ -22,7 +22,6 @@
#include <Guid/ZeroGuid.h>
#include <Guid/MmramMemoryReserve.h>
#include "StandaloneMmCpu.h"
// GUID to identify HOB with whereabouts of communication buffer with Normal
@@ -163,9 +162,12 @@ StandaloneMmCpuInitialize (
}
// Share the entry point of the CPU driver
DEBUG ((DEBUG_INFO, "Sharing Cpu Driver EP *0x%lx = 0x%lx\n",
DEBUG ((
DEBUG_INFO,
"Sharing Cpu Driver EP *0x%lx = 0x%lx\n",
(UINTN)CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr,
(UINTN) PiMmStandaloneArmTfCpuDriverEntry));
(UINTN)PiMmStandaloneArmTfCpuDriverEntry
));
*(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) = PiMmStandaloneArmTfCpuDriverEntry;
// Find the descriptor that contains the whereabouts of the buffer for
@@ -220,15 +222,21 @@ StandaloneMmCpuInitialize (
CopyMem (mMpInformationHobData, MpInformationHobData, MpInfoSize);
// Print MP information
DEBUG ((DEBUG_INFO, "mMpInformationHobData: 0x%016lx - 0x%lx\n",
DEBUG ((
DEBUG_INFO,
"mMpInformationHobData: 0x%016lx - 0x%lx\n",
mMpInformationHobData->NumberOfProcessors,
mMpInformationHobData->NumberOfEnabledProcessors));
mMpInformationHobData->NumberOfEnabledProcessors
));
for (Index = 0; Index < mMpInformationHobData->NumberOfProcessors; Index++) {
DEBUG ((DEBUG_INFO, "mMpInformationHobData[0x%lx]: %d, %d, %d\n",
DEBUG ((
DEBUG_INFO,
"mMpInformationHobData[0x%lx]: %d, %d, %d\n",
mMpInformationHobData->ProcessorInfoBuffer[Index].ProcessorId,
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Package,
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Core,
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Thread));
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Thread
));
}
//
@@ -246,5 +254,6 @@ StandaloneMmCpuInitialize (
DEBUG ((DEBUG_INFO, "PerCpuGuidedEventContext mem alloc failed - 0x%x\n", Status));
return Status;
}
return Status;
}

View File

@@ -22,7 +22,6 @@ typedef struct {
EFI_PHYSICAL_ADDRESS Address;
} MM_CORE_DATA_HOB_DATA;
///
/// Define values for the communications buffer used when gEfiEventDxeDispatchGuid is
/// event signaled. This event is signaled by the DXE Core each time the DXE Core

View File

@@ -53,4 +53,3 @@ typedef struct {
extern EFI_GUID gEfiMmPeiSmramMemoryReserveGuid;
#endif

View File

@@ -91,7 +91,6 @@ UpdateMmFoundationPeCoffPermissions (
IN REGION_PERMISSION_UPDATE_FUNC ReadWriteUpdater
);
/**
Privileged firmware assigns RO & Executable attributes to all memory occupied
by the Boot Firmware Volume. This function locates the section information of
@@ -115,7 +114,6 @@ GetStandaloneMmCorePeCoffSections (
IN OUT UINT16 *NumberOfSections
);
/**
Privileged firmware assigns RO & Executable attributes to all memory occupied
by the Boot Firmware Volume. This function locates the Standalone MM Core
@@ -135,7 +133,6 @@ LocateStandaloneMmCorePeCoffData (
IN OUT UINTN *TeDataSize
);
/**
Use the boot information passed by privileged firmware to populate a HOB list
suitable for consumption by the MM Core and drivers.
@@ -152,7 +149,6 @@ CreateHobListFromBootInfo (
IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
);
/**
The entry point of Standalone MM Foundation.
@@ -171,7 +167,6 @@ _ModuleEntryPoint (
IN UINT64 cookie2
);
/**
Auto generated function that calls the library constructors for all of the module's dependent libraries.
@@ -195,7 +190,6 @@ ProcessLibraryConstructorList (
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
);
/**
Auto generated function that calls a set of module entry points.

View File

@@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
///
extern VOID *gHobList;
/**
The entry point of PE/COFF Image for the STANDALONE MM Core.
@@ -35,7 +34,6 @@ _ModuleEntryPoint (
IN VOID *HobStart
);
/**
Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
@@ -50,7 +48,6 @@ EfiMain (
IN VOID *HobStart
);
/**
Auto generated function that calls the library constructors for all of the module's dependent libraries.
@@ -74,7 +71,6 @@ ProcessLibraryConstructorList (
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
);
/**
Autogenerated function that calls a set of module entry points.

View File

@@ -77,6 +77,7 @@ CalculateHeaderChecksum (
for ( ; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
Sum = (UINT8)(Sum + ptr[Index]);
}
//
// State field (since this indicates the different state of file).
//
@@ -128,30 +129,29 @@ FfsFindNextFile (
} else {
ErasePolarity = 0;
}
//
// If FileHeader is not specified (NULL) start with the first file in the
// firmware volume. Otherwise, start from the FileHeader.
//
if (*FileHeader == NULL) {
if (FwVolHeader->ExtHeaderOffset != 0) {
FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)((UINT8 *)FwVolHeader +
FwVolHeader->ExtHeaderOffset);
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FvExtHeader +
FvExtHeader->ExtHeaderSize);
} else {
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader +
FwVolHeader->HeaderLength);
}
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FwVolHeader +
ALIGN_VALUE((UINTN)FfsFileHeader -
(UINTN)FwVolHeader, 8));
ALIGN_VALUE (
(UINTN)FfsFileHeader -
(UINTN)FwVolHeader,
8
));
} else {
//
// Length is 24 bits wide so mask upper 8 bits
@@ -171,7 +171,6 @@ FfsFindNextFile (
FileState = GetFileState (ErasePolarity, FfsFileHeader);
switch (FileState) {
case EFI_FILE_HEADER_INVALID:
FileOffset += sizeof (EFI_FFS_FILE_HEADER);
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
@@ -184,7 +183,6 @@ FfsFindNextFile (
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
*FileHeader = FfsFileHeader;
return EFI_SUCCESS;
@@ -195,6 +193,7 @@ FfsFindNextFile (
} else {
return EFI_NOT_FOUND;
}
break;
case EFI_FILE_DELETED:
@@ -206,7 +205,6 @@ FfsFindNextFile (
default:
return EFI_NOT_FOUND;
}
}
@@ -250,6 +248,7 @@ FindFfsSectionInSections (
if (EndOfSection == EndOfSections) {
break;
}
CurrentAddress = EndOfSection;
Section = (EFI_COMMON_SECTION_HEADER *)(UINTN)CurrentAddress;
@@ -263,6 +262,7 @@ FindFfsSectionInSections (
if (EndOfSection > EndOfSections) {
return EFI_VOLUME_CORRUPTED;
}
Size = GET_OCCUPIED_SIZE (Size, 4);
//
@@ -363,6 +363,7 @@ FfsFindSectionData (
*SectionDataSize = SECTION_SIZE (Section);
return EFI_SUCCESS;
}
//
// Size is 24 bits wide so mask upper 8 bits.
// SectionLength is adjusted it is 4 byte aligned.

View File

@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiMm.h>
#include <PiPei.h>
@@ -128,6 +127,7 @@ CreateHobListFromBootInfo (
if (CpuInfo[Index].Flags & CPU_INFO_FLAG_PRIMARY_CPU) {
Flags |= PROCESSOR_AS_BSP_BIT;
}
ProcInfoBuffer[Index].StatusFlag = Flags;
}

View File

@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiMm.h>
#include <PiPei.h>
@@ -78,25 +77,47 @@ UpdateMmFoundationPeCoffPermissions (
);
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: ImageContext->ImageRead () failed (Status = %r)\n",
__FUNCTION__, Status));
__FUNCTION__,
Status
));
return Status;
}
DEBUG ((DEBUG_INFO,
DEBUG ((
DEBUG_INFO,
"%a: Section %d of image at 0x%lx has 0x%x permissions\n",
__FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.Characteristics));
DEBUG ((DEBUG_INFO,
__FUNCTION__,
Index,
ImageContext->ImageAddress,
SectionHeader.Characteristics
));
DEBUG ((
DEBUG_INFO,
"%a: Section %d of image at 0x%lx has %a name\n",
__FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.Name));
DEBUG ((DEBUG_INFO,
__FUNCTION__,
Index,
ImageContext->ImageAddress,
SectionHeader.Name
));
DEBUG ((
DEBUG_INFO,
"%a: Section %d of image at 0x%lx has 0x%x address\n",
__FUNCTION__, Index, ImageContext->ImageAddress,
ImageContext->ImageAddress + SectionHeader.VirtualAddress));
DEBUG ((DEBUG_INFO,
__FUNCTION__,
Index,
ImageContext->ImageAddress,
ImageContext->ImageAddress + SectionHeader.VirtualAddress
));
DEBUG ((
DEBUG_INFO,
"%a: Section %d of image at 0x%lx has 0x%x data\n",
__FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.PointerToRawData));
__FUNCTION__,
Index,
ImageContext->ImageAddress,
SectionHeader.PointerToRawData
));
//
// If the section is marked as XN then remove the X attribute. Furthermore,
@@ -109,19 +130,33 @@ UpdateMmFoundationPeCoffPermissions (
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_WRITE) != 0) {
ReadWriteUpdater (Base, SectionHeader.Misc.VirtualSize);
DEBUG ((DEBUG_INFO,
DEBUG ((
DEBUG_INFO,
"%a: Mapping section %d of image at 0x%lx with RW-XN permissions\n",
__FUNCTION__, Index, ImageContext->ImageAddress));
__FUNCTION__,
Index,
ImageContext->ImageAddress
));
} else {
DEBUG ((DEBUG_INFO,
DEBUG ((
DEBUG_INFO,
"%a: Mapping section %d of image at 0x%lx with RO-XN permissions\n",
__FUNCTION__, Index, ImageContext->ImageAddress));
__FUNCTION__,
Index,
ImageContext->ImageAddress
));
}
} else {
DEBUG ((DEBUG_INFO,
DEBUG ((
DEBUG_INFO,
"%a: Ignoring section %d of image at 0x%lx with 0x%x permissions\n",
__FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.Characteristics));
__FUNCTION__,
Index,
ImageContext->ImageAddress,
SectionHeader.Characteristics
));
}
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
}
@@ -158,8 +193,11 @@ LocateStandaloneMmCorePeCoffData (
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM FFS file - 0x%x\n",
Status));
DEBUG ((
DEBUG_ERROR,
"Unable to locate Standalone MM FFS file - 0x%x\n",
Status
));
return Status;
}
@@ -167,8 +205,11 @@ LocateStandaloneMmCorePeCoffData (
if (EFI_ERROR (Status)) {
Status = FfsFindSectionData (EFI_SECTION_TE, FileHeader, TeData, TeDataSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Section data - %r\n",
Status));
DEBUG ((
DEBUG_ERROR,
"Unable to locate Standalone MM Section data - %r\n",
Status
));
return Status;
}
}
@@ -207,9 +248,12 @@ GetPeCoffSectionInformation (
Status = PeCoffLoaderGetImageInfo (ImageContext);
if (RETURN_ERROR (Status)) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: PeCoffLoaderGetImageInfo () failed (Status == %r)\n",
__FUNCTION__, Status));
__FUNCTION__,
Status
));
return Status;
}
@@ -219,11 +263,16 @@ GetPeCoffSectionInformation (
// granularity at which we can tighten permissions.
//
if (!ImageContext->IsTeImage) {
DEBUG ((DEBUG_WARN,
DEBUG ((
DEBUG_WARN,
"%a: non-TE Image at 0x%lx has SectionAlignment < 4 KB (%lu)\n",
__FUNCTION__, ImageContext->ImageAddress, ImageContext->SectionAlignment));
__FUNCTION__,
ImageContext->ImageAddress,
ImageContext->SectionAlignment
));
return RETURN_UNSUPPORTED;
}
ImageContext->SectionAlignment = EFI_PAGE_SIZE;
}
@@ -244,9 +293,12 @@ GetPeCoffSectionInformation (
);
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: TmpContext->ImageRead () failed (Status = %r)\n",
__FUNCTION__, Status));
__FUNCTION__,
Status
));
return Status;
}
@@ -273,6 +325,7 @@ GetPeCoffSectionInformation (
*NumberOfSections = Hdr.Te->NumberOfSections;
*ImageBase -= (UINT32)Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER);
}
return RETURN_SUCCESS;
}
@@ -308,15 +361,23 @@ GetStandaloneMmCorePeCoffSections (
DEBUG ((DEBUG_INFO, "Found Standalone MM PE data - 0x%x\n", TeData));
Status = GetPeCoffSectionInformation (ImageContext, ImageBase,
SectionHeaderOffset, NumberOfSections);
Status = GetPeCoffSectionInformation (
ImageContext,
ImageBase,
SectionHeaderOffset,
NumberOfSections
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Core PE-COFF Section information - %r\n", Status));
return Status;
}
DEBUG ((DEBUG_INFO, "Standalone MM Core PE-COFF SectionHeaderOffset - 0x%x, NumberOfSections - %d\n",
*SectionHeaderOffset, *NumberOfSections));
DEBUG ((
DEBUG_INFO,
"Standalone MM Core PE-COFF SectionHeaderOffset - 0x%x, NumberOfSections - %d\n",
*SectionHeaderOffset,
*NumberOfSections
));
return Status;
}

View File

@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiMm.h>
#include <Library/Arm/StandaloneMmCoreEntryPoint.h>
@@ -69,8 +68,12 @@ GetAndPrintBootinformation (
}
if (PayloadBootInfo->Header.Version != BOOT_PAYLOAD_VERSION) {
DEBUG ((DEBUG_ERROR, "Boot Information Version Mismatch. Current=0x%x, Expected=0x%x.\n",
PayloadBootInfo->Header.Version, BOOT_PAYLOAD_VERSION));
DEBUG ((
DEBUG_ERROR,
"Boot Information Version Mismatch. Current=0x%x, Expected=0x%x.\n",
PayloadBootInfo->Header.Version,
BOOT_PAYLOAD_VERSION
));
return NULL;
}
@@ -145,8 +148,12 @@ DelegatedEventLoop (
EventCompleteSvcArgs->Arg3
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n",
EventCompleteSvcArgs->Arg3, Status));
DEBUG ((
DEBUG_ERROR,
"Failed delegated event 0x%x, Status 0x%x\n",
EventCompleteSvcArgs->Arg3,
Status
));
}
} else {
Status = CpuDriverEntryPoint (
@@ -155,8 +162,12 @@ DelegatedEventLoop (
EventCompleteSvcArgs->Arg1
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n",
EventCompleteSvcArgs->Arg0, Status));
DEBUG ((
DEBUG_ERROR,
"Failed delegated event 0x%x, Status 0x%x\n",
EventCompleteSvcArgs->Arg0,
Status
));
}
}
@@ -202,7 +213,9 @@ DelegatedEventLoop (
**/
STATIC
EFI_STATUS
GetSpmVersion (VOID)
GetSpmVersion (
VOID
)
{
EFI_STATUS Status;
UINT16 CalleeSpmMajorVer;
@@ -244,14 +257,22 @@ GetSpmVersion (VOID)
if ((CalleeSpmMajorVer == CallerSpmMajorVer) &&
(CalleeSpmMinorVer >= CallerSpmMinorVer))
{
DEBUG ((DEBUG_INFO, "SPM Version: Major=0x%x, Minor=0x%x\n",
CalleeSpmMajorVer, CalleeSpmMinorVer));
DEBUG ((
DEBUG_INFO,
"SPM Version: Major=0x%x, Minor=0x%x\n",
CalleeSpmMajorVer,
CalleeSpmMinorVer
));
Status = EFI_SUCCESS;
}
else
{
DEBUG ((DEBUG_INFO, "Incompatible SPM Versions.\n Callee Version: Major=0x%x, Minor=0x%x.\n Caller: Major=0x%x, Minor>=0x%x.\n",
CalleeSpmMajorVer, CalleeSpmMinorVer, CallerSpmMajorVer, CallerSpmMinorVer));
} else {
DEBUG ((
DEBUG_INFO,
"Incompatible SPM Versions.\n Callee Version: Major=0x%x, Minor=0x%x.\n Caller: Major=0x%x, Minor>=0x%x.\n",
CalleeSpmMajorVer,
CalleeSpmMinorVer,
CallerSpmMajorVer,
CallerSpmMinorVer
));
Status = EFI_UNSUPPORTED;
}
@@ -407,6 +428,7 @@ finish:
} else {
Ret = 0;
}
ZeroMem (&InitMmFoundationSvcArgs, sizeof (InitMmFoundationSvcArgs));
InitArmSvcArgs (&InitMmFoundationSvcArgs, &Ret);
DelegatedEventLoop (&InitMmFoundationSvcArgs);

View File

@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiMm.h>
#include <Library/StandaloneMmCoreEntryPoint.h>
@@ -52,7 +51,6 @@ _ModuleEntryPoint (
//
}
/**
Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().

View File

@@ -83,8 +83,10 @@ BuildModuleHob (
{
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
ASSERT (
((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
@@ -169,7 +171,6 @@ BuildGuidHob (
return Hob + 1;
}
/**
Copies a data buffer to a newly-built HOB.
@@ -230,7 +231,6 @@ BuildFvHob (
Hob->Length = Length;
}
/**
Builds a EFI_HOB_TYPE_FV2 HOB.
@@ -262,7 +262,6 @@ BuildFv2Hob (
CopyGuid (&Hob->FileName, FileName);
}
/**
Builds a HOB for the CPU.
@@ -314,8 +313,10 @@ BuildMemoryAllocationHob (
{
EFI_HOB_MEMORY_ALLOCATION *Hob;
ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
((Length & (EFI_PAGE_SIZE - 1)) == 0));
ASSERT (
((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
((Length & (EFI_PAGE_SIZE - 1)) == 0)
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));

View File

@@ -72,8 +72,10 @@ GetNextHob (
if (Hob.Header->HobType == Type) {
return Hob.Raw;
}
Hob.Raw = GET_NEXT_HOB (Hob);
}
return NULL;
}
@@ -138,8 +140,10 @@ GetNextGuidHob (
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
break;
}
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
}
return GuidHob.Raw;
}
@@ -199,7 +203,6 @@ GetBootModeHob (
return HandOffHob->BootMode;
}
/**
Builds a HOB that describes a chunk of system memory with Owner GUID.
@@ -247,7 +250,6 @@ BuildCvHob (
ASSERT (FALSE);
}
/**
Builds a HOB for the BSP store.

View File

@@ -49,6 +49,7 @@ InternalAllocatePages (
if (EFI_ERROR (Status)) {
return NULL;
}
return (VOID *)(UINTN)Memory;
}
@@ -189,6 +190,7 @@ InternalAllocateAlignedPages (
if (Pages == 0) {
return NULL;
}
if (Alignment > EFI_PAGE_SIZE) {
//
// Calculate the total number of pages since alignment is larger than page size.
@@ -204,6 +206,7 @@ InternalAllocateAlignedPages (
if (EFI_ERROR (Status)) {
return NULL;
}
AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
if (UnalignedPages > 0) {
@@ -213,6 +216,7 @@ InternalAllocateAlignedPages (
Status = gMmst->MmFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
Memory = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
@@ -230,8 +234,10 @@ InternalAllocateAlignedPages (
if (EFI_ERROR (Status)) {
return NULL;
}
AlignedMemory = (UINTN)Memory;
}
return (VOID *)AlignedMemory;
}
@@ -378,6 +384,7 @@ InternalAllocatePool (
if (EFI_ERROR (Status)) {
Memory = NULL;
}
return Memory;
}
@@ -470,6 +477,7 @@ InternalAllocateZeroPool (
if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
return Memory;
}
@@ -572,6 +580,7 @@ InternalAllocateCopyPool (
if (Memory != NULL) {
Memory = CopyMem (Memory, Buffer, AllocationSize);
}
return Memory;
}
@@ -689,10 +698,11 @@ InternalReallocatePool (
VOID *NewBuffer;
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
if (NewBuffer != NULL && OldBuffer != NULL) {
if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
FreePool (OldBuffer);
}
return NewBuffer;
}
@@ -872,7 +882,6 @@ MemoryAllocationLibConstructor (
if (MmramRanges == NULL) {
return EFI_UNSUPPORTED;
}
} else {
DataInHob = GET_GUID_HOB_DATA (GuidHob);
MmCorePrivate = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
@@ -885,8 +894,13 @@ MemoryAllocationLibConstructor (
DEBUG ((DEBUG_INFO, "MmramRangeCount - 0x%x\n", MmramRangeCount));
for (Index = 0; Index < MmramRangeCount; Index++) {
DEBUG ((DEBUG_INFO, "MmramRanges[%d]: 0x%016lx - 0x%016lx\n",
Index, MmramRanges[Index].CpuStart, MmramRanges[Index].PhysicalSize));
DEBUG ((
DEBUG_INFO,
"MmramRanges[%d]: 0x%016lx - 0x%016lx\n",
Index,
MmramRanges[Index].CpuStart,
MmramRanges[Index].PhysicalSize
));
}
}

View File

@@ -49,6 +49,7 @@ HobLibConstructor (
break;
}
}
return EFI_SUCCESS;
}
@@ -77,6 +78,7 @@ GetHobList (
}
}
}
ASSERT (gHobList != NULL);
return gHobList;
}
@@ -117,8 +119,10 @@ GetNextHob (
if (Hob.Header->HobType == Type) {
return Hob.Raw;
}
Hob.Raw = GET_NEXT_HOB (Hob);
}
return NULL;
}
@@ -183,8 +187,10 @@ GetNextGuidHob (
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
break;
}
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
}
return GuidHob.Raw;
}
@@ -306,8 +312,10 @@ BuildModuleHob (
{
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
ASSERT (
((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
@@ -392,7 +400,6 @@ BuildGuidHob (
return Hob + 1;
}
/**
Copies a data buffer to a newly-built HOB.
@@ -453,7 +460,6 @@ BuildFvHob (
Hob->Length = Length;
}
/**
Builds a EFI_HOB_TYPE_FV2 HOB.
@@ -485,7 +491,6 @@ BuildFv2Hob (
CopyGuid (&Hob->FileName, FileName);
}
/**
Builds a HOB for the CPU.
@@ -537,8 +542,10 @@ BuildMemoryAllocationHob (
{
EFI_HOB_MEMORY_ALLOCATION *Hob;
ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
((Length & (EFI_PAGE_SIZE - 1)) == 0));
ASSERT (
((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
((Length & (EFI_PAGE_SIZE - 1)) == 0)
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
@@ -599,7 +606,6 @@ BuildCvHob (
ASSERT (FALSE);
}
/**
Builds a HOB for the BSP store.

View File

@@ -74,4 +74,3 @@ MmMemLibInternalFreeMmramRanges (
{
// Not implemented for AARCH64.
}

View File

@@ -13,7 +13,6 @@
**/
#include <PiMm.h>
#include <Library/BaseLib.h>
@@ -82,7 +81,8 @@ MmIsBufferOutsideMmValid (
//
if ((Length > mMmMemLibInternalMaximumSupportAddress) ||
(Buffer > mMmMemLibInternalMaximumSupportAddress) ||
((Length != 0) && (Buffer > (mMmMemLibInternalMaximumSupportAddress - (Length - 1)))) ) {
((Length != 0) && (Buffer > (mMmMemLibInternalMaximumSupportAddress - (Length - 1)))))
{
//
// Overflow happen
//
@@ -100,7 +100,8 @@ MmIsBufferOutsideMmValid (
if (((Buffer >= mMmMemLibInternalMmramRanges[Index].CpuStart) &&
(Buffer < mMmMemLibInternalMmramRanges[Index].CpuStart + mMmMemLibInternalMmramRanges[Index].PhysicalSize)) ||
((mMmMemLibInternalMmramRanges[Index].CpuStart >= Buffer) &&
(mMmMemLibInternalMmramRanges[Index].CpuStart < Buffer + Length))) {
(mMmMemLibInternalMmramRanges[Index].CpuStart < Buffer + Length)))
{
DEBUG ((
DEBUG_ERROR,
"MmIsBufferOutsideMmValid: Overlap: Buffer (0x%lx) - Length (0x%lx), ",
@@ -149,6 +150,7 @@ MmCopyMemToMmram (
DEBUG ((DEBUG_ERROR, "MmCopyMemToMmram: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));
return EFI_SECURITY_VIOLATION;
}
CopyMem (DestinationBuffer, SourceBuffer, Length);
return EFI_SUCCESS;
}
@@ -179,10 +181,15 @@ MmCopyMemFromMmram (
)
{
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {
DEBUG ((DEBUG_ERROR, "MmCopyMemFromMmram: Security Violation: Destination (0x%x), Length (0x%x)\n",
DestinationBuffer, Length));
DEBUG ((
DEBUG_ERROR,
"MmCopyMemFromMmram: Security Violation: Destination (0x%x), Length (0x%x)\n",
DestinationBuffer,
Length
));
return EFI_SECURITY_VIOLATION;
}
CopyMem (DestinationBuffer, SourceBuffer, Length);
return EFI_SUCCESS;
}
@@ -214,14 +221,20 @@ MmCopyMem (
)
{
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {
DEBUG ((DEBUG_ERROR, "MmCopyMem: Security Violation: Destination (0x%x), Length (0x%x)\n",
DestinationBuffer, Length));
DEBUG ((
DEBUG_ERROR,
"MmCopyMem: Security Violation: Destination (0x%x), Length (0x%x)\n",
DestinationBuffer,
Length
));
return EFI_SECURITY_VIOLATION;
}
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)SourceBuffer, Length)) {
DEBUG ((DEBUG_ERROR, "MmCopyMem: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));
return EFI_SECURITY_VIOLATION;
}
CopyMem (DestinationBuffer, SourceBuffer, Length);
return EFI_SUCCESS;
}
@@ -254,6 +267,7 @@ MmSetMem (
DEBUG ((DEBUG_ERROR, "MmSetMem: Security Violation: Source (0x%x), Length (0x%x)\n", Buffer, Length));
return EFI_SECURITY_VIOLATION;
}
SetMem (Buffer, Length, Value);
return EFI_SUCCESS;
}
@@ -305,7 +319,6 @@ MemLibDestructor (
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
)
{
//
// Deinitialize cached Mmram Ranges.
//

View File

@@ -58,6 +58,7 @@ MmMemLibInternalCalculateMaximumSupportAddress (
PhysicalAddressBits = 36;
}
}
//
// IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses.
//
@@ -108,7 +109,7 @@ MmMemLibInternalPopulateMmramRanges (
}
MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
if (MmramRangesHobData == NULL || MmramRangesHobData->Descriptor == NULL) {
if ((MmramRangesHobData == NULL) || (MmramRangesHobData->Descriptor == NULL)) {
return EFI_UNSUPPORTED;
}
@@ -121,7 +122,7 @@ MmMemLibInternalPopulateMmramRanges (
}
MmCorePrivateData = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
if (MmCorePrivateData == NULL || MmCorePrivateData->MmramRanges == 0) {
if ((MmCorePrivateData == NULL) || (MmCorePrivateData->MmramRanges == 0)) {
return EFI_UNSUPPORTED;
}
@@ -131,9 +132,11 @@ MmMemLibInternalPopulateMmramRanges (
mMmMemLibInternalMmramRanges = AllocatePool (mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR));
if (mMmMemLibInternalMmramRanges) {
CopyMem (mMmMemLibInternalMmramRanges,
CopyMem (
mMmMemLibInternalMmramRanges,
MmramDescriptors,
mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR));
mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR)
);
}
return EFI_SUCCESS;
@@ -152,4 +155,3 @@ MmMemLibInternalFreeMmramRanges (
FreePool (mMmMemLibInternalMmramRanges);
}
}

View File

@@ -45,6 +45,7 @@ InternalAllocatePages (
if (EFI_ERROR (Status)) {
return NULL;
}
return (VOID *)(UINTN)Memory;
}
@@ -185,6 +186,7 @@ InternalAllocateAlignedPages (
if (Pages == 0) {
return NULL;
}
if (Alignment > EFI_PAGE_SIZE) {
//
// Calculate the total number of pages since alignment is larger than page size.
@@ -200,6 +202,7 @@ InternalAllocateAlignedPages (
if (EFI_ERROR (Status)) {
return NULL;
}
AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
if (UnalignedPages > 0) {
@@ -209,6 +212,7 @@ InternalAllocateAlignedPages (
Status = gMmst->MmFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
Memory = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
@@ -226,8 +230,10 @@ InternalAllocateAlignedPages (
if (EFI_ERROR (Status)) {
return NULL;
}
AlignedMemory = (UINTN)Memory;
}
return (VOID *)AlignedMemory;
}
@@ -374,6 +380,7 @@ InternalAllocatePool (
if (EFI_ERROR (Status)) {
Memory = NULL;
}
return Memory;
}
@@ -466,6 +473,7 @@ InternalAllocateZeroPool (
if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
return Memory;
}
@@ -568,6 +576,7 @@ InternalAllocateCopyPool (
if (Memory != NULL) {
Memory = CopyMem (Memory, Buffer, AllocationSize);
}
return Memory;
}
@@ -685,10 +694,11 @@ InternalReallocatePool (
VOID *NewBuffer;
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
if (NewBuffer != NULL && OldBuffer != NULL) {
if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
FreePool (OldBuffer);
}
return NewBuffer;
}

View File

@@ -52,17 +52,25 @@ UpdatePeCoffPermissions (
if (TmpContext.PeCoffHeaderOffset == 0) {
Status = PeCoffLoaderGetImageInfo (&TmpContext);
if (RETURN_ERROR (Status)) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: PeCoffLoaderGetImageInfo () failed (Status = %r)\n",
__FUNCTION__, Status));
__FUNCTION__,
Status
));
return Status;
}
}
if (TmpContext.IsTeImage &&
TmpContext.ImageAddress == ImageContext->ImageAddress) {
DEBUG ((DEBUG_INFO, "%a: ignoring XIP TE image at 0x%lx\n", __FUNCTION__,
ImageContext->ImageAddress));
(TmpContext.ImageAddress == ImageContext->ImageAddress))
{
DEBUG ((
DEBUG_INFO,
"%a: ignoring XIP TE image at 0x%lx\n",
__FUNCTION__,
ImageContext->ImageAddress
));
return RETURN_SUCCESS;
}
@@ -73,10 +81,15 @@ UpdatePeCoffPermissions (
// noexec permissions on the entire region.
//
if (!TmpContext.IsTeImage) {
DEBUG ((DEBUG_WARN,
DEBUG ((
DEBUG_WARN,
"%a: non-TE Image at 0x%lx has SectionAlignment < 4 KB (%lu)\n",
__FUNCTION__, ImageContext->ImageAddress, TmpContext.SectionAlignment));
__FUNCTION__,
ImageContext->ImageAddress,
TmpContext.SectionAlignment
));
}
Base = ImageContext->ImageAddress & ~(EFI_PAGE_SIZE - 1);
Size = ImageContext->ImageAddress - Base + ImageContext->ImageSize;
return NoExecUpdater (Base, ALIGN_VALUE (Size, EFI_PAGE_SIZE));
@@ -91,12 +104,19 @@ UpdatePeCoffPermissions (
Hdr.Union = &HdrData;
Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);
ReadSize = Size;
Status = TmpContext.ImageRead (TmpContext.Handle,
TmpContext.PeCoffHeaderOffset, &Size, Hdr.Pe32);
Status = TmpContext.ImageRead (
TmpContext.Handle,
TmpContext.PeCoffHeaderOffset,
&Size,
Hdr.Pe32
);
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: TmpContext.ImageRead () failed (Status = %r)\n",
__FUNCTION__, Status));
__FUNCTION__,
Status
));
return Status;
}
@@ -126,40 +146,61 @@ UpdatePeCoffPermissions (
//
Size = sizeof (EFI_IMAGE_SECTION_HEADER);
ReadSize = Size;
Status = TmpContext.ImageRead (TmpContext.Handle, SectionHeaderOffset,
&Size, &SectionHeader);
Status = TmpContext.ImageRead (
TmpContext.Handle,
SectionHeaderOffset,
&Size,
&SectionHeader
);
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: TmpContext.ImageRead () failed (Status = %r)\n",
__FUNCTION__, Status));
__FUNCTION__,
Status
));
return Status;
}
Base = TmpContext.ImageAddress + SectionHeader.VirtualAddress;
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) == 0) {
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_WRITE) == 0) {
DEBUG ((DEBUG_INFO,
DEBUG ((
DEBUG_INFO,
"%a: Mapping section %d of image at 0x%lx with RO-XN permissions and size 0x%x\n",
__FUNCTION__, Index, Base, SectionHeader.Misc.VirtualSize));
__FUNCTION__,
Index,
Base,
SectionHeader.Misc.VirtualSize
));
ReadOnlyUpdater (Base, SectionHeader.Misc.VirtualSize);
} else {
DEBUG ((DEBUG_WARN,
DEBUG ((
DEBUG_WARN,
"%a: Mapping section %d of image at 0x%lx with RW-XN permissions and size 0x%x\n",
__FUNCTION__, Index, Base, SectionHeader.Misc.VirtualSize));
__FUNCTION__,
Index,
Base,
SectionHeader.Misc.VirtualSize
));
}
} else {
DEBUG ((DEBUG_INFO,
DEBUG ((
DEBUG_INFO,
"%a: Mapping section %d of image at 0x%lx with RO-X permissions and size 0x%x\n",
__FUNCTION__, Index, Base, SectionHeader.Misc.VirtualSize));
__FUNCTION__,
Index,
Base,
SectionHeader.Misc.VirtualSize
));
ReadOnlyUpdater (Base, SectionHeader.Misc.VirtualSize);
NoExecUpdater (Base, SectionHeader.Misc.VirtualSize);
}
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
}
return RETURN_SUCCESS;
}
@@ -185,8 +226,6 @@ PeCoffLoaderRelocateImageExtraAction (
);
}
/**
Performs additional actions just before a PE/COFF image is unloaded. Any resources
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.