Skip to content

Commit

Permalink
Minor debug print updates for DxePagingAuditTestApp (#382)
Browse files Browse the repository at this point in the history
## Description

This change updated some print levels and added the PDB name for images
being looked at.

- [ ] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [x] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

Tested on proprietary virtual ARM platform and verified updated prints
works as expected.

## Integration Instructions

N/A
  • Loading branch information
kuqin12 authored Dec 8, 2023
1 parent f535499 commit 36cec67
Showing 1 changed file with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@ ImageCodeSectionsRoDataSectionsXp (
BOOLEAN TestFailure;
UINT64 SectionStart;
UINT64 SectionEnd;
CHAR8 *PdbFileName;

DEBUG ((DEBUG_INFO, "%a Enter...\n", __FUNCTION__));

Expand Down Expand Up @@ -1243,6 +1244,17 @@ ImageCodeSectionsRoDataSectionsXp (
}

// Check PE/COFF image
PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);
if (PdbFileName == NULL) {
DEBUG ((
DEBUG_WARN,
"%a Could not get name of image loaded at 0x%llx - 0x%llx...\n",
__func__,
(UINTN)LoadedImage->ImageBase,
(UINTN)LoadedImage->ImageBase + LoadedImage->ImageSize
));
}

DosHdr = (EFI_IMAGE_DOS_HEADER *)(UINTN)LoadedImage->ImageBase;
PeCoffHeaderOffset = 0;
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
Expand All @@ -1260,7 +1272,8 @@ ImageCodeSectionsRoDataSectionsXp (

if (!IsLoadedImageSectionAligned (SectionAlignment, LoadedImage->ImageCodeType)) {
UT_LOG_ERROR (
"Image 0x%llx - 0x%llx is not aligned\n",
"Image %a: 0x%llx - 0x%llx is not aligned\n",
PdbFileName,
(UINTN)LoadedImage->ImageBase,
(UINTN)LoadedImage->ImageBase + LoadedImage->ImageSize
);
Expand All @@ -1287,7 +1300,8 @@ ImageCodeSectionsRoDataSectionsXp (
(EFI_IMAGE_SCN_CNT_INITIALIZED_DATA || EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA)) != 0))
{
UT_LOG_ERROR (
"Image Section 0x%llx-0x%llx contains code and data\n",
"Image %a: Section 0x%llx-0x%llx contains code and data\n",
PdbFileName,
SectionStart,
SectionEnd
);
Expand All @@ -1313,7 +1327,8 @@ ImageCodeSectionsRoDataSectionsXp (
{
if ((Attributes & EFI_MEMORY_RO) == 0) {
UT_LOG_ERROR (
"Image Section 0x%llx-0x%llx is not EFI_MEMORY_RO\n",
"Image %a: Section 0x%llx-0x%llx is not EFI_MEMORY_RO\n",
PdbFileName,
SectionStart,
SectionEnd
);
Expand All @@ -1322,7 +1337,8 @@ ImageCodeSectionsRoDataSectionsXp (
} else {
if ((Attributes & EFI_MEMORY_XP) == 0) {
UT_LOG_ERROR (
"Image Section 0x%llx-0x%llx is not EFI_MEMORY_XP\n",
"Image %a: Section 0x%llx-0x%llx is not EFI_MEMORY_XP\n",
PdbFileName,
SectionStart,
SectionEnd
);
Expand Down Expand Up @@ -1377,7 +1393,7 @@ BspStackIsXpAndHasGuardPage (
StackBase = (EFI_PHYSICAL_ADDRESS)((MemoryHob->AllocDescriptor.MemoryBaseAddress / EFI_PAGE_SIZE) * EFI_PAGE_SIZE);
StackLength = (EFI_PHYSICAL_ADDRESS)(EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (MemoryHob->AllocDescriptor.MemoryLength)));

UT_LOG_INFO ("BSP stack located at 0x%llx - 0x%llx", StackBase, StackBase + StackLength);
UT_LOG_INFO ("BSP stack located at 0x%llx - 0x%llx\n", StackBase, StackBase + StackLength);

Attributes = 0;
Status = GetRegionCommonAccessAttributes (
Expand Down Expand Up @@ -1545,7 +1561,7 @@ DxePagingAuditTestAppEntryPoint (
);

if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "%a Could not retrieve command line args!\n", __FUNCTION__));
DEBUG ((DEBUG_ERROR, "%a Could not retrieve command line args!\n", __FUNCTION__));
return EFI_PROTOCOL_ERROR;
}

Expand All @@ -1563,13 +1579,13 @@ DxePagingAuditTestAppEntryPoint (
}
} else {
if (StrnCmp (ShellParams->Argv[1], L"-h", MAX_CHARS_TO_READ) != 0) {
DEBUG ((DEBUG_INFO, "Invalid argument!\n"));
DEBUG ((DEBUG_ERROR, "Invalid argument!\n"));
}

DEBUG ((DEBUG_INFO, "-h : Print available flags\n"));
DEBUG ((DEBUG_INFO, "-d : Dump the page table files\n"));
DEBUG ((DEBUG_INFO, "-r : Run the application tests\n"));
DEBUG ((DEBUG_INFO, "NOTE: Combined flags (i.e. -rd) is not supported\n"));
Print (L"-h : Print available flags\n");
Print (L"-d : Dump the page table files\n");
Print (L"-r : Run the application tests\n");
Print (L"NOTE: Combined flags (i.e. -rd) is not supported\n");
}
}

Expand Down

0 comments on commit 36cec67

Please sign in to comment.