Skip to content

[major] Add Initial Patina UEFI Services [Rebase & FF] - #1743

Merged
makubacki merged 4 commits into
OpenDevicePartnership:majorfrom
makubacki:patina_uefi_services_major
Sep 14, 2026
Merged

makubacki merged 4 commits into
OpenDevicePartnership:majorfrom
makubacki:patina_uefi_services_major

Conversation

@makubacki

@makubacki makubacki commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Includes an initial merge commit from the current main branch into major.

Adds a new set of Patina component services called "UEFI Services". These services are defined in the Patina SDK, produced by the Patina DXE Core, and used by Patina components.

Main changes:

  1. Add Patina UEFI Services trait and related definitions - see sdk\patina\src\component\service\uefi_services.
  2. Produce Patina UEFI Services in the DXE Core - see patina_dxe_core\src\uefi_services.
  3. Add Patina component samples using the services - see
    components\patina_samples\src\component\uefi_services.

Note: Throughout the development of this PR, other changes were added that built on the code that currently remains. Those have been removed to reduce the size of this PR, and the above set of changes are the primary set that remain.

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

How This Was Tested

  • cargo make all
  • QEMU ArmVirt & Q35 boot to EFI shell with Patina samples included
    • Initial component dispatch (DXE core and sample components):

      INFO - Dispatching Drivers
      INFO - Dispatching patina_dxe_core::cpu::cpu_arch_protocol::CpuArchProtocolInstaller
      INFO - InstallProtocolInterface: 26BACCB1-6F42-11D4-BCE7-0080C73C8881 @ 0x000000007a1ff800
      INFO - installed EFI_CPU_ARCH_PROTOCOL_GUID
      INFO - Dispatching patina_dxe_core::systemtables::SystemTableChecksumInstaller
      INFO - Dispatching patina_dxe_core::decompress::DecompressProtocolInstaller
      INFO - InstallProtocolInterface: D8117CFE-94A6-11D4-9A3A-0090273FC14D @ 0x000000007a977700
      INFO - Dispatching patina_adv_logger::component::AdvancedLoggerComponent<patina::peripheral::serial::uart::uart_16550::Uart16550>
      INFO - InstallProtocolInterface: 434F695C-EF26-4A12-9EBA-DDEF0097497C @ 0x000000007a200220
      INFO - Advanced Logger protocol installed.
      INFO - Dispatching patina_samples::component::uefi_services::configuration_table::ConfigurationTableSample
      INFO - Installed SampleVendorTable v1
      INFO - Read back signature "PTNA", 0 entries
      INFO - Dispatching patina_samples::component::uefi_services::driver_connect::DriverConnectSample
      INFO - Dispatching patina_samples::component::uefi_services::protocol_publisher::ProtocolPublisherSample
      INFO - InstallProtocolInterface: A1B2C3D4-E5F6-4789-ABCD-EF0123456789 @ 0x000000007ad727c8
      INFO - published SampleVendorProtocol on handle Handle(0x688cdc10f3d4e4b5)
      INFO - Dispatching patina_samples::component::uefi_services::protocol_publisher::ProtocolConsumerSample
      INFO - SampleVendorProtocol rev 0x10000 returned status 0x12345678
      INFO - Dispatching patina_samples::component::uefi_services::protocol_consumer::ProtocolConsumerSample
      INFO - with_protocol() read status is 0x12345678
      INFO - open_protocol() revision is 0x10000
      INFO - open_protocol() status is 0x12345678
      INFO - Protocol token resolved, status is 0x12345678
      INFO - SampleVendorProtocol notification: Protocol is installed on Handle(0x688cdc10f3d4e4b5)
      INFO - Dispatching patina_samples::component::uefi_services::tpl_critical_section::TplCriticalSectionSample
      INFO - Counters were kept consistent under raised TPL
      INFO - Dispatching patina_samples::component::uefi_services::end_of_dxe_protocol_consumer::EndOfDxeProtocolConsumerSample
      INFO - Registered End-of-DXE callback for SampleVendorProtocol
      INFO - Dispatching qemu_resources::q35::component::service::mm_config_provider::MmConfigurationProvider
      INFO - ACPI I/O Port Address: 0xB00F8040
      INFO - ACPI (PMBASE) I/O Port: 0x600
      INFO - Found 1 MM Communicate Region HOBs
      INFO - Dispatching qemu_resources::q35::component::service::mm_control::QemuQ35PlatformMmControl
      INFO - Dispatching patina_mm::component::sw_mmi_manager::SwMmiManager
      INFO - Dispatching patina_mm::component::communicator::MmCommunicator
      INFO - Dispatching qemu_resources::q35::component::service::mm_test::QemuQ35MmTest
      INFO - MM Supervisor Version: 0x0, Patch Level: 0x0, Max Request Level: 0x3533715F756D6571
      INFO - Dispatching patina_performance::component::protocol::MeasurementProtocolPublisher
      INFO - InstallProtocolInterface: C85D06BE-5F75-48CE-A80F-1236BA3B87B1 @ 0x000000007ad715e8
      INFO - Dispatching patina_performance::component::property::PropertyPublisher
      INFO - Dispatching patina_performance::component::fbpt::FbptPublisher
      INFO - Dispatching patina_performance::component::mm_records::MmRecordCollector
      INFO - Dispatching patina_smbios::component::provider::SmbiosProvider
      INFO - Dispatching patina_smbios::component::protocol_publisher::SmbiosProtocolPublisher
      INFO - InstallProtocolInterface: 03583FF6-CB36-4940-947E-B9B39F4AFAF7 @ 0x000000007a973800
      INFO - Dispatching qemu_resources::q35::component::service::smbios_platform::Q35SmbiosPlatform
      INFO - Dispatching patina_acpi::component::AcpiComponent
      INFO - InstallProtocolInterface: FFE06BDD-6107-46A6-7BB2-5A9C7EC5275C @ 0x000000007ad35028
      INFO - InstallProtocolInterface: 7F3C1A92-8B4E-4D2F-A6C9-3E12F4B8D7C1 @ 0x000000007ad35010
      INFO - Depex evaluation complete, scheduled 2 drivers
      
    • Later after the Timer Architectural protocol is installed:

      INFO - Dispatching patina_samples::component::uefi_services::overview::UefiServicesSample
      INFO - Sample crc32 = 0x7c22221c
      INFO - Dispatching patina_samples::component::uefi_services::timers::TimerSample
      INFO - Armed one-shot (50 ms) and periodic (10 ms) timers
      INFO - Logged from the periodic timer event
      INFO - Logged from the one-shot timer event
      INFO - Logged from the periodic timer event
      INFO - Logged from the periodic timer event
      INFO - Logged from the periodic timer event
      INFO - Logged from the periodic timer event
      INFO - Logged from the periodic timer event
      
    • End of DXE messages:

      INFO - End of DXE: sample_get_status returned 0x12345678
      INFO - Logged from the periodic timer event
      All EndOfDxe callbacks have returned successfully
      
    • All Patina on-system tests pass:

      INFO - adv_logger_test: Direct log message!!!
      adv_logger_test: Logged through the protocol!!!
      INFO - Patina on-system unit-test results:
        patina_acpi::integration_test::acpi_protocol_test ... ok (1 passes)
        patina_acpi::integration_test::acpi_test ... ok (1 passes)
        patina_adv_logger::integration_test::adv_logger_test ... ok (1 passes)
        patina_dxe_core::core_patina_tests::audit_tests::gcd_free_memory_merged_test ... ok (1 passes)
        patina_dxe_core::core_patina_tests::stability_tests::page_table_tests_1gb_split ... ok (4 passes)
        patina_dxe_core::core_patina_tests::stability_tests::page_table_tests_1gb_unmap_2mb_remap ... ok (4 passes)
        patina_dxe_core::core_patina_tests::stability_tests::page_table_tests_1gb_unmap_4kb_remap ... ok (4 passes)
        patina_dxe_core::core_patina_tests::stability_tests::page_table_tests_2mb_split ... ok (4 passes)
        patina_dxe_core::core_patina_tests::stability_tests::page_table_tests_2mb_unmap ... ok (4 passes)
        patina_dxe_core::memory_manager::memory_manager_allocations_test ... ok (1 passes)
        patina_dxe_core::memory_manager::memory_manager_attributes_test ... ok (1 passes)
        qemu_resources::q35::component::service::smbios_test::q35_smbios_ffi_test ... ok (1 passes)
      Patina on-system unit-test result totals: 27 passes, 0 fails
      
  • Verified EFI shell console rendering after removing GraphicsConsoleDxe from QEMU platforms and using the patina_graphics_console component instead.

Integration Instructions

  • See individual crate documentation samples. In addition, a patina-dxe-core-qemu PR will demonstrate the changes needed to integrate and use the new components.

@makubacki makubacki self-assigned this Aug 13, 2026
@github-actions github-actions Bot added impact:breaking-change Requires integration attention impact:testing Affects testing type:documentation Improvements or additions to documentation labels Aug 13, 2026
@makubacki

Copy link
Copy Markdown
Collaborator Author

I'm working on some changes to improve unit test coverage.

@patina-automation

patina-automation Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

ℹ️ QEMU Validation Skipped - Unsupported Target Branch

The Patina QEMU PR validation workflow did not run because the PR targets an unsupported branch.

Workflow run: https://github.com/OpenDevicePartnership/patina/actions/runs/34870380596

Note: Previous results are available in this comment's edit history.

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

@makubacki
makubacki force-pushed the patina_uefi_services_major branch from f63f1af to 3e810b7 Compare August 14, 2026 20:08
@makubacki

Copy link
Copy Markdown
Collaborator Author

I'm working on some changes to improve unit test coverage.

Pushed. Also updated the major branch to include the clippy pedantic changes in main (merged at a1f6643) and rebased changes against those new lints.

@cfernald cfernald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just reviewed the SDK interface for now. Will review the full changes later.

Comment thread sdk/patina/src/component/service.rs Resolved

@kat-perez kat-perez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I found several safety and contract issues in the new service layer that should be addressed before merge. The inline comments focus on callback lifetime, protocol reference lifetime, marker protocol compatibility, and duration conversion.

@kat-perez
kat-perez dismissed their stale review August 19, 2026 20:52

Withdrawn by reviewer for additional cross-checking before feedback is submitted.

Comment thread components/patina_smbios/src/manager.rs Resolved
@makubacki
makubacki force-pushed the patina_uefi_services_major branch 3 times, most recently from b9d0dbd to 75530e3 Compare August 20, 2026 20:19
@makubacki

Copy link
Copy Markdown
Collaborator Author

@Javagedes, @cfernald, @kat-perez, this is ready for you review again when you get time.

@makubacki

Copy link
Copy Markdown
Collaborator Author

I've decided to spend a bit more time improving open protocol and driver binding since that might impact some other interfaces and there's no point having those in an intermediate state. Will push that update within a few days.

@makubacki
makubacki force-pushed the patina_uefi_services_major branch from 75530e3 to 1fed1b9 Compare September 2, 2026 23:53
@makubacki

Copy link
Copy Markdown
Collaborator Author

I've decided to spend a bit more time improving open protocol and driver binding since that might impact some other interfaces and there's no point having those in an intermediate state. Will push that update within a few days.

Merged main into the major branch (at commit 35f9055) and rebased the PR onto it. The main set of changes added are in commit 59cc862.

@makubacki

makubacki commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator Author

I've decided to spend a bit more time improving open protocol and driver binding since that might impact some other interfaces and there's no point having those in an intermediate state. Will push that update within a few days.

Merged main into the major branch (at commit 35f9055) and rebased the PR onto it. The main set of changes added are in commit 59cc862.

I made some cumulative changes to better support UEFI Driver Model components, the PR description is updated.

The summary of new changes is a locate_first_handle function in Protocol Services, support for producing the EFI Component Name protocol, support for producing the EFI Driver Supported EFI Version protocol, support for a new component parameter Protocol<P> that allows a protocol to be a component dependency, a minimal PCD service that only abstracts access to Dynamic PCDs using an underlying PCD protocol, and a Patina component port of GraphicsConsoleDxe to show many of the UEFI Services changes working together.

@makubacki

Copy link
Copy Markdown
Collaborator Author

I've made some additional changes to handle pool allocations returned from C code, split GOP-specific logic out to a dedicated component/service and move the default font package into its own component (out of patina_graphics_console), so it, along with other font packages, can be independently managed from the graphics console component. Will push these updates soon. I've also started breaking out standalone changes into PRs into main to start reducing this PR to incremental changes that need to go to major. When that's done, I'll merge main into major and rebase this PR, dropping those commits.

Patina UEFI Services are a set of service traits that expose UEFI Boot
Services (and, potentially Runtime Services in the future) to Patina
components so that they can perform the operations provided by the
services in a safer more idiomatic way.

These services are the recommended way for components to consume UEFI
functionality. Unlike the raw `uefi::boot_services` abstractions,
which wrap the C `EFI_BOOT_SERVICES` function-pointer table, these
services are implemented by the Patina DXE Core directly against its
internal Rust APIs. Components therefore do not interact with C-style
constructs such as the boot services table or raw pointers until they
go down an unavoidable path into C code, such as calling a protocol
function pointer when the protocol is produced by a C driver.

The services are only defined in this commit and will be produced by
the Patina DXE Core in a future commit.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Binds these types to the GUID they are published under, so they can
be used with Configuration Table Services without handling a raw
pointer or repeating the GUID at each call site.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Produces UEFI Services for components to have safer, direct access to
common UEFI Services implemented in the DXE Core.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Adds a set of new sample components that demonstrate how to use the
UEFI Services.

Samples include:

- `overview` - A quick tour of timer, event, and protocol usage in
  one component.
- `configuration_table` - Installs a vendor configuration table and
  reads it back.
- `driver_connect` - Discovers controllers by protocol and connects
  drivers to them.
- `end_of_dxe_protocol_consumer` - Defers protocol consumption to
  End-of-DXE.
- `protocol_consumer` - Shows different ways to consume a protocol.
- `protocol_publisher` - Demonstrates one component publishing a
  protocol and another consuming it.
- `timers` - Drives work from one-shot and periodic timers using Rust
  closures.
- `tpl_critical_section` - Serializes access to shared state with TPL.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@makubacki
makubacki force-pushed the patina_uefi_services_major branch 2 times, most recently from 744f2ee to ea0dd60 Compare September 14, 2026 16:30
@makubacki

Copy link
Copy Markdown
Collaborator Author

This branch has accumulated several months worth of changes now. I'm going to remove everything except the initial set of commits to add the UEFI Services themselves and break the remaining changes up into other PRs for more focused review. The remaining set of changes (and some commits after) were already reviewed and approved, so I'll complete this PR after CI passes. There might be some redundant review in the next few PRs created, but a second look doesn't hurt.

@makubacki
makubacki merged commit 2de3788 into OpenDevicePartnership:major Sep 14, 2026
11 checks passed
{
// SAFETY: `context` is the `ClosureHolder` pointer created in `create_event_internal`.
// The event has just been closed, so no further notifications can reference it.
drop(unsafe { Box::from_raw(context as *mut ClosureHolder) });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Couldn't this be the closure that called close_event?

.map_err(ConfigTableError::from)
}

fn remove_table(&self, guid: BinaryGuid) -> Result<(), ConfigTableError> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this routine needs to also try CONFIG_TABLE_TYPES.lock().remove(&guid); to avoid potential type aliasing.

@cfernald cfernald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks like I missed the window a bit, but a few comments.

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 impact:testing Affects testing type:documentation Improvements or additions to documentation

Projects

None yet

4 participants