Skip to content

Commit

Permalink
Revert "MdeModulePkg: Updates Debug Statements for Mem/Page.c"
Browse files Browse the repository at this point in the history
This reverts commit 76f8060.

This commit was from an earlier era of Project Mu where we were
not as strict with memory protections. Now that we are more strict,
these are important prints (and failures if alignment of a RUNTIME
entry is wrong). This was confirmed by booting on Q35 and analyzing
the few prints that showed up.

The first was that Rust code was not being linked as we expected,
that is fixed here: microsoft/mu_devops#356.
This may get fixed in a different way that is more broad. See the
PR for this commit for more details on the failure seen.

The other set of failures was from gDS->SetMemorySpaceCapabilities()
trying to set attributes in gMemoryMap on GCD memory types that
don't exist there and an edk2 PR has been put up to fix that:
tianocore/edk2#6062.

There are no other failures seen and when these failures do occur,
we want to debug them.
  • Loading branch information
os-d committed Aug 7, 2024
1 parent 63fc132 commit a81517e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions MdeModulePkg/Core/Dxe/Mem/Page.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ CoreConvertPagesEx (
}

if (Link == &gMemoryMap) {
DEBUG ((DEBUG_PAGE, "ConvertPages: failed to find range %lx - %lx\n", Start, End)); // MU_CHANGE
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: failed to find range %lx - %lx\n", Start, End));
return EFI_NOT_FOUND;
}

Expand All @@ -900,8 +900,7 @@ CoreConvertPagesEx (
//
if (ChangingType && (NewType != EfiConventionalMemory)) {
if (Entry->End < End) {
// MU_CHANGE: remove this debug print since within debug print there is another allocate pages call
// DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: range %lx - %lx covers multiple entries\n", Start, End));
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: range %lx - %lx covers multiple entries\n", Start, End));
return EFI_NOT_FOUND;
}
}
Expand Down Expand Up @@ -930,11 +929,11 @@ CoreConvertPagesEx (
// Debug code - verify conversion is allowed
//
if (!((NewType == EfiConventionalMemory) ? 1 : 0) ^ ((Entry->Type == EfiConventionalMemory) ? 1 : 0)) {
DEBUG ((DEBUG_PAGE, "ConvertPages: Incompatible memory types, ")); // MU_CHANGE
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible memory types, "));
if (Entry->Type == EfiConventionalMemory) {
DEBUG ((DEBUG_PAGE, "the pages to free have been freed\n")); // MU_CHANGE
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "the pages to free have been freed\n"));
} else {
DEBUG ((DEBUG_PAGE, "the pages to allocate have been allocated\n")); // MU_CHANGE
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "the pages to allocate have been allocated\n"));
}

return EFI_NOT_FOUND;
Expand Down Expand Up @@ -2248,7 +2247,7 @@ CoreAllocatePoolPages (
// Convert it to boot services data
//
if (Start == 0) {
DEBUG ((DEBUG_PAGE, "AllocatePoolPages: failed to allocate %d pages\n", (UINT32)NumberOfPages)); // MU_CHANGE
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "AllocatePoolPages: failed to allocate %d pages\n", (UINT32)NumberOfPages));
} else {
if (NeedGuard) {
CoreConvertPagesWithGuard (Start, NumberOfPages, PoolType);
Expand Down Expand Up @@ -2314,12 +2313,14 @@ CoreTerminateMemoryMap (
ASSERT (Entry->Type != EfiACPIReclaimMemory);
ASSERT (Entry->Type != EfiACPIMemoryNVS);
if ((Entry->Start & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {
DEBUG ((DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n")); // MU_CHANGE
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
Status = EFI_INVALID_PARAMETER;
goto Done;
}

if (((Entry->End + 1) & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {
DEBUG ((DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n")); // MU_CHANGE
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
Status = EFI_INVALID_PARAMETER;
goto Done;
}
}
Expand Down

0 comments on commit a81517e

Please sign in to comment.