Skip to content

Commit 381bf9f

Browse files
committed
StandaloneMmPkg: StandaloneMmIplPei: Handle return status from MmAccess
This change adds some logic to handle the MmAccess PPI failure and makes effort to close and lock all regions when possible. Signed-off-by: Kun Qin <[email protected]>
1 parent 49688b1 commit 381bf9f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ ExecuteMmCoreFromMmram (
655655
)
656656
{
657657
EFI_STATUS Status;
658+
EFI_STATUS AccessStatus; // MU_CHANGE: Separate variable to avoid overwriting Status
658659
UINTN PageCount;
659660
VOID *MmHobList;
660661
UINTN MmHobSize;
@@ -801,13 +802,15 @@ ExecuteMmCoreFromMmram (
801802
// Close all MMRAM ranges, if MmAccess is available.
802803
//
803804
for (Index = 0; Index < MmramRangeCount; Index++) {
804-
Status = MmAccess->Close ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), MmAccess, Index);
805-
if (EFI_ERROR (Status)) {
806-
DEBUG ((DEBUG_ERROR, "MM IPL failed to close MMRAM windows index %d - %r\n", Index, Status));
805+
// MU_CHANGE START: Will not return if error occurs
806+
AccessStatus = MmAccess->Close ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), MmAccess, Index);
807+
if (EFI_ERROR (AccessStatus)) {
808+
DEBUG ((DEBUG_ERROR, "MM IPL failed to close MMRAM windows index %d - %r\n", Index, AccessStatus));
807809
ASSERT (FALSE);
808-
return Status;
809810
}
810811

812+
// MU_CHANGE END: Will not return if error occurs
813+
811814
//
812815
// Print debug message that the MMRAM window is now closed.
813816
//
@@ -816,18 +819,20 @@ ExecuteMmCoreFromMmram (
816819
//
817820
// Lock the MMRAM (Note: Locking MMRAM may not be supported on all platforms)
818821
//
819-
Status = MmAccess->Lock ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), MmAccess, Index);
820-
if (EFI_ERROR (Status)) {
822+
// MU_CHANGE START: Will not return if error occurs and allow UNSUPPORTED
823+
AccessStatus = MmAccess->Lock ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), MmAccess, Index);
824+
if (EFI_ERROR (AccessStatus) && (AccessStatus != EFI_UNSUPPORTED)) {
821825
//
822826
// Print error message that the MMRAM failed to lock...
823827
//
824-
DEBUG ((DEBUG_ERROR, "MM IPL could not lock MMRAM (Index %d) after executing MM Core %r\n", Index, Status));
828+
DEBUG ((DEBUG_ERROR, "MM IPL could not lock MMRAM (Index %d) after executing MM Core %r\n", Index, AccessStatus));
825829
ASSERT (FALSE);
826-
return Status;
827830
}
828831

832+
// MU_CHANGE END: Will not return if error occurs and allow UNSUPPORTED
833+
829834
//
830-
// Print debug message that the MMRAM window is now closed.
835+
// Print debug message that the MMRAM window is now locked.
831836
//
832837
DEBUG ((DEBUG_INFO, "MM IPL locked MMRAM window index %d\n", Index));
833838
}

0 commit comments

Comments
 (0)