Repository navigation
Conversation
QEMU Validation FailedQEMU validation did not complete successfully or did not shutdown as expected. Workflow run: https://github.com/OpenDevicePartnership/patina/actions/runs/38433553970
|
| Job | Result |
|---|---|
| Gather Incoming PR Metadata | ✅ |
| Run Patina QEMU Validation / Preflight Checks | ✅ |
| Run Patina QEMU Validation / Post In-Progress Notification | ✅ |
| Run Patina QEMU Validation / Get Constants / Get Repository Constants | ✅ |
| Run Patina QEMU Validation / Validate QEMU Q35 (Windows) | ❌ |
| Run Patina QEMU Validation / Validate QEMU - ArmVirt (Linux) | ❌ |
| Run Patina QEMU Validation / Validate QEMU - Q35 (Linux) | ❌ |
| Run Patina QEMU Validation / Emit PR Metadata | ✅ |
Error Details
qemu-validation-logs-Windows-Q35/q35-windows.log (6 error/warning sections)
error[E0277]: The function signature does not meet the requirements.
error[E0277]: The function signature does not meet the requirements.
error[E0599]: the method `run` exists for struct `FunctionTest<_, fn(StandardBootServices) -> ... {q35_smbios_ffi_test}>`, but its trait bounds were not satisfied
--> src\q35\component\service\smbios_test.rs:25:1
|
25 | #[patina_test]
| ^^^^^^^^^^^^^^ method cannot be called due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
error: could not compile `qemu_dxe_core` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
[cargo-make] ERROR - Error while running duckscript: Source: Unknown Line: 113 - Error while executing command, exit code: 101
qemu-validation-logs-Linux-ArmVirt/armvirt-linux.log (6 error/warning sections)
error[E0277]: The function signature does not meet the requirements.
error[E0277]: The function signature does not meet the requirements.
error[E0599]: the method `run` exists for struct `FunctionTest<_, fn(StandardBootServices) -> ... {q35_smbios_ffi_test}>`, but its trait bounds were not satisfied
--> src/q35/component/service/smbios_test.rs:25:1
|
25 | #[patina_test]
| ^^^^^^^^^^^^^^ method cannot be called due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
error: could not compile `qemu_dxe_core` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
[cargo-make] ERROR - Error while running duckscript: Source: Unknown Line: 113 - Error while executing command, exit code: 101
qemu-validation-logs-Linux-Q35/q35-linux.log (6 error/warning sections)
error[E0277]: The function signature does not meet the requirements.
error[E0277]: The function signature does not meet the requirements.
error[E0599]: the method `run` exists for struct `FunctionTest<_, fn(StandardBootServices) -> ... {q35_smbios_ffi_test}>`, but its trait bounds were not satisfied
--> src/q35/component/service/smbios_test.rs:25:1
|
25 | #[patina_test]
| ^^^^^^^^^^^^^^ method cannot be called due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
error: could not compile `qemu_dxe_core` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
[cargo-make] ERROR - Error while running duckscript: Source: Unknown Line: 113 - Error while executing command, exit code: 101
Dependencies
| Repository | Ref |
|---|---|
| patina | c95e8bb |
| patina-dxe-core-qemu | 93ef089 |
| patina-fw-patcher | a450500 |
| patina-qemu firmware | v4.1.2 |
| patina-qemu build script | f170bda |
This comment was automatically generated by the Patina QEMU PR Validation Post workflow.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
@makubacki I reviewed the majority of these changes when they went into the major branch. Is there any part that should be reviewed in particular for the integration to main that may have changed? |
The only three that were not trivially updated for merge conflicts and minor clippy issues are these three commits that were made before the PR to split MP Services: |
…#1685) **Background:** Behavior of `--all-features` with explicit package vs without explicit package: ``` cargo clippy --all-features --tests workspace crate a(feature fa) <--- all features defined in crate_a are enabled and built as a test binary crate b(feature fb) <--- all features defined in crate_b are enabled and built as a lib cargo clippy -p crate_a --all-features --tests workspace crate a(feature fa) <--- all features defined in crate_a are enabled and built as a test binary crate b(feature fb) <--- only features selected when specifying crate_b as dependency are enabled(if non selected, default features are applied) and built as a lib ``` **NOTE:** `--tests` is nothing special here any target can be picked **Problem:** Rust MM Supervisor avoids hidden heap allocations from dependencies by ensuring the "alloc" feature is not enabled. Since Patina currently includes "alloc" in its default feature set, the MM Supervisor branch had to explicitly remove it from its default features(`default = []`) and also by not defining an explicit `#[global_allocator]`. Because `default-features = false` only affects a direct dependency, not transitive dependencies Now with `default=[]` in place on patina sdk in feature/supv branch, Before the SDK refactor, c_ptr.rs is gated as shown below. Which means trying to run `cargo clippy --tests` did not break the build with or without --all-features because in both cases c_ptr.rs is fully stubbed out as patina sdk is neither built with test feature(remember this is a dependency to whatever crate is being built) nor alloc(since we have set default=[]). ``` sdk\patina\src\lib.rs extern crate alloc; pub mod boot_services; sdk\patina\src\boot_services\c_ptr.rs <----- stubbed out because patina sdk is a dependency for whatever test crate is being built right now use alloc::boxed::Box; ``` After the SDK refactor, c_ptr.rs is NOT gated. Which means trying to run `cargo clippy --tests` will break the build with or without `--all-features` because in both the cases c_ptr.rs is always present and `extern crate alloc` is always absent as neither test feature(again remember this is a dependency to whatever crate is being built) nor alloc(since we have set default=[]). ``` sdk\patina\src\lib.rs extern crate alloc; pub mod base; <----- NOT STUBBED OUT sdk\patina\src\base\c_ptr.rs <----- NOT STUBBED OUT use alloc::boxed::Box; ``` Resulting in below error: ``` error[E0433]: cannot find module or crate `alloc` in this scope --> sdk\patina\src\base\c_ptr.rs:9:5 | 9 | use alloc::boxed::Box; | ^^^^^ use of unresolved module or unlinked crate `alloc` ``` While restoring the feature gate on `c_ptr` fixes this immediate issue(also done in #1677), debugging "feature" related failures like this is not a very pleasant experience. In particular, `--all-features` only applies to the package being built and does not propagate to dependencies. To some extent `cargo hack` makes it easier to run failing command on individual packages but that brings in its own set of new challenges. After spending a considerable amount of time untangling the dependencies and finding the root cause, it seems that removing "alloc" from the default feature set across all Patina crates would alleviate some of the debugging pain. **Benefits:** 1. Patina crates no longer assume the presence of the `alloc` feature. 2. Crates within Patina repo are nothing special and they have to explicitly declare the required feature set, making feature usage easier to audit and maintain. ``` E:\repos\patina>cargo tree -e features -p patina_ffs_extractors -e=no-dev patina_ffs_extractors v23.0.1 (E:\repos\patina\sdk\patina_ffs_extractors) ... ├── patina feature "default" <---- vs E:\repos\patina>cargo tree -e features -p patina_ffs_extractors -e=no-dev patina_ffs_extractors v23.0.1 (E:\repos\patina\sdk\patina_ffs_extractors) ... ├── patina feature "alloc" <---- ``` 3. Rust MM Supervisor can now opt out of `alloc` without requiring any hacks. Please note that #[global_allocator] should still be avoided so that the compiler can flag any dependent code paths that require heap allocations. This is a breaking change because existing consumers relying on Patina's default feature set will need to explicitly enable the required features. Most existing crates have already been updated as part of this commit. - [ ] Impacts functionality? - [ ] Impacts security? - [x] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? `cargo make all` and validated on hardware platform. All external crates relying on patina crates will need to add "alloc" to the features list like below `patina = { workspace = true, features = ["alloc"] }`
- The core feature is redundant and ambiguous with its dependent feature "alloc" now explicitly called out. Hence removing it. - The actual usage of the "core" feature need to reevaluated eventually, As its current usage is hacky just to expose arch::enable_interrupts() and arch::disable_interrupts() only to Patina crates (also referred to as "core" crates). However, it does not prevent external crates from enabling the core feature in their dependencies and using these restricted APIs. Overall, feature flags are intended for conditional compilation, not for enforcing visibility or access control over internal APIs. --- - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? `cargo make all` in `Patina` and `patina-dxe-core-qemu` NA: core feature is expected to be enabled only by internal crates of Patina. So removal of "alloc" should not affect consumers of patina crates. Hence the change is not marked as breaking.
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.
---
This includes a change to defer event and protocol notification
closures originally made separately. Its message is included below
for context.
Currently, events are dispatched in `restore_tpl()` by calling
`EVENT_DB.consume_next_event_notify()`. Note that the event is only
actually removed from `EVENT_DB` by calling `close_event()`.
When `EventServices` are used, the actual "raw event notification"
is a wrapper (`notify_trampoline()`) that creates a `ClosureHolder`
that contains the actual notification function registered.
Once the closure is executing, if it (or a nested call within the stack),
calls `close_event()` on its own event, the `close_event()` will remove
the event from `EVENT_DB` immediately, which frees the `ClosureHolder`
(and boxed closure). The issue is that the closure might still be
executing earlier in the call stack.
Control will return to the closure body (after the `close_event()`
call) and any use of captured state in the closure is no longer valid.
This change shares a small set of state between `notify_trampoline()`
and `close_event()` to track whether the closure is still active,
allowing `close_event()` to determine if it is safe to free the event.
Similarly, a protocol `NotifyHolder` could be freed while the callback
is still executing if the notify function cancels its own registration.
In this case, `notify_install_trampoline()` is what's actually called
when the watched protocol is installed. This change updates it to
push its context before starting to call notification functions and
then to pop its context after all notification functions have been
called to determine if its registration was requested to be closed.
`cancel_install_notify()` is updated to be able to set the
`close_requested` flag on the active notification context and defer
dropping the `NotifyHolder` if the notification is still active.
To reduce the total number of statics, a new type called
`UefiServicesState` is introduced to hold shared internal state for
UEFI Services in the DXE Core.
---
Also includes a change to tighten down config table type tracking
originally made separately. Its message is included below for context.
Makes the type tracking for configuration tables more strict and
consistent between configuration table interfaces.
There are two general paths for working with config tables:
- Untyped: C FFI for UEFI Boot Services
- Compatibility with existing C drivers using Boot Services
- Typed: Safe Rust API available through UEFI Services
- Used by Patina Rust components
These have to be supported simultaneously while keeping the safe API as
safe as possible.
The untyped path (C EFIAPI) is:
- `unsafe extern "efiapi" fn install_configuration_table`
- Which calls: `core_install_configuration_table()`
- Calls: `install_configuration_table_entry()`
The typed path (Safe Rust API) is:
- `ConfigurationTableServicesExt::install<T>()`
- Calls: `ConfigurationTableServicesExt::install_typed_table()`
- Calls: `core_install_typed_configuration_table()`
- Calls: `install_configuration_table_entry()`
On the typed path, `core_install_typed_configuration_table()` is what
checks if an update is allowed (overwrite is allowed) and record the
type information for the configuration table entry.
Below that, the same `install_configuration_table_entry()` is used for
both paths.
`CoreConfigurationTableServices::get_typed_table()` checks the type
tracked map for a table and then gets the pointer from the actual
configuration table in memory (shared with the untyped path).
To ensure that the "typed" API path is safe, an update through the
untyped path for any configuration table already under a GUID will be
unconditionally clear that table entry. This provides compatibility for
the C API while ensuring any table considered "typed" is the correct
type. This design is about ensuring the safety assertions of a typed
table in safe code, not denying updates through the untyped path.
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>
TPLs allowed as arguments to `register_install_notify()` are defined in `patina::component::service::uefi_services::tpl::Tpl`. This change prevents registering protocol install notifications at `TPL_HIGH`, ensuring that callbacks are only invoked at allowed TPL levels. Matches the behavior defined in [`CoreCreateEventEx()` in edk2](https://github.com/tianocore/edk2/blob/96341752cef63f3626d64d0b19f60202367627cf/MdeModulePkg/Core/Dxe/Event/Event.c#L332-L339) for `EVT_NOTIFY_SIGNAL` events. - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [x] Includes tests? - [ ] Includes documentation? - `cargo make all` - N/A Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
extern "efiapi" functions backing EDK II protocols carry no context parameter, so a component can't hand them a `Service<T>` the way it can a closure-based callback. `ServiceCell<T>` gives components a wait-free, write-once cell for this. The `publish()` function never blocks even under contention, so it can't deadlock under preemption like other mechanisms. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Implements the `Debug` trait for `Service<T>` to allow the type to be used in contexts where `Debug` is required. Since the `value` field in `Service<T>` is `OnceCell<&'static dyn Any>` and `dyn Any` does not implement `Debug`, the implementation here is custom (instead of deriving `Debug`) and just prints the type name of the service interface `T`. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Updates code using `Service::new_unit()` to use `ServiceCell<T>` to align on a single approach for safely storing services accessed in different contexts. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
There is nothing wrong with `Service::new_uninit()` for the use case it directly supports, that allows a `Service<T>` to be created before the underlying service is available. For example, it allows `AdvancedLogger` to be const-constructible before the actual component dispatch system is available. Then the component entry point can call `.replace()` to safely fill in the actual service implementation once the service is ready. However, there is also a need to more generically support service storage for cases when an `extern "efiapi"` protocol function produced by a component and the protocol interface does not have a `this` context pointer. Using `Service<T>` for that case is certainly possible, but it starts to mix two different use cases in a single type. `Service<T>` relies heavily on `Deref` to provide a convenient interface to the underlying service, but that convenience can be dangerous when the service is not yet available. It is easy to forget to check for availability before dereferencing, which can lead to panics. `Deref::deref()` has to return `&Target`, it cannot return `Option<&Target>`, so there is no way to signal that the service is not yet available. Of course, `is_init()` or `map_or_else()` could be used, but it is safer and makes `Service<T>` easier to reason about if it simply represents an available service. Then, dereferencing a service is always safe (the common case). This aligns with official `Deref` implementation guidance (https://doc.rust-lang.org/std/ops/trait.Deref.html#when-to-implement-deref-or-derefmut): ``` In general, deref traits should not be implemented if: 1. the deref implementations could fail unexpectedly; or 2. the type has methods that are likely to collide with methods on the target type; or 3. committing to deref coercion as part of the public API is not desirable. ``` For these cases, having a dedicated type that does not implement `Deref` allows the type to clearly distinguish between an uninitialized service and an initialized one forcing users to handle the uninitialized case explicitly while also making the usage pattern more clear. The `ServiceCell<T>` moves these semantics into a separate type that allows the value to set once (wrapping `OnceCell<T>`) and then read as an `Option<&T>` (using `get()`). Existing callers that want to panic can simply call `.get().expect("service not published yet")` to get the same behavior and provide a custom message at the call site. The `ServiceCell<T>` type is also `Sync` and compare-exchange guarded, so a second call to `publish()` will return an error instead of racing the first. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Now that `Service<T>` implements `Copy`, explicit calls to `clone()` are no longer necessary and can be removed. Also prevents the `clippy::clone_on_copy` lint from warning about unnecessary clones. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
#1832) This commit requires the platform to declare its supported UEFI Specification version, which is propagated to the various system tables. - [ ] Impacts functionality? - [ ] Impacts security? - [x] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? CI The platform must now set a specific `UefiSpecVersion` in their `PlatformInfo` trait implementation. ```rust struct Platform; impl PlatformInfo for Platform { const UEFI_SPEC_VERSION: patina::UefiSpecVersion = UefiSpecVersion::V2_11; } ```
Previously, `FromHob::parse` panicked on malformed guided HOB payloads. Since HOBs are input data outside the DXE Core's (and component's) control, HOB parsing is naturally a fallible operation and treating it as such allows more robust HOB parsing and reduces the inclination to treat malformed HOBs as fatal errors. Therefore, `FromHob::parse` now returns `Result<Self, HobParseError>`. A HOB that fails to parse is logged and not registered, so components that depend on it are not dispatched. Code that implemented `FromHob` is updated accordingly. - [x] Impacts functionality? - [ ] Impacts security? - [x] Breaking change? - [x] Includes tests? - [x] Includes documentation? - `cargo make all` - Q35 boot to EFI shell with component dispatch This is a breaking change because of the update to the `parse` method signature in the `FromHob` trait. Trait implementations will need to be updated to use the new method return value (as shown in examples in this commit). Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Tests would just restate the same mappings already defined in the enum variants, so coverage is disabled. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
`StandardAcpiProvider` is about to stop depending on `BootServices` entirely when it transitions to UEFI Services. This renames the `BootServicesAlreadyInitialized` error variant to `ConfigTableServicesAlreadyInitialized` so the next commit can focus on behavioral changes. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Updates the ACPI component to use the new UEFI Services instead of `StandardBootServices`. Overall changes are relatively minimal to focus on the transition itself and keeping in mind that more ACPI component refactoring is expected in the future. `StandardAcpiProvider` no longer needs to be generic over `BootServices`. Testing is simplified overall using `MockTplServices` and `MockConfigurationTableServices` instead of `MockBootServices`. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Updates `acpi_protocol_test` to use `ProtocolServices` instead of `StandardBootServices` to locate the ACPI Table and ACPI Get protocols. This allows two unsafe code blocks at the call sites to be removed. This was the last `StandardBootServices` usage in the crate, so `patina_acpi` no longer depends on it at all. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
The ACPI Table and ACPI Get protocols are currently insalled at the beginning of the entry point. This is before the `STANDARD_ACPI_PROVIDER` is initialized and the XSDT and RSDP exist. This commit moves protocol installation to the end of the entry point, after the `AcpiTableManager` service is produced. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Updates the entry point to depend on `ProtocolServices`. Replaces raw pointer handling with safe code using `on_protocol_installed()`. Implements the `ProtocolInterface` trait for `MmCommBufferUpdateProtocol` to allow safe access to the protocol's fields without unsafe pointer casts. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Protocol services can be mocked with the `ProtocolServices` trait now, so functions dependent on that like `entry_point` and `handle_protocol_installed` are updated to use mocked protocol services and drop their exclusion from code coverage. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
`CpuArchProtocolInstaller`, `HwInterruptProtocolInstaller`, `SystemTableChecksumInstaller`, and `DecompressProtocolInstaller` were the last components in patina_dxe_core still depending on `StandardBootServices` directly. This change moves them onto `Service<dyn ProtocolServices>` so `StandardBootServices` can be removed from the component model in a follow up change. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
…overage Some internal component entry points could be tested with service mocks, but they are just installing protocols or notification functions without significant logic, so coverage is disabled. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Removes the `StandardBootServices` param from the component benchmark entry points since `StandardBootServices` is about to be removed from the component model. - [x] Impacts functionality? - [ ] Impacts security? - [x] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? - `cargo make bench` - N/A Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit updates Patina Test to use the UEFI Services APIs made available through the core, instead of using StandardBootServices struct. - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? N/A N/A
Now that no component in patina_dxe_core depends on `StandardBootServices` directly, this drops `ComponentDispatcher::set_boot_services` and the code in `Core::initialize_system_table` that constructed a `StandardBootServices` for the component dispatcher. `StandardRuntimeServices` is not modified. - [x] Impacts functionality? - [ ] Impacts security? - [x] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? - `cargo make all` - QEMU EFI shell boot with components using UEFI Services - N/A Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Removes the `StandardBootServices` `Param` implementation and all references to it. Removes the `boot_services` field from `Storage`. Removes logic in the `#[component]` parameter validation macro that checked for duplicate `StandardBootServices` parameters. In cases where `StandardBootServices` was used as an example type in tests for `Option<T>` and tuple `Param` implementations, it was replaced with `StandardRuntimeServices`. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Straightforward update to docs that referenced `StandardBootServices` to either drop the reference or replace it with the equivalent info or example from UEFI Services. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Adds a document that explains common scenario where services need be shared and stored and patterns for those scenarios. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Adds a document that explains when to use Patina UEFI Services and links to individual service documentation. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
`FromHob::parse` was updated to return `Result<Self, HobParseError>`. This commit reports a truncated `MpInformation2`, `MpHandOff` or `MpHandOffConfig` as `BufferTooSmall` instead of being parsed as empty or zeroed data. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Updates the MP Services patina tests to account for UEFI Services. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Accounts for `StandardBootServices` no longer being a component parameter. The MP Services component now takes the services it needs as parameters rather than as a single `StandardBootServices` structure. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit splits the MP services component into 3: 1. `MpServicesComponent` - Creates the service and all associated resources. 2. `MpProtocolInstaller` - Installs the MP services protocol using the service. 3. `MpBistReporter` - Reports the Built-In Self-Test (BIST) results for the processors from PEI. To split this functionality, the `MpServices` service now gets installed as a service. However, the definition of this struct is scoped to the `mp_services` module and so it cannot be retrieved or used by external components.
Updates the documentation to reflect the new component split in MP services.
Description
Closes #1537
Closes #432
Closes #515
Merges changes accumulated in the
majorbranch since the last Patina major release into themainbranch. By definition, this will be a breaking change for Patina integration. Read the integration notes carefully, refer to QEMU examples, sample code included in these changes, documentation updates, and finally reach out in GitHub discussions if there are any questions.Key high-level changes:
FromHob::parsefallibleHow This Was Tested
patina_samplesusing UEFI ServicesIntegration Instructions
Review the UEFI Services overview
Replace components using
StandardBootServiceswith the corresponding UEFI Service dependenciesReview the Patina UEFI Services samples to see how UEFI Services are used for common operations
Update the code used to build your DXE core binary to account for components that may have been split into more granular components. The following components were split into more granular components:
patina_performanceandpatina_smbiosUpdate the code used to build your DXE Core binary to specify the UEFI Specification version your platform supports by assigning
PlatformInfo::UEFI_SPEC_VERSION. For example:Detailed Changes
1687: [major] Remove "alloc" from "core" feature
Description
The core feature is redundant and ambiguous with its dependent
feature "alloc" now explicitly called out. Hence removing it.
The actual usage of the "core" feature need to reevaluated eventually,
As its current usage is hacky just to expose
arch::enable_interrupts() and arch::disable_interrupts() only to
Patina crates (also referred to as "core" crates). However, it does
not prevent external crates from enabling the core feature in their
dependencies and using these restricted APIs. Overall, feature flags
are intended for conditional compilation, not for enforcing
visibility or access control over internal APIs.
Impacts functionality?
Impacts security?
Breaking change?
Includes tests?
Includes documentation?
How This Was Tested
cargo make allinPatinaandpatina-dxe-core-qemuIntegration Instructions
NA: core feature is expected to be enabled only by internal crates of Patina. So removal of "alloc" should not affect consumers of patina crates. Hence the change is not marked as breaking.
1743: Add Initial Patina UEFI Services
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:
sdk\patina\src\component\service\uefi_services.patina_dxe_core\src\uefi_services.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.
How This Was Tested
cargo make allInitial component dispatch (DXE core and sample components):
Later after the Timer Architectural protocol is installed:
End of DXE messages:
All Patina on-system tests pass:
GraphicsConsoleDxefrom QEMU platforms and using thepatina_graphics_consolecomponent instead.Integration Instructions
1787: Prevent protocol notification at TPL_HIGH
Description
Note: This can be squashed into earlier commits when major is being prepared to merge into main.
TPLs allowed as arguments to
register_install_notify()are defined inpatina::component::service::uefi_services::tpl::Tpl.This change prevents registering protocol install notifications at
TPL_HIGH, ensuring that callbacks are only invoked at allowed TPL levels.Matches the behavior defined in
CoreCreateEventEx()in edk2 forEVT_NOTIFY_SIGNALevents.How This Was Tested
cargo make allIntegration Instructions
1778: Add and integrate ServiceCell
Description
A series of commits for adding a new type
ServiceCell<T>in place ofService::new_unit(). This was already part of approved changes in #1743, but broken out here for clarity.sdk: Add ServiceCell for bridging services to context-free callbacks
extern "efiapi" functions backing EDK II protocols carry no context
parameter, so a component can't hand them a
Service<T>the way itcan a closure-based callback.
ServiceCell<T>gives components await-free, write-once cell for this. The
publish()function neverblocks even under contention, so it can't deadlock under preemption
like other mechanisms.
sdk: Impl Debug for Service
Implements the
Debugtrait forService<T>to allow the type to beused in contexts where
Debugis required.Since the
valuefield inService<T>isOnceCell<&'static dyn Any>and
dyn Anydoes not implementDebug, the implementation hereis custom (instead of deriving
Debug) and just prints the typename of the service interface
T.Swap Service::new_unit() usage to ServiceCell
Updates code using
Service::new_unit()to useServiceCell<T>toalign on a single approach for safely storing services accessed in
different contexts.
sdk: Drop Service::new_uninit()
There is nothing wrong with
Service::new_uninit()for the use caseit directly supports, that allows a
Service<T>to be created beforethe underlying service is available.
For example, it allows
AdvancedLoggerto be const-constructiblebefore the actual component dispatch system is available. Then the
component entry point can call
.replace()to safely fill in theactual service implementation once the service is ready.
However, there is also a need to more generically support service
storage for cases when an
extern "efiapi"protocol function producedby a component and the protocol interface does not have a
thiscontext pointer. Using
Service<T>for that case is certainlypossible, but it starts to mix two different use cases in a single
type.
Service<T>relies heavily onDerefto provide a convenientinterface to the underlying service, but that convenience can be
dangerous when the service is not yet available. It is easy to
forget to check for availability before dereferencing, which can
lead to panics.
Deref::deref()has to return&Target, it cannotreturn
Option<&Target>, so there is no way to signal that theservice is not yet available.
Of course,
is_init()ormap_or_else()could be used, but itis safer and makes
Service<T>easier to reason about if itsimply represents an available service. Then, dereferencing a
service is always safe (the common case).
This aligns with official
Derefimplementation guidance(https://doc.rust-lang.org/std/ops/trait.Deref.html#when-to-implement-deref-or-derefmut):
For these cases, having a dedicated type that does not implement
Derefallows the type to clearly distinguish between anuninitialized service and an initialized one forcing users to
handle the uninitialized case explicitly while also making the
usage pattern more clear.
The
ServiceCell<T>moves these semantics into a separate typethat allows the value to set once (wrapping
OnceCell<T>) and thenread as an
Option<&T>(usingget()). Existing callers that wantto panic can simply call
.get().expect("service not published yet")to get the same behavior and provide a custom message at the call
site. The
ServiceCell<T>type is alsoSyncand compare-exchangeguarded, so a second call to
publish()will return an error insteadof racing the first.
Remove clone calls on Service instances
Now that
Service<T>implementsCopy, explicit calls toclone()are no longer necessary and can be removed.
Also prevents the
clippy::clone_on_copylint from warning aboutunnecessary clones.
How This Was Tested
cargo make allIntegration Instructions
1798: Integrate UEFI Services with patina_performance and refactor the component
Description
A series of commits to split patina_performance into more granular components that take dependencies relevant to that task they are performing and integrate UEFI Services in the process.
patina_performance: Migrate protocol.rs to MeasurementProtocolPublisher
Splits the protocol-installation responsibility out of the monolithic
Performance component into its own MeasurementProtocolPublisher, and
replaces the custom ServiceHolder (OnceCell + AtomicBool + manual
unsafe impl Sync) with ServiceCell, installing the protocol
through ProtocolServicesExt instead of a raw BootServices call.
The old Performance component is untouched and keeps working during
this incremental migration. It will be removed once the remaining
components are split out.
patina_performance: Add PropertyPublisher component
Splits performance property publishing out of the monolithic
Performance component. Depends only on
ArchTimerFunctionalityandConfigurationTableServicesfor its own work, plusPerformanceManageras a dependency so this table is only published when performance
measurement is enabled.
patina_performance: Add FbptPublisher component
Splits FBPT (Firmware Basic Boot Performance Table) publishing out of
the monolithic Performance component.
Migrates the End-of-DXE event registration, protocol location, page
allocation, and configuration table installation from raw
BootServicescalls to granular service calls to
EventServices,ProtocolServices,MemoryManager, andConfigurationTableServices.RuntimeServicesis left as a generic parameter since there is nota dedicated Patina service for Runtime Services at this time.
The old
close_event()once-only guard is replaced with a capturedCell<bool>, since the closure-based event API does not hand thecallback its own
Eventto close.patina_performance: Add MmRecordCollector component
Splits MM performance record collection out of the monolithic
Performance component.
mm_comm_serviceis now a requiredService<dyn MmCommunication>rather than
Option<Service<...>>, so the dispatcher itself skipsthis component on platforms with no MM communication region instead
of branching on an
Option<Service<...>>at runtime.Also adds a
core::error::ErrorimplforMmPerformanceErrorwhile it is already being moved.
patina_performance: Remove the monolithic Performance component
The monolithic Performance component has now been split into separate
single-purpose components, each with its own responsibilities, so it
can be removed.
components/patina_performance: Add key log messages
Makes it easier to confirm key events happen in the patina_perforamnce
components by being able to track and verify important events in the
log.
Update docs for the patina_performance component split
Updates docs in the mdbook and the patina_performance component crate
to reflect the recent split of the monolithic patina_performance
component into separate components.
How This Was Tested
cargo make allPERF_TRACE_ENABLE=TRUEand check perf data is availableIntegration Instructions
1807: sdk: Implement TplController for Service
Description
Adds an
implofTplControllerforService<dyn TplServices>along with aTryFrom<BootServicesTpl>implementation forTplthat acts as a bridge between the raw boot services TPL values and the newerTplenum.The "raw" TPL type is
BootServicesTplwhich is ultimately ausizeand it can hold TPL values outside those defined by the UEFI Specification. TheTplenum is a strongly-typed representation of the standard TPL levels defined by the UEFI specification for use in UEFI Services.TplMutexdefaults toStandardBootServices:By implementing
TplControllerforService<dyn TplServices>, the TPL Service can now be used withTplMutex.How This Was Tested
cargo make allTplMutexin components back byTplServicesIntegration Instructions
1814: Add no-notification timer event support to UEFI Services
Description
Allows timer events to be created without notification functions. The current function (
TimerEventServices::create_timer_event()) creates the event withEVT_TIMER | EVT_NOTIFY_SIGNALand requires a boxed notification callback. For code wanting to simply create a timer event and check it withEventServices::check_event()there is not a direct path with UEFI Services becausecheck_event()(per spec) requires that the event is not a notify-signal event.This adds a function called
create_timer_event_no_notify(). That name is consistent with naming convention to others in the trait and allows timer events without notification functions to easily be created for this use case. A simple example is addeed to timers.rs in patina_samples.How This Was Tested
cargo make all(including unit tests)Integration Instructions
1813: Add device path APIs to UEFI Services
Description
Adds first-class support for device paths to protocol services.
Similar to other protocol service methods,
ProtocolServicesgets alocate_device_path()method that can take aBinaryGuidand aDevicePathdirectly.ProtocolServicesExtgets the fully featured version taking advantage of theProtocolInterfacetrait. It is called as follows:To support this,
locate_device_path()is added toCoreProtocolServicesin patina_dxe_core as a wrapper aroundcore_locate_device_path(). This provides handling for theBinaryGuidandDevicePathtypes around the call.How This Was Tested
cargo make all(including unit tests)Integration Instructions
1821: Add marker protocol APIs to UEFI Services
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_interfacefunction can't express a "marker" protocol because it takesProtocolPtrwhich wrapsNonNull<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_protocolalso have logic around returning sound protocol interfaces to callers (e.g. verifying the GUID matches the protocol interface).The
ProtocolInterfacetrait 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)anduninstall_marker_protocol::<P>(handle)to protocol services to make working with marker protocols andProtocolInterfaceobvious and ergonomic.An
is_marker_protocol_installedfunction 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.
How This Was Tested
cargo make all(including unit test changes)Integration Instructions
1831: Only return config table copies and pointers
Description
Note: Can be squashed into the earlier configuration table UEFI services commit when
majoris merged intomain.Updates the configuration table services currently returning
&'staticreferences to return a copy instead.This changes:
To:
To allow the caller to determine whether they can work with a short-lived reference, a pointer to the table is available through a new function with function doc guidance on using it:
How This Was Tested
cargo make allIntegration Instructions
major1815: components/patina_adv_logger: Update to use UEFI Services
Description
Replaces boot services calls to
StandardBootServiceswith calls to the Patina UEFI Services.Includes some test code for the component entry point.
How This Was Tested
cargo make all(with unit tests included)Integration Instructions
1819: Split event ownership model
Description
Note: These commits can be squashed into commit 98e6dc3 when the major branch is merged into main.
Split event ownership model
Currently the function (e.g.
on_event) that registers a callback returns theEvent. This makes it difficult to pass that event through to the notification function. There is tension between the ownership of the event at the caller and notification (closure) levels. The original implementation essentially did not provide a straightforward path for notifications to close their own event and leaving it to the caller.Notifications closing their own event is common and there was a previous change made to defer their closure/cleanup in nested notification scenarios.
This change better reflects the two event ownership models: one where the caller retains ownership and one where the callback takes ownership. This is done by separting event creation functions into "caller-managed" and "self-managed" variants. This makes intention clear in the code while preventing ownership confusion.
Add create_wait_event to UEFI Services
Allows a caller to create a wait (non-timer) event.
How This Was Tested
cargo make all(includes unit test updates)patina_samplescomponents on QEMU Q35Integration Instructions
1836: Add signal_group to UEFI Services
Description
Provides a simple way to signal an event group by GUID using event services.
Found during an audit of event patterns currently not available in event services.
How This Was Tested
cargo make all(unit tests)Integration Instructions
1811: Integrate UEFI Services with patina_smbios and refactor the component
Description
A series of commits to integrate UEFI Services into
patina_smbiosand refactor the component to take more granular dependencies and to use injected dependencies on the component entry point(s). These changes are unmodified in any significant way from the already approved changes in a previous, larger UEFI Services PR.components/patina_smbios: Add a Busy error for SMBIOS lock contention
Adds
SmbiosError::Busyso lock contention can be reported as anormal error. It maps to
EfiError::DeviceError.components/patina_smbios: Extend the Smbios trait with record lookup methods
Adds a couple of methods to the
Smbiostrait so the C protocol shimwill be able to look up the next record after a handle and the address
of a published record without touching the
SmbiosManageror itsTplMutexdirectly.Both return owned data instead of a borrowing iterator, since the
existing
SmbiosRecordsItercannot outlive a lock guard.components/patina_smbios: Move SMBIOS service off raw BootServices
SmbiosImplno longer takes a genericBootServicesparameter. ItsTplMutexnow usesService<dyn TplServices>. Every lock acquisitiongoes through
try_lock, which returnsSmbiosError::Busyon lockcontention instead of panicking.
SmbiosImplstores aService<dyn ConfigurationTableServices>and uses it to install theSMBIOS configuration table entry.
SmbiosProtocolInternalnow holds only the protocol struct and aService<dyn Smbios>, dropping the rawTplMutexreference.The extern functions call through the service trait instead of locking
the manager directly, and the protocol is installed through
ProtocolServicesinstead of a raw unsafe boot services call.component.rs is updated minimally to keep the crate compiling, still
fetching the newly needed services through
storage.get_serviceinthe same style it already used. It will be split into two components
with typed parameters in a future change.
components/patina_smbios: Split SmbiosProvider and add SmbiosProtocolPublisher
Moves
SmbiosProviderinto component/provider.rs and migrates itsentry point to use typed service parameters for memory, configuration
table, and TPL services, plus
Commandsfor registration, droppingthe
storage.get_serviceandstorage.boot_servicescalls usedpreviously. Buffer allocation is updated to use
leak_as_sliceinsteadof
into_raw_slice.Adds a new
SmbiosProtocolPublishercomponent that installs theprotocol for C drivers depending only on
Service<dyn Smbios>andService<dyn ProtocolServices>. This is the piece the earlierSmbiostrait extension made it possible to split out on its own.Adds a new entry point test for each component, now that every
dependency is mockable.
Update SMBIOS docs for the two component split
Updates the crate README and the patina_samples SMBIOS example to
reflect the
SmbiosProviderandSmbiosProtocolPublishersplit.Updates the "Global State Justification" section to describe that the
C protocol shim now reaches the
Smbiosservice through a field onthe leaked protocol struct instead of extra global state.
How This Was Tested
cargo make allIntegration Instructions
1832: patina_dxe_core: Require platforms declare supported UEFI spec version
Description
This commit requires the platform to declare its supported UEFI Specification version, which is propagated to the various system tables.
How This Was Tested
CI
Integration Instructions
The platform must now set a specific
UefiSpecVersionin theirPlatformInfotrait implementation.1839: Make FromHob::parse fallible
Description
Previously,
FromHob::parsepanicked on malformed guided HOB payloads.Since HOBs are input data outside the DXE Core's (and component's) control, HOB parsing is naturally a fallible operation and treating it as such allows more robust HOB parsing and reduces the inclination to treat malformed HOBs as fatal errors.
Therefore,
FromHob::parsenow returnsResult<Self, HobParseError>.A HOB that fails to parse is logged and not registered, so components that depend on it are not dispatched.
Code that implemented
FromHobis updated accordingly.How This Was Tested
cargo make allIntegration Instructions
This is a breaking change because of the update to the
parsemethod signature in theFromHobtrait. Trait implementations will need to be updated to use the new method return value (as shown in examples in this commit).1844: components/patina_acpi: Update to use UEFI Services
Description
A series of commits to update the patina_acpi component to use UEFI Services.
This change is light on component refactor unrelated to directly using the services since an overall patina_acpi component refactor is already planned in the future.
components/patina_acpi: Cover all AcpiError enum variants with tests
Improve the code coverage in this module by adding tests that cover
variants that are not currently covered.
components/patina_acpi: Rename BootServicesAlreadyInitialized
StandardAcpiProvideris about to stop depending onBootServicesentirely when it transitions to UEFI Services.
This renames the
BootServicesAlreadyInitializederror variant toConfigTableServicesAlreadyInitializedso the next commit can focuson behavioral changes.
components/patina_acpi: Use UEFI Services in the ACPI component
Updates the ACPI component to use the new UEFI Services instead of
StandardBootServices. Overall changes are relatively minimal tofocus on the transition itself and keeping in mind that more ACPI
component refactoring is expected in the future.
StandardAcpiProviderno longer needs to be generic overBootServices.Testing is simplified overall using
MockTplServicesandMockConfigurationTableServicesinstead ofMockBootServices.components/patina_acpi: Use ProtocolServices in acpi_protocol_test
Updates
acpi_protocol_testto useProtocolServicesinstead ofStandardBootServicesto locate the ACPI Table and ACPI Get protocols.This allows two unsafe code blocks at the call sites to be removed.
This was the last
StandardBootServicesusage in the crate, sopatina_acpino longer depends on it at all.components/patina_acpi: Install protocols at end of the entry point
The ACPI Table and ACPI Get protocols are currently insalled at the
beginning of the entry point. This is before the
STANDARD_ACPI_PROVIDERis initialized and the XSDT and RSDP exist.
This commit moves protocol installation to the end of the entry point,
after the
AcpiTableManagerservice is produced.How This Was Tested
cargo make allIntegration Instructions
1841: components/patina_mm: Update to use UEFI Services
Description
A couple of commits to update the patina_mm component to use UEFI Services.
components/patina_mm: Replace StandardBootServices with UEFI Services
Updates the entry point to depend on
ProtocolServices. Replaces rawpointer handling with safe code using
on_protocol_installed().Implements the
ProtocolInterfacetrait forMmCommBufferUpdateProtocolto allow safe access to the protocol's fields without unsafe pointer
casts.
components/patina_mm: Increase test coverage with protocol mocking
Protocol services can be mocked with the
ProtocolServicestraitnow, so functions dependent on that like
entry_pointandhandle_protocol_installedare updated to use mocked protocolservices and drop their exclusion from code coverage.
How This Was Tested
cargo make allIntegration Instructions
1847: patina_dxe_core: Migrate internal components off StandardBootServices
Description
CpuArchProtocolInstaller,HwInterruptProtocolInstaller,SystemTableChecksumInstaller, andDecompressProtocolInstallerwere the last components in patina_dxe_core still depending onStandardBootServicesdirectly.This change moves them onto
Service<dyn ProtocolServices>soStandardBootServicescan be removed from the component model in a follow up change.How This Was Tested
cargo make allIntegration Instructions
1848: sdk: Update component benchmark to drop StandardBootServices
Description
Removes the
StandardBootServicesparam from the component benchmark entry points sinceStandardBootServicesis about to be removed from the component model.How This Was Tested
cargo make benchIntegration Instructions
1830: components/patina_test: Update to use UEFI Services
Description
This commit updates Patina Test to use the UEFI Services APIs made
available through the core, instead of using StandardBootServices struct.
How This Was Tested
N/A
Integration Instructions
N/A
1850: patina_dxe_core: Remove StandardBootServices from the dispatcher
Description
Now that no component in patina_dxe_core depends on
StandardBootServicesdirectly, this dropsComponentDispatcher::set_boot_servicesand the code inCore::initialize_system_tablethat constructed aStandardBootServicesfor the component dispatcher.StandardRuntimeServicesis not modified.How This Was Tested
cargo make allIntegration Instructions
1851: sdk: Remove StandardBootServices from the Patina SDK component model
Description
Two commits to remove
StandardBootServicesfrom the SDK component code and mdbook documentation.sdk: Remove StandardBootServices from the Patina SDK component model
Removes the
StandardBootServicesParamimplementation and all references to it. Removes theboot_servicesfield fromStorage.Removes logic in the
#[component]parameter validation macro that checked for duplicateStandardBootServicesparameters.In cases where
StandardBootServiceswas used as an example type in tests forOption<T>and tupleParamimplementations, it was replaced withStandardRuntimeServices.docs: Account for StandardBootServices removal
Straightforward update to docs that referenced
StandardBootServicesto either drop the reference or replace it with the equivalent info
or example from UEFI Services.
How This Was Tested
cargo make allcargo make test-mdbookIntegration Instructions
1854: UEFI Services documentation updates
Description
New documentation and updates to existing documentation in the mdbook to account for UEFI Services.
docs: Add component state storage docs
Adds a document that explains common scenario where services need
be shared and stored and patterns for those scenarios.
docs: Add Patina UEFI Services documentation
Adds a document that explains when to use Patina UEFI Services and
links to individual service documentation.
How This Was Tested
cargo make cspellmdbook build docscargo make serve-mdbookIntegration Instructions
1866: patina_dxe_core: Split the MP services component
Description
This commit splits the MP services component into 3:
MpServicesComponent- Creates the service and all associated resources.MpProtocolInstaller- Installs the MP services protocol using the service.MpBistReporter- Reports the Built-In Self-Test (BIST) results for the processors from PEI.To split this functionality, the
MpServicesservice now gets installed as a service. However, the definition of this struct is scoped to themp_servicesmodule and so it cannot be retrieved or used by external components.How This Was Tested
Integration Instructions
N/A