Skip to content

[major] Do Not Allow Non-Page Aligned GCD Allocations - #1767

Open
os-d wants to merge 3 commits into
OpenDevicePartnership:majorfrom
os-d:no_unaligned_alloc
Open

[major] Do Not Allow Non-Page Aligned GCD Allocations#1767
os-d wants to merge 3 commits into
OpenDevicePartnership:majorfrom
os-d:no_unaligned_alloc

Conversation

@os-d

@os-d os-d commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes #1614 and has three commits. This PR is targeting the major branch because platforms should re-run the readiness tool to confirm FV regions are covered by memory allocation HOBs.

GCD: Do Not Allocate FV HOB Regions

Currently, Patina took the stance that it should allocate FVs to make sure memory allocations did not stomp on them. However, this led to an issue where FVs are not page aligned and so non-page aligned allocations were made in the GCD. The EFI_MEMORY_MAP must be page aligned, so these regions could not be added and had to be silently dropped. Patina does not have the information required to know if it is safe to extend these allocations to page aligned lengths.

Originally, Patina inherited behavior from EDK II to only allocate FV regions if they were MMIO. However, MMIO allocations are not used in the core.

It is the domain of the pre-DXE phase to properly describe allocations to DXE so that existing allocations are not stomped on. The PI spec defined way is to do this through memory allocation HOBs. As such, Patina should only rely on memory allocation HOBs to build the GCD, not FV HOBs. It is then a reasonable expectation to say that memory allocation HOBs must be page aligned.

This expectation is also testable and added to the patina-readiness-tool.

GCD: Enforce Page Aligned Allocations

The GCD must have page aligned allocations because the EFI_MEMORY_MAP is built from it, which must be page aligned per spec (and the structure only describes ranges in page count length). In addition, memory protections rely on page aligned regions.

This commit enforces this expectation.

Revert "dxe: GCD: Don't Assert on Non-Page Aligned GCD Allocations"

This reverts commit 7d88394. This commit allowed for non-page aligned GCD allocations, but that allowance is no longer made because of the two preceding commits.

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

How This Was Tested

Through updating the patina-readiness-tool and confirming these assumptions are valid.

Integration Instructions

Platforms should re-run the patina-readiness-tool v0.4.0 or greater when about to ingest this change. They should confirm that FV HOBs are covered by memory allocation HOBs. If not, page aligned memory allocation HOBs must be produced by the platform for the FV regions.

Separately, the platform should identify if any non-page aligned GCD allocations are being made (debug_asserts will catch this). If so, they must convert them to page aligned allocations. This does not affect AllocatePool allocations, only direct GCD allocations through AllocateMemorySpace().

os-d added 3 commits September 4, 2026 09:52
Currently, Patina took the stance that it should
allocate FVs to make sure memory allocations
did not stomp on them. However, this led to an
issue where FVs are not page aligned and so non-page
aligned allocations were made in the GCD. The
EFI_MEMORY_MAP must be page aligned, so these regions
could not be added and had to be silently dropped.
Patina does not have the information required to know
if it is safe to extend these allocations to page aligned
lengths.

Originally, Patina inherited behavior from EDK II to
only allocate FV regions if they were MMIO. However,
MMIO allocations are not used in the core.

It is the domain of the pre-DXE phase to properly describe
allocations to DXE so that existing allocations are not
stomped on. The PI spec defined way is to do this
through memory allocation HOBs. As such, Patina should
only rely on memory allocation HOBs to build the GCD, not
FV HOBs. It is then a reasonable expectation to say that
memory allocation HOBs must be page aligned.

This expectation is also testable and added to the
patina-readiness-tool.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
The GCD must have page aligned allocations because
the EFI_MEMORY_MAP is built from it, which must
be page aligned per spec (and the structure only
describes ranges in page count length). In addition,
memory protections rely on page aligned regions.

This commit enforces this expectation.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
This reverts commit 7d88394. This
commit allowed for non-page aligned GCD allocations, but that
allowance is no longer made because of the two preceding commits.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
@github-actions github-actions Bot added the impact:breaking-change Requires integration attention label Sep 4, 2026
@os-d os-d linked an issue Sep 4, 2026 that may be closed by this pull request
1 task
@os-d

os-d commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

I need to come back and update the docs as well

@makubacki makubacki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good pending the doc update.

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.

[Bug]: Patina Needs to Consider Non-Page Aligned GCD Allocations

3 participants