Skip to content

[major] Add marker protocol APIs to UEFI Services [Rebase & FF] - #1821

Merged
makubacki merged 2 commits into
OpenDevicePartnership:majorfrom
makubacki:patina_uefi_services_major_update_7
Oct 2, 2026
Merged

makubacki merged 2 commits into
OpenDevicePartnership:majorfrom
makubacki:patina_uefi_services_major_update_7

Conversation

@makubacki

@makubacki makubacki commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

"Marker protocols" are protocols without a protocol interface structure where the pointer to the protocol structure is a null pointer. This PR has two commits to support marker protocols in UEFI Services.


sdk: Add MarkerProtocol trait

To better enforce and identify "marker protocols" in the type system, a new trait is added called MarkerProtocol.

A const assert is added that verifies the size is zero. Because it is const, it is treated as a built-time compilation failure not a runtime check.


Add marker protocol APIs to UEFI Services

The existing install_interface function can't express a "marker" protocol because it takes ProtocolPtr which wraps NonNull<c_void>.

That is intentional to reduce the risk of installing an invalid interface and requiring the caller to work more directly with raw pointer logic. Other functions like locate_protocol also have logic around returning sound protocol interfaces to callers (e.g. verifying the GUID matches the protocol interface).

The ProtocolInterface trait used to establish a protocol GUID to interface relationship already supports marker protocols with the interface being a zero-sized type.

This adds new functions like install_marker_protocol::<P>(handle) and uninstall_marker_protocol::<P>(handle) to protocol services to make working with marker protocols and ProtocolInterface obvious and ergonomic.

An is_marker_protocol_installed function is also provided to make it simple to check if a marker protocol is installed without needing to worry about optional protocol interfaces and null pointers.

Protocol notification works with marker protocols as well, so some unit tests are added to test and demonstrate that.


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

How This Was Tested

  • cargo make all (including unit test changes)

Integration Instructions

  • N/A

@makubacki makubacki self-assigned this Sep 29, 2026
@github-actions github-actions Bot added impact:non-functional Does not have a functional impact impact:testing Affects testing type:documentation Improvements or additions to documentation labels Sep 29, 2026
@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@patina-automation

patina-automation Bot commented Sep 29, 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/37071524372

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_update_7 branch from 344a2f1 to 9c03ce3 Compare September 30, 2026 15:40
@makubacki makubacki changed the title [major] Add marker protocol APIs to UEFI Services [major] Add marker protocol APIs to UEFI Services [Rebase & FF] Sep 30, 2026
To better enforce and identify "marker protocols" in the type system,
a new trait is added called `MarkerProtocol`.

A const assert is added that verifies the size is zero. Because it is
const, it is treated as a built-time compilation failure not a runtime
check.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
The existing `install_interface` function can't express a "marker"
protocol because it takes `ProtocolPtr` which wraps `NonNull<c_void>`.

That is intentionally to reduce the risk of installing an invalid
interface and requiring the caller to work more directly with raw
pointer logic. Other functions like `locate_protocol` also have logic
around returning sound protocol interfaces to callers.

The `ProtocolInterface` trait used to establish a protocol GUID to
interface relationship already supports marker protocols with the
interface being a zero-sized type.

This adds new functions like `install_marker_protocol::<P>(handle)`
and `uninstall_marker_protocol::<P>(handle)` to make working with
marker protocols and `ProtocolInterface` obvious and ergonomic.

A `is_marker_protocol_installed` function is also provided to make it
simple to check if a marker protocol is installed without needing to
worry about optional protocol interfaces and null pointers.

Protocol notification works with marker protocols as well, so some
unit tests are added to test and demonstrate that.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@makubacki
makubacki force-pushed the patina_uefi_services_major_update_7 branch from 9c03ce3 to 62be27e Compare October 2, 2026 22:05
@makubacki
makubacki enabled auto-merge (rebase) October 2, 2026 22:06
@makubacki
makubacki merged commit d92c47a into OpenDevicePartnership:major Oct 2, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:non-functional Does not have a functional impact impact:testing Affects testing type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants