Add Patina Support#91
Conversation
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 <osde@microsoft.com>
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 <osde@microsoft.com>
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 <osde@microsoft.com>
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 <osde@microsoft.com>
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 <osde@microsoft.com>
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 <osde@microsoft.com>
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 <osde@microsoft.com>
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 <osde@microsoft.com>
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 <osde@microsoft.com>
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 <osde@microsoft.com>
| !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 |
There was a problem hiding this comment.
Placeholder until msvm-patina-bins repo (or equivalent) set up.
| !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 |
There was a problem hiding this comment.
Placeholder until msvm-patina-bins (or equivalent) are set up.
|
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. |
So, basically no longer support interrupts and just poll. |
@jstarks, no the behavior should be the same, supporting device interrupts. All this change does is move the functionality to wait for an event at a TPL higher than APPLICATION out of the core (where there are issues supporting this generically and MSVM is the only consumer) into the platform instead of extending the hack into Patina (which is a UEFI spec violation). So the behavior of: loop: Remains the same. The logic just becomes simpler because MSVM doesn’t have to handle this generically, it knows exactly the case it is waiting for. |
|
Oh, I see, that makes sense and seems reasonable. Thanks. |
|
|
||
| [BuildOptions.common.EDKII.SEC, BuildOptions.common.EDKII.PEIM, BuildOptions.common.EDKII.PEI_CORE] | ||
| MSFT:*_*_*_DLINK_FLAGS = -align:4096 -filealign:4096 | ||
| *_CLANGPDB_*_DLINK_FLAGS = -align:4096 -filealign:4096 |
There was a problem hiding this comment.
This is true for MSVC, but I had forgotten this: https://github.com/microsoft/mu_basecore/blob/release/202511/BaseTools/Conf/tools_def.template#L1802-L1804. So, I will leave this alone and instead adjust the FV size (I don't think it requires an FD size change).
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.