Repository navigation
patina-v24.5.0
What's Changed
Note
The minor version was bumped in this release to bring notice to the Patina MM Supervisor being available in the release.
🐛 Bug Fixes
-
[feature/supv] patina\_mm\_supervisor: Fix the version check for minor 0 @vineelko (#2015)
Change Details
## Description
[feature/supv] patina_mm_supervisor: Fix the version check for minor 0
The compile time check on the crate version now uses strict comparisons
with the same limits: a major version below 100 and a minor version below
1000.The crate version update to 25.0.0 failed clippy. The minor version is
0, so the check compared the minimum u32 value with 999:error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false --> patina_mm_supervisor/src/version.rs:30:34The lint clippy::absurd_extreme_comparisons is in the correctness group.
The workspace Cargo.toml sets that group to deny in its
workspace.lints.clippy table, and this crate inherits the workspace
lints, so the lint is a build error. Clippy does not flag a strict
comparison with the minimum value. Clippy and the crate tests pass with
the workspace at both 24.4.1 and 25.0.0.- Impacts functionality?
- Impacts security?
- Breaking change?
- Includes tests?
- Includes documentation?
How This Was Tested
cargo make clippy with artificially bumping the version to
25.0.0Integration Instructions
NA
🔐 Security Impacting
-
[Rebase \& FF] Patina: Rust based MM Supervisor and User Core @vineelko (#1875)
Change Details
## Description
[feature/supv] patina: sdk: Add MM services and the supervisor ABI
[feature/supv] patina: core: patina_internal_cpu: save state support for supv
patina: Add MemoryRange for checked address ranges
[feature/supv] patina_mm_supervisor: Add the MM supervisor core
[feature/supv] patina_mm_supervisor: Add unit tests across the crate
[feature/supv] patina_mm_user_core: Add the MM user core
[feature/supv] patina_mm_user_core: Improve unit test coverage
[feature/supv] patina: component: Add a MM CPU component at mm user level
[feature/supv] docs: Add the MM supervisor and user core documentationRFC: https://github.com/OpenDevicePartnership/patina/blob/main/docs/src/rfc/text/0026-mm-supv.md
[feature/supv] patina: sdk: Add MM services and the supervisor ABI
Add the MmServices trait to the patina SDK. The trait is the safe Rust
interface to the PI EFI_MM_SYSTEM_TABLE services. It covers pool and
page allocation, MMI handler registration, protocol install
notifications, and handle lookup. Every method returns a Result instead
of a raw status.A core such as patina_mm_user_core implements MmServices and registers
that implementation with StandardMmServices. The EfiMmSystemTable
function pointers then forward each C call into the registered
implementation. Rust callers use the trait directly and never dispatch
through the shared table. Components reach the same implementation
through MmServiceProvider, which resolves during parameter setup.Also add the management_mode::supervisor module. It holds what the two
halves of the MM core must agree on before either one exists: the
module GUIDs for the supervisor core, the user core and the init
module, the UserCommandType values the supervisor passes when it calls
into Ring 3, the SyscallIndex values Ring 3 passes back, and
raw_syscall. Neither half can own this, so it lives in the SDK.
[feature/supv] patina: core: patina_internal_cpu: save state support for supv
Add a save_state module to patina_internal_cpu. It defines the
MmSaveStateRegister values from the PI specification and the vendor
register maps that give the offset and width of each register inside the
SMRAM save state area.The MM supervisor needs these offsets to serve save state reads on behalf
of Ring 3 code. The layout differs between Intel and AMD, so each vendor
map lives in its own file, intel.rs and amd.rs.Both maps are always compiled so each one is type checked and unit tested
in every build, including the --all-features build that CI uses for
clippy, coverage, and docs. The active map is chosen by the
save_state_intel and save_state_amd features. Intel is the default when
both features or neither feature is enabled.
patina: Add MemoryRange for checked address ranges
Add MemoryRange to the base module and export it, with MemoryRangeError,
from the crate root. A MemoryRange is a [base, base + size) range whose
size is never zero and whose end always fits in a u64. The constructors
(new, from_inclusive, from_pages and TryFrom for Rust ranges) return an
error instead of building a range that breaks these rules.Code that handles address ranges as (base, size) pairs repeats the same
overflow, overlap and containment checks, often with checked_add at each
call site. With these rules held by the type, a range that wraps the
address space or has no size cannot reach that code.The type provides containment, overlap, intersection, union, alignment
checks, extension and iteration by step. collapse returns the range that
covers a list of ranges, and coalesce does the same but fails when the
ranges leave a gap. find_overlap returns the first overlapping pair in a
list, and coverage reports whether a list covers a range fully, partly,
or not at all. MemoryRangeError converts to EfiError::InvalidParameter.
[feature/supv] patina_mm_supervisor: Add the MM supervisor core
Add patina_mm_supervisor, the Ring 0 half of the standalone MM core. It
runs on x86-64 and replaces the C MM supervisor in MmSupervisorPkg. The
entry shim starts at efi_main and jumps to rust_main, which the
platform binary supplies.The BSP performs the one time initialization and then serves incoming
MMI requests. It arms the syscall entry path and the call gate, builds
the page tables and the memory policy, programs the SMRRs to protect
MMRAM from accesses outside MM, and demotes execution to Ring 3 before
it calls the user core. APs wait in a holding pen and poll a mailbox
for work from the BSP.The crate does not allocate from a heap.
[feature/supv] patina_mm_supervisor: Add unit tests across the crate
Add unit tests that run on the host for most modules in the crate: HOB
validation, the page and paging allocators, the policy gate, the
syscall dispatcher, the call gate, the supervisor request handlers,
save state, SMRR, the mailbox and the semaphore. A new test_support
module holds the shared fixtures, and mm_policy gains a builder for
synthetic policy buffers.
[feature/supv] patina_mm_user_core: Add the MM user core
Add patina_mm_user_core, the Ring 3 half of the standalone MM core. It
performs the same work as the C StandaloneMmCore. It walks the HOB list
to find MM drivers, evaluates their dependency expressions, dispatches
them, and routes MMI requests to the registered handlers.The supervisor calls the entry point with one of three commands.
StartUserCore runs the one time setup and the first dispatch pass.
UserRequest parses a communication buffer and invokes the matching MMI
handler. UserApProcedure runs a procedure on behalf of an AP.The crate implements the MmServices trait from the SDK and publishes an
EfiMmSystemTable for C drivers. It keeps its own protocol database and
configuration table, and serves small allocations from a pool that
requests pages from the supervisor by syscall. Ring 3 has no direct
access to supervisor resources, so every privileged operation goes
through the syscall interface. A component dispatcher lets a platform
register native Patina components next to the C drivers.
[feature/supv] patina_mm_user_core: Improve unit test coverage
| Filename | Function Coverage | Line Coverage | Region Coverage | | --------------------------------------------------------------------------- | ----------------- | ----------------- | ----------------- | | patina_mm_user_core\src\component_dispatcher.rs | 100.00% (19/19) | 100.00% (83/83) | 95.80% (137/143) | | patina_mm_user_core\src\config_table.rs | 100.00% (7/7) | 100.00% (69/69) | 98.72% (77/78) | | patina_mm_user_core\src\core_handlers.rs | 100.00% (10/10) | 94.74% (90/95) | 92.04% (104/113) | | patina_mm_user_core\src\lib.rs | 100.00% (19/19) | 86.18% (187/217) | 85.25% (289/339) | | patina_mm_user_core\src\mm_dispatcher.rs | 100.00% (9/9) | 93.33% (140/150) | 89.26% (216/242) | | patina_mm_user_core\src\mm_mem.rs | 100.00% (8/8) | 100.00% (45/45) | 100.00% (68/68) | | patina_mm_user_core\src\mm_services.rs | 100.00% (34/34) | 99.47% (378/380) | 98.85% (431/436) | | patina_mm_user_core\src\mmi.rs | 100.00% (17/17) | 99.41% (169/170) | 96.40% (214/222) | | patina_mm_user_core\src\pool_allocator.rs | 100.00% (9/9) | 100.00% (90/90) | 99.38% (160/161) | | patina_mm_user_core\src\protocol_db.rs | 100.00% (29/29) | 100.00% (153/153) | 100.00% (248/248) |
[feature/supv] patina: component: Add a MM CPU component at mm user level
Add patina_mm_cpu, a component that produces the PI EFI_MM_CPU_PROTOCOL
inside the MM user core. The protocol lets MM drivers read the
architecture standard registers of a CPU save state, including the fields
that describe the I/O instruction that caused a software MMI.The save state lives in SMRAM that only the supervisor can read, so Ring
3 cannot reach it. ReadSaveState forwards each read to the supervisor
through the save state syscall, and the supervisor applies the save state
policy before it returns a value.This replaces the C MmSupervisedCpu driver in MmSupervisorPkg. A platform
registers the component through its MmComponentInfo implementation.
[feature/supv] docs: Add the MM supervisor and user core documentation
Add a Patina MM Subsystems part to the book. It explains how
patina_mm_supervisor and patina_mm_user_core work, from the first MMI to
the services that MM drivers call, so a reader can follow the design
without reading the code first.The part has eight pages:
- Theory and Operation: actors, cores and rings, the MMRAM map, the
trust model, the crate map and the global state of each core - Initialization and Initialization Validation: the first MMI on the
BSP and the APs, and every check made on what MM Init hands over - Privilege Boundary: demotion to Ring 3, the call gate, the syscalls,
failure handling and Ring 0 access to user pages - MMI Handling: the rendezvous, the communication buffers, supervisor
and user requests, and AP procedures - Memory Management: MMRAM and the SMRRs, the page allocator, the page
table, page ownership and unblocked memory - Security Policy: the policy blob, the runtime gate, the memory policy
and the boundary audit - User Core: the MM System Table, the protocol and MMI handler
databases, component and driver dispatch, and the save state
A new integration page, Patina MM Supervisor Requirements, lists what a
platform must provide: processor support, MMRAM layout, MM Init state,
HOBs, the security policy file, MM driver rules and the requests from
outside MM, followed by the known limitations. The figures are SVG files
in docs/src/media, drawn in one style with numbered steps. Every
statement was checked against the code.- Impacts functionality?
- Impacts security?
- Breaking change?
- Includes tests?
- Includes documentation?
How This Was Tested
Validated on internal hardware platforms.
Integration Instructions
Consumed in SEA repository to produce Supervisor, User Core, SEA rule sets and related binaries.
Note: Patina v24.4.1 is the last release before merging this PR.
- Theory and Operation: actors, cores and rings, the MMRAM map, the
📖 Documentation Updates
-
[Rebase \& FF] Patina: Rust based MM Supervisor and User Core @vineelko (#1875)
Change Details
## Description
[feature/supv] patina: sdk: Add MM services and the supervisor ABI
[feature/supv] patina: core: patina_internal_cpu: save state support for supv
patina: Add MemoryRange for checked address ranges
[feature/supv] patina_mm_supervisor: Add the MM supervisor core
[feature/supv] patina_mm_supervisor: Add unit tests across the crate
[feature/supv] patina_mm_user_core: Add the MM user core
[feature/supv] patina_mm_user_core: Improve unit test coverage
[feature/supv] patina: component: Add a MM CPU component at mm user level
[feature/supv] docs: Add the MM supervisor and user core documentationRFC: https://github.com/OpenDevicePartnership/patina/blob/main/docs/src/rfc/text/0026-mm-supv.md
[feature/supv] patina: sdk: Add MM services and the supervisor ABI
Add the MmServices trait to the patina SDK. The trait is the safe Rust
interface to the PI EFI_MM_SYSTEM_TABLE services. It covers pool and
page allocation, MMI handler registration, protocol install
notifications, and handle lookup. Every method returns a Result instead
of a raw status.A core such as patina_mm_user_core implements MmServices and registers
that implementation with StandardMmServices. The EfiMmSystemTable
function pointers then forward each C call into the registered
implementation. Rust callers use the trait directly and never dispatch
through the shared table. Components reach the same implementation
through MmServiceProvider, which resolves during parameter setup.Also add the management_mode::supervisor module. It holds what the two
halves of the MM core must agree on before either one exists: the
module GUIDs for the supervisor core, the user core and the init
module, the UserCommandType values the supervisor passes when it calls
into Ring 3, the SyscallIndex values Ring 3 passes back, and
raw_syscall. Neither half can own this, so it lives in the SDK.
[feature/supv] patina: core: patina_internal_cpu: save state support for supv
Add a save_state module to patina_internal_cpu. It defines the
MmSaveStateRegister values from the PI specification and the vendor
register maps that give the offset and width of each register inside the
SMRAM save state area.The MM supervisor needs these offsets to serve save state reads on behalf
of Ring 3 code. The layout differs between Intel and AMD, so each vendor
map lives in its own file, intel.rs and amd.rs.Both maps are always compiled so each one is type checked and unit tested
in every build, including the --all-features build that CI uses for
clippy, coverage, and docs. The active map is chosen by the
save_state_intel and save_state_amd features. Intel is the default when
both features or neither feature is enabled.
patina: Add MemoryRange for checked address ranges
Add MemoryRange to the base module and export it, with MemoryRangeError,
from the crate root. A MemoryRange is a [base, base + size) range whose
size is never zero and whose end always fits in a u64. The constructors
(new, from_inclusive, from_pages and TryFrom for Rust ranges) return an
error instead of building a range that breaks these rules.Code that handles address ranges as (base, size) pairs repeats the same
overflow, overlap and containment checks, often with checked_add at each
call site. With these rules held by the type, a range that wraps the
address space or has no size cannot reach that code.The type provides containment, overlap, intersection, union, alignment
checks, extension and iteration by step. collapse returns the range that
covers a list of ranges, and coalesce does the same but fails when the
ranges leave a gap. find_overlap returns the first overlapping pair in a
list, and coverage reports whether a list covers a range fully, partly,
or not at all. MemoryRangeError converts to EfiError::InvalidParameter.
[feature/supv] patina_mm_supervisor: Add the MM supervisor core
Add patina_mm_supervisor, the Ring 0 half of the standalone MM core. It
runs on x86-64 and replaces the C MM supervisor in MmSupervisorPkg. The
entry shim starts at efi_main and jumps to rust_main, which the
platform binary supplies.The BSP performs the one time initialization and then serves incoming
MMI requests. It arms the syscall entry path and the call gate, builds
the page tables and the memory policy, programs the SMRRs to protect
MMRAM from accesses outside MM, and demotes execution to Ring 3 before
it calls the user core. APs wait in a holding pen and poll a mailbox
for work from the BSP.The crate does not allocate from a heap.
[feature/supv] patina_mm_supervisor: Add unit tests across the crate
Add unit tests that run on the host for most modules in the crate: HOB
validation, the page and paging allocators, the policy gate, the
syscall dispatcher, the call gate, the supervisor request handlers,
save state, SMRR, the mailbox and the semaphore. A new test_support
module holds the shared fixtures, and mm_policy gains a builder for
synthetic policy buffers.
[feature/supv] patina_mm_user_core: Add the MM user core
Add patina_mm_user_core, the Ring 3 half of the standalone MM core. It
performs the same work as the C StandaloneMmCore. It walks the HOB list
to find MM drivers, evaluates their dependency expressions, dispatches
them, and routes MMI requests to the registered handlers.The supervisor calls the entry point with one of three commands.
StartUserCore runs the one time setup and the first dispatch pass.
UserRequest parses a communication buffer and invokes the matching MMI
handler. UserApProcedure runs a procedure on behalf of an AP.The crate implements the MmServices trait from the SDK and publishes an
EfiMmSystemTable for C drivers. It keeps its own protocol database and
configuration table, and serves small allocations from a pool that
requests pages from the supervisor by syscall. Ring 3 has no direct
access to supervisor resources, so every privileged operation goes
through the syscall interface. A component dispatcher lets a platform
register native Patina components next to the C drivers.
[feature/supv] patina_mm_user_core: Improve unit test coverage
| Filename | Function Coverage | Line Coverage | Region Coverage | | --------------------------------------------------------------------------- | ----------------- | ----------------- | ----------------- | | patina_mm_user_core\src\component_dispatcher.rs | 100.00% (19/19) | 100.00% (83/83) | 95.80% (137/143) | | patina_mm_user_core\src\config_table.rs | 100.00% (7/7) | 100.00% (69/69) | 98.72% (77/78) | | patina_mm_user_core\src\core_handlers.rs | 100.00% (10/10) | 94.74% (90/95) | 92.04% (104/113) | | patina_mm_user_core\src\lib.rs | 100.00% (19/19) | 86.18% (187/217) | 85.25% (289/339) | | patina_mm_user_core\src\mm_dispatcher.rs | 100.00% (9/9) | 93.33% (140/150) | 89.26% (216/242) | | patina_mm_user_core\src\mm_mem.rs | 100.00% (8/8) | 100.00% (45/45) | 100.00% (68/68) | | patina_mm_user_core\src\mm_services.rs | 100.00% (34/34) | 99.47% (378/380) | 98.85% (431/436) | | patina_mm_user_core\src\mmi.rs | 100.00% (17/17) | 99.41% (169/170) | 96.40% (214/222) | | patina_mm_user_core\src\pool_allocator.rs | 100.00% (9/9) | 100.00% (90/90) | 99.38% (160/161) | | patina_mm_user_core\src\protocol_db.rs | 100.00% (29/29) | 100.00% (153/153) | 100.00% (248/248) |
[feature/supv] patina: component: Add a MM CPU component at mm user level
Add patina_mm_cpu, a component that produces the PI EFI_MM_CPU_PROTOCOL
inside the MM user core. The protocol lets MM drivers read the
architecture standard registers of a CPU save state, including the fields
that describe the I/O instruction that caused a software MMI.The save state lives in SMRAM that only the supervisor can read, so Ring
3 cannot reach it. ReadSaveState forwards each read to the supervisor
through the save state syscall, and the supervisor applies the save state
policy before it returns a value.This replaces the C MmSupervisedCpu driver in MmSupervisorPkg. A platform
registers the component through its MmComponentInfo implementation.
[feature/supv] docs: Add the MM supervisor and user core documentation
Add a Patina MM Subsystems part to the book. It explains how
patina_mm_supervisor and patina_mm_user_core work, from the first MMI to
the services that MM drivers call, so a reader can follow the design
without reading the code first.The part has eight pages:
- Theory and Operation: actors, cores and rings, the MMRAM map, the
trust model, the crate map and the global state of each core - Initialization and Initialization Validation: the first MMI on the
BSP and the APs, and every check made on what MM Init hands over - Privilege Boundary: demotion to Ring 3, the call gate, the syscalls,
failure handling and Ring 0 access to user pages - MMI Handling: the rendezvous, the communication buffers, supervisor
and user requests, and AP procedures - Memory Management: MMRAM and the SMRRs, the page allocator, the page
table, page ownership and unblocked memory - Security Policy: the policy blob, the runtime gate, the memory policy
and the boundary audit - User Core: the MM System Table, the protocol and MMI handler
databases, component and driver dispatch, and the save state
A new integration page, Patina MM Supervisor Requirements, lists what a
platform must provide: processor support, MMRAM layout, MM Init state,
HOBs, the security policy file, MM driver rules and the requests from
outside MM, followed by the known limitations. The figures are SVG files
in docs/src/media, drawn in one style with numbered steps. Every
statement was checked against the code.- Impacts functionality?
- Impacts security?
- Breaking change?
- Includes tests?
- Includes documentation?
How This Was Tested
Validated on internal hardware platforms.
Integration Instructions
Consumed in SEA repository to produce Supervisor, User Core, SEA rule sets and related binaries.
Note: Patina v24.4.1 is the last release before merging this PR.
- Theory and Operation: actors, cores and rings, the MMRAM map, the
Full Changelog: patina-v24.4.1...v24.5.0