Skip to content

Conversation

makubacki
Copy link
Member

@makubacki makubacki commented Oct 6, 2025

Description

Commit d8f513de3e3ef228af7e6facf0ad3e35c3224032 (an edk2 commit) added runtime memory allocation to VariablePei. That will cause runtime memory bucket fragmentation affecting hibernate stability as these runtime allocations are separate from the main runtime memory type bucket allocation made by the DXE Core.

To preserve the existing functionality but allow the runtime buffer to come from the DXE bucket, the allocations in PEI are changed to boot services data allocations and the contents are moved to the runtime memory buffers (and those pages unblocked to MM) in the DXE variable driver after the bucket has been allocated by the DXE core.


Note: I will upstream this to edk2 but it is urgently needed in Project Mu.

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

How This Was Tested

  • CI
  • Boot to EFI shell on QEMU Q35 and verify allocations come from the DXE allocated bucket buffer

Integration Instructions

  • N/A

@makubacki makubacki self-assigned this Oct 6, 2025
@makubacki
Copy link
Member Author

I was originally planning to take this straight to edk2, but it's needed here now. I'll add MU_CHANGE tags before completing it.

@makubacki makubacki requested review from apop5, kuqin12 and os-d October 6, 2025 18:19
@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/202502@573b64f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...versal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c 0.00% 3 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             release/202502    #1519   +/-   ##
=================================================
  Coverage                  ?    1.55%           
=================================================
  Files                     ?      636           
  Lines                     ?   233935           
  Branches                  ?      370           
=================================================
  Hits                      ?     3649           
  Misses                    ?   230273           
  Partials                  ?       13           
Flag Coverage Δ
MdeModulePkg 1.55% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@makubacki makubacki force-pushed the prevent_variablepei_mem_bucket_fragmentation branch from f2b15aa to 16ac2d6 Compare October 6, 2025 21:10
@makubacki
Copy link
Member Author

I was originally planning to take this straight to edk2, but it's needed here now. I'll add MU_CHANGE tags before completing it.

Done - MU_CHANGE tags added

Commit `d8f513de3e3ef228af7e6facf0ad3e35c3224032` added runtime
memory allocation to VariablePei. That will cause runtime memory
bucket fragmentation affecting hibernate stability as these runtime
allocations are separate from the main runtime memory type
bucket allocation made by the DXE Core.

To preserve the existing functionality but allow the runtime buffer
to come from the DXE bucket, the allocations in PEI are changed to
boot services data allocations and the contents are moved to the
runtime memory buffers (and those pages unblocked to MM) in the
DXE variable driver after the bucket has been allocated by the DXE
core.

Signed-off-by: Michael Kubacki <[email protected]>
…lure

If a RT data buffer fails to be allocated or unblocked, clean up the
RT cache state by (1) freeing any allocated buffers and (2) resetting
the buffer addresses back to zero to indicate the RT cache is not
available.

Signed-off-by: Michael Kubacki <[email protected]>
@makubacki makubacki force-pushed the prevent_variablepei_mem_bucket_fragmentation branch from 16ac2d6 to a88d506 Compare October 8, 2025 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants