Skip to content

Add Patina Support#91

Open
os-d wants to merge 10 commits into
microsoft:mainfrom
os-d:personal/osde/patina_rebase
Open

Add Patina Support#91
os-d wants to merge 10 commits into
microsoft:mainfrom
os-d:personal/osde/patina_rebase

Conversation

@os-d

@os-d os-d commented Jul 13, 2026

Copy link
Copy Markdown

This PR adds the following commits in support of adding Patina to mu_msvm. Patina is currently disabled by default, but is expected to become on by default.

Update MU Submodules and add Patina Edk2

This updates mu_plus and mu_basecore to pull in new BaseTools changes required for sharing an FV with modules that must be rebased and those that cannot be.

It also adds the Patina Edk2 submodule which will have MpDxe used from it when patina is integrated.

Drop A Priori Sections

A Priori sections are not recommended and are not supported in Patina. They cause issues in platforms around dependency resolution.

This commits drops the A Priori sections for X64 and AARCH64 which weren't needed; the only reason they were being used was the PcdLibNull wasn't being used for PcdPei and PcdDxe. When that is fixed, the dependency expressions are already correct.

Use New XIP BaseTools Functionality

Use the new XIP specifier to only rebase modules that need to be, not all modules. This resolves the issue of modules being in an uncompressed FV with other modules that do need rebasing needing to have the same file and section alignment.

Lower File Alignment to Minimum

VS/CLANGPDB File Alignment was raised to 0x1000 in b63514d.

This greatly increases the used FD size, which requires host changes to update.

Let this return to the minimum value defined in tools_def.template.

The problem this commit was trying to solve was incorrectly trying to ensure all modules had 4K section alignment. This is only needed for DXE modules as memory protections are only applied there.

Drop WaitForEventInternal and Implement in MsvmPkg

WaitForEventInternal was created for MSVM and it is the only consumer. This protocol was required to be able to wait for an event at a TPL higher than application, which is not allowed by the UEFI spec. This causes a series of other issues in the core when allowed.

The reason to do this was to allow waiting for device interrupts, which is outside the purview of the UEFI spec. Most platforms do not do this.

As a result, it is much safer to do this in the platform than in the core. The core must be generic for all cases whereas the platform can know the cases where this will be called and handle it appropriately. The core also does not take device interrupts into account specifically, because they are generally not used.

This drops the usage of WaitForEventInternal and instead implements the associated functionality in MsvmPkg: loop while calling CheckEvent() waiting for a device interrupt. In the meantime, enable interrupts and sleep.

Drop CpuDxe Override

With the Cpu2 Protocol changes no longer required, the CpuDxe override is not necessary. Drop it and use upstream. This is optimistic and is a discussion point to see what else exists in there that needs support in one form or another.

AARCH64: Produce Resource Descriptor HOB for BiosDevice

The BiosDevice MMIO region did not have a memory HOB produced for it and was being added through AddMemorySpace() at runtime. This pattern is okay, except that EfiDiagnosticsDxe was attempting to access the BiosDevice before NvramVariableDxe came up and added the memory space.

In Patina, this would fault because we only map described memory.

The reason this was done was to add the runtime attribute to the memory region as it must persist to the OS. However, there is no need to couple that with the memory space add, those are separate calls.

This commit changes the behavior to produce a resource descriptor HOB covering the BiosDevice and only mark it as runtime later in boot.

Add Patina Config HOB

MSVM AARCH64 can have dynamic GIC bases, which is a configuration input to Patina. This produces a HOB with the actual values so that Patina can configure them correctly.

Update All Resc Desc Hobs to V2

Patina expects resc desc HOB V2s so that cache information is correctly reported. This commit updates the platform to produce
these instead of the V1 HOBs.

Enable Patina as an Option

This adds Patina to X64 and AARCH64 MSVM, keeping the C core as the default for now. The X64 FV size is adjusted between the two FVs to account for the larger size in the PEI FV. No FD size change is required.

os-d added 10 commits July 13, 2026 14:45
This updates mu_plus and mu_basecore to pull in
new BaseTools changes required for sharing an
FV with modules that must be rebased and those
that cannot be.

It also adds the Patina Edk2 submodule which will
have MpDxe used from it when patina is integrated.

Signed-off-by: Oliver Smith-Denny <[email protected]>
A Priori sections are not recommended and are not
supported in Patina. They cause issues in platforms
around dependency resolution.

This commits drops the A Priori sections for X64 and
AARCH64 which weren't needed; the only reason they
were being used was the PcdLibNull wasn't being used
for PcdPei and PcdDxe. When that is fixed, the dependency
expressions are already correct.

Signed-off-by: Oliver Smith-Denny <[email protected]>
Use the new XIP specifier to only rebase modules
that need to be, not all modules. This resolves
the issue of modules being in an uncompressed FV
with other modules that do need rebasing needing
to have the same file and section alignment.

Signed-off-by: Oliver Smith-Denny <[email protected]>
VS/CLANGPDB File Alignment was raised to 0x1000 in
b63514d.

This greatly increases the used FD size, which requires
host changes to update.

Let this return to the minimum value defined in
tools_def.template.

The problem this commit was trying to solve was
incorrectly trying to ensure all modules had 4K section
alignment. This is only needed for DXE modules as memory
protections are only applied there.

Signed-off-by: Oliver Smith-Denny <[email protected]>
WaitForEventInternal was created for MSVM and it is
the only consumer. This protocol was required to be
able to wait for an event at a TPL higher than application,
which is not allowed by the UEFI spec. This causes a series
of other issues in the core when allowed.

The reason to do this was to allow waiting for device interrupts,
which is outside the purview of the UEFI spec. Most platforms do
not do this.

As a result, it is much safer to do this in the platform than in
the core. The core must be generic for all cases whereas the platform
can know the cases where this will be called and handle it
appropriately. The core also does not take device interrupts into
account specifically, because they are generally not used.

This drops the usage of WaitForEventInternal and instead implements
the associated functionality in MsvmPkg: loop while calling CheckEvent()
waiting for a device interrupt. In the meantime, enable interrupts
and sleep.

Signed-off-by: Oliver Smith-Denny <[email protected]>
With the Cpu2 Protocol changes no longer
required, the CpuDxe override is not necessary.
Drop it and use upstream.

Signed-off-by: Oliver Smith-Denny <[email protected]>
The BiosDevice MMIO region did not have a memory HOB produced
for it and was being added through AddMemorySpace() at runtime.
This pattern is okay, except that EfiDiagnosticsDxe was
attempting to access the BiosDevice before NvramVariableDxe
came up and added the memory space.

In Patina, this would fault because we only map described memory.

The reason this was done was to add the runtime attribute to
the memory region as it must persist to the OS. However, there
is no need to couple that with the memory space add, those are
separate calls.

This commit changes the behavior to produce a resource descriptor
HOB covering the BiosDevice and only mark it as runtime later
in boot.

Signed-off-by: Oliver Smith-Denny <[email protected]>
MSVM AARCH64 can have dynamic GIC bases, which
is a configuration input to Patina. This produces
a HOB with the actual values so that Patina can
configure them correctly.

Signed-off-by: Oliver Smith-Denny <[email protected]>
Patina expects resc desc HOB V2s so
that cache information is correctly reported.
This commit updates the platform to produce
these instead of the V1 HOBs.

Signed-off-by: Oliver Smith-Denny <[email protected]>
This adds Patina to X64 and AARCH64 MSVM, keeping
the C core as the default for now. The X64 FV size
is adjusted between the two FVs to account for the
larger size in the PEI FV. No FD size change is
required.

Signed-off-by: Oliver Smith-Denny <[email protected]>
!if $(TARGET) == RELEASE
SECTION PE32 = d:\r\patina-dxe-core-qemu\target\aarch64-unknown-uefi\release\msvm_aarch64_dxe_core.efi
!else
SECTION PE32 = d:\r\patina-dxe-core-qemu\target\aarch64-unknown-uefi\debug\msvm_aarch64_dxe_core.efi

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Placeholder until msvm-patina-bins repo (or equivalent) set up.

Comment thread MsvmPkg/MsvmPkgX64.fdf
!if $(TARGET) == RELEASE
SECTION PE32 = d:\r\patina-dxe-core-qemu\target\x86_64-unknown-uefi\release\msvm_x64_dxe_core.efi
!else
SECTION PE32 = d:\r\patina-dxe-core-qemu\target\x86_64-unknown-uefi\debug\msvm_x64_dxe_core.efi

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Placeholder until msvm-patina-bins (or equivalent) are set up.

@os-d

os-d commented Jul 14, 2026

Copy link
Copy Markdown
Author

It's been pointed out to me that I missed enlightened TDX support is in the CpuDxe override as well, so it likely can't be dropped. That's okay and not required for Patina use, but an equivalent solution will need to be added to Patina. Investigating that now.

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.

1 participant