Skip to content

AdvLoggerPkg: Use Scratchpad Region instead of PEI_CORE_INSTANCE#913

Open
os-d wants to merge 1 commit into
microsoft:release/202511from
os-d:scratchpad
Open

AdvLoggerPkg: Use Scratchpad Region instead of PEI_CORE_INSTANCE#913
os-d wants to merge 1 commit into
microsoft:release/202511from
os-d:scratchpad

Conversation

@os-d

@os-d os-d commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description

Currently, The SecDebugAgent and PeiCore instances of advanced logger use the internal PEI_CORE_INSTANCE to store a pointer to the advanced logger buffer. This is a performance optimization to avoid a HOB lookup on every debug message.

However, this is also a hack and requires a basecore override to reach into the core internals.

This commit changes that behavior by introducing a PCD to define a scratchpad page where the pointer can be stored. This must exist outside of the PHIT free memory region so that it is not handed out as another allocation in PEI, because the allocator does not respect memory allocation HOBs for that region.

If a platform does not specify this PCD, a HOB lookup will be performed on every debug message.

Closes #910 .

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

Booting to shell on Q35, seeing PEI logs. Added a spin loop when the PCD is used to confirm it wasn't falling back to the HOB lookup. Physical Intel testing is going on in parallel with this PR.

Integration Instructions

This is marked as a breaking change because there is a significant performance impact if a platform does not take action here. However, the build and run will still work if not.

In order to keep the same performance guarantees as the current code, platforms must provide a page address that is outside of the PHIT free memory region in gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerScratchpadBase. This must be available to write to in SEC and PEI_CORE.

Currently, The SecDebugAgent and PeiCore instances of advanced
logger use the internal PEI_CORE_INSTANCE to store a pointer to
the advanced logger buffer. This is a performance optimization to
avoid a HOB lookup on every debug message.

However, this is also a hack and requires a basecore override to
reach into the core internals.

This commit changes that behavior by introducing a PCD to define
a scratchpad page where the pointer can be stored. This must
exist outside of the PHIT free memory region so that it is not
handed out as another allocation in PEI, because the allocator
does not respect memory allocation HOBs for that region.

If a platform does not specify this PCD, a HOB lookup will be
performed on every debug message.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
@os-d os-d requested review from apop5, cfernald, kuqin12 and makubacki June 26, 2026 18:03
@mu-automation

mu-automation Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

❌ QEMU Validation Failed

Source Dependencies

Repository Commit
mu_plus 7d8bb8f
mu_tiano_platforms a3f899f

Results

Platform Target Build Boot Overall Boot Time Build Logs Boot Logs
Q35 DEBUG ✅ success ❌ failure 5m 0s (timed out) Build Logs Boot Logs
ArmVirt DEBUG ❌ failure ⏩ skipped N/A Build Logs N/A

Workflow run: https://github.com/microsoft/mu_plus/actions/runs/28256825348

This comment was automatically generated by the Mu QEMU PR Validation workflow.

@mu-automation mu-automation Bot added the impact:breaking-change Requires integration attention label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:breaking-change Requires integration attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Create Scratchpad Space for PeiCore AdvancedLoggerLib and Drop PEI_CORE_INSTANCE Hack

1 participant