Skip to content

Commit

Permalink
FlatPageTableLib: Add a Dump Table Function
Browse files Browse the repository at this point in the history
Description

This patch adds a function to dump the contents of a flat page
table to the console. This is useful for debugging.

- [x] 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, ...
- [ ] 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 Q35 by running the function.

Integration Instructions

N/A
  • Loading branch information
TaylorBeebe authored and kenlautner committed Jan 19, 2024
1 parent 74cbde4 commit 1552e19
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions UefiTestingPkg/Include/Library/FlatPageTableLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ CreateFlatPageTable (
IN OUT PAGE_MAP *Map
);

/**
Dumps the contents of the input PAGE_MAP to the debug log.
**/
VOID
EFIAPI
DumpPageMap (
IN PAGE_MAP *Map
);

/**
Checks the input flat page/translation table for the input region and converts the associated
table entries to EFI access attributes (EFI_MEMORY_XP, EFI_MEMORY_RO, EFI_MEMORY_RP). If the
Expand Down
30 changes: 30 additions & 0 deletions UefiTestingPkg/Library/FlatPageTableLib/FlatPageTableLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@
((AStart <= BStart && AEnd > BStart) || \
(BStart <= AStart && BEnd > AStart)))

/**
Dumps the contents of the input PAGE_MAP to the debug log.
**/
VOID
EFIAPI
DumpPageMap (
IN PAGE_MAP *Map
)
{
UINTN Index;
UINT64 Attributes;

DEBUG ((DEBUG_INFO, "Page Map: %p\n", Map));
DEBUG ((DEBUG_INFO, " EntryCount: %d\n", Map->EntryCount));
DEBUG ((DEBUG_INFO, " Entries:\n"));
for (Index = 0; Index < Map->EntryCount; Index++) {
Attributes = IsPageExecutable (Map->Entries[Index].PageEntry) ? 0 : EFI_MEMORY_XP;
Attributes |= IsPageWritable (Map->Entries[Index].PageEntry) ? 0 : EFI_MEMORY_RO;
Attributes |= IsPageReadable (Map->Entries[Index].PageEntry) ? 0 : EFI_MEMORY_RP;
DEBUG ((
DEBUG_INFO,
" %d: %p-%p. Attributes: 0x%llx\n",
Index,
Map->Entries[Index].LinearAddress,
Map->Entries[Index].LinearAddress + Map->Entries[Index].Length - 1,
Attributes
));
}
}

/**
Checks the input flat page/translation table for the input region and converts the associated
table entries to EFI access attributes (EFI_MEMORY_XP, EFI_MEMORY_RO, EFI_MEMORY_RP). If the
Expand Down

0 comments on commit 1552e19

Please sign in to comment.