-
Notifications
You must be signed in to change notification settings - Fork 41
Refactor Patina Perf MM Code and Use the MM Comm Service [Rebase & FF] #746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Patina Perf MM Code and Use the MM Comm Service [Rebase & FF] #746
Conversation
016d9b8 to
ed1f66c
Compare
8929318 to
71fd25d
Compare
71fd25d to
ad64aa1
Compare
|
I'm holding merging of this PR until a few others go in that this one will build on top of. Currently blocked on microsoft/mu_feature_mm_supv#541 for compat with MM Supervisor Standalone MM. |
Marking the PR as draft until that is done. Then, I'll rebase and update the PR as needed. |
ad64aa1 to
56da443
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
56da443 to
2876f01
Compare
2876f01 to
e8d8285
Compare
e8d8285 to
c22a615
Compare
|
@joschock, @Javagedes, @os-d, @magravel, @berlin-with0ut-return, this PR is now updated to work with the MM Supervisor, taking advantage of a new protocol that updates the comm buffer protocol during boot. That change in particular is made in ef054ea. The new commits since the last review period are: |
|
Can you please take a look through the current PR? I'll complete the PR after getting two approvals on the latest changes. |
c22a615 to
a784dd4
Compare
|
If anyone would like to review, please comment in the next hour or so, otherwise I'll rebase and merge it. |
@os-d reached out about taking a look. The PR will stay open. |
components/patina_mm/src/component/communicator/comm_buffer_update.rs
Outdated
Show resolved
Hide resolved
`zerocopy_dervice` does not need to be explicitly used. Duplicate symbols are now being reported with the latest build using nightly. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Add patina_mm dependency to workspace and performance component to enable MM communication. Replace scroll with zerocopy for improved serialization performance and reduced dependency weight. Key changes: - Add patina_mm dependency to workspace Cargo.toml - Add patina_mm and zerocopy dependencies to performance component - Remove scroll dependency in favor of zerocopy for serialization - Add zerocopy with derive features to SDK This establishes the foundation for modernizing MM communication in the performance component by replacing HOB-based communication with a service-based approach. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Add a dedicated MM communication module for performance related MM definitions and functionality such as record fetching. - SmmCommHeader is zerocopy wire format compatible - Adds GetRecordSize for querying total performance record size - Adds GetRecordDataByOffset for chunked record retrieval wit configurable buffer sizes Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
- Adds the PerformanceRecordHeader struct to represent and manage performance record headers. - Replaces scroll::Error with Error::Serialization so scroll errror types are not leaking into performance code. - Implement direct little-endian serialization helpers for certain primitives - Favors zerocopy instead of scroll in relevant places. - Adds improved bounds checking for serialization operations. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Enhance `PerfConfig` with explicit default values and improved documentation to provide clearer configuration semantics. - Add explicit `DEFAULT_ENABLE_COMPONENT` and `DEFAULT_ENABLED_MEASUREMENTS` constants - Implement custom `Default` trait instead of derive to better control defaults - Improve documentation - Improve `PerfConfig` usage ergonomics Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Drop HOB-based MM comm buffers and the Communicate protocol being used in the performance component to instead use the Communicate service. Implements more robust error handling, general code cleanup, and additional tests. - Uses the `MmCommunication` service - Adds better error handling using the `MmPerformanceError` enum - Implements chunked MM record fetching with configurable buffer sizes - Adds `PerformanceRecordIterator` for more memory-efficient perf record processing - Adds unit tests covering different scenarios such as zero records, single record, and multi-chunk scenarios - Mocks the `MmCommunication` service implementations to better isolate testing Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Remove protocol-based MM communication in the patina_sdk perf code and clean up the `event_callback` namespace. - Remove Vec import as it's no longer needed for temporary buffers - Remove fetch_and_add_mm_performance_records from event_callback module - Clean up unused imports and simplify module dependencies Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Remove the temporary _smm module that provided scroll-based MM communication. The new MM communication approach in the mm.rs module provides the same functionality with improved error handling, better resource management, and integration with the Patina service architecture. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Adds structures that represent performance records so they can be parsed and printed in debug messages. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Implements the MM communication buffer update protocol to support` dynamic updates to MM communication buffers during boot. This is an option that can be enabled in the MM Comm buffer config. The protocol is currently published the Mu MM Supervisor Standalone MM implementation. High-level changes: - Add support for the MmCommBufferUpdate protocol - Update the patina_mm component to support MM Comm buffer updates - Update patina_mm config to support MM Comm buffer updates - Integration with SW MMI manager for buffer update handling - Component integration tests for buffer update functionality An example of a pending MM Communication buffer being applied when the perf component triggers a SW MMI: ``` DEBUG - Starting MM communication: buffer_id=1, data_size=40, recipient=C095791A-3001-47B2-80C9-EAC7319F2FA4 INFO - Pending buffer update detected, applying now INFO - Adding new comm buffer 1: addr=0x7ddd9000, size=0x10000 INFO - Successfully applied pending comm buffer 1 update TRACE - patina_mm\src\component\communicator.rs:466: Buffer validation: buffer_len=65536, required_len=64 TRACE - patina_mm\src\component\communicator.rs:473: Resetting the comm buffer and internal tracking state TRACE - patina_mm\src\component\communicator.rs:476: Setting up communication buffer for MM request TRACE - patina_mm\src\config.rs:569: Setting message info for buffer 1: recipient=C095791A-3001-47B2-80C9-EAC7319F2FA4 TRACE - patina_mm\src\config.rs:540: Validating capacity for buffer 1: buffer_size=65536, message_size=0 TRACE - patina_mm\src\config.rs:558: Buffer 1 capacity validation passed TRACE - patina_mm\src\config.rs:527: Buffer 1 state consistency was verified successfully TRACE - patina_mm\src\config.rs:586: Message info set successfully for buffer 1 TRACE - patina_mm\src\config.rs:598: Setting message for buffer 1: message_size=40 TRACE - patina_mm\src\config.rs:540: Validating capacity for buffer 1: buffer_size=65536, message_size=40 TRACE - patina_mm\src\config.rs:558: Buffer 1 capacity validation passed TRACE - patina_mm\src\config.rs:610: Buffer 1: writing header and message data TRACE - patina_mm\src\config.rs:527: Buffer 1 state consistency was verified successfully DEBUG - Buffer 1 message set successfully: header_size=24, message_size=40 DEBUG - Outgoing MM communication request: buffer_id=1, data_size=40, recipient=C095791A-3001-47B2-80C9-EAC7319F2FA4 DEBUG - Request Data (hex): [01, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00] TRACE - patina_mm\src\component\communicator.rs:488: Comm buffer before request: CommunicateBuffer(id: 0x1. len: 0x10000) . . . ``` Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Coverage for: - Debug output - Default trait implementation - Using an MM executor Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Prints additional information about MM performance records retrieved, including record-specific information. That allows better visibility into the records themselves and MM communication between the Patina Performance component the MM performance code. An example of two MM performance records received from the MM UEFI variable driver: ``` DEBUG - MM communication response received: size=156 INFO - Performance: Processing 116 bytes of MM performance data DEBUG - Performance: MM record #1 - type: 0x1011 (Dynamic String Event), length: 58, revision: 1, data_len: 54 DEBUG - Record #1: progress_id: 0x0030, apic_id: 0, timestamp: 4105960673, guid: 7EE2C0C1-C21A-4113-A53A-66824A95696F DEBUG - String: "MmVariableServiceInitia" DEBUG - Performance: MM record #2 - type: 0x1011 (Dynamic String Event), length: 58, revision: 1, data_len: 54 DEBUG - Record #2: progress_id: 0x0031, apic_id: 0, timestamp: 4157443753, guid: 7EE2C0C1-C21A-4113-A53A-66824A95696F DEBUG - String: "MmVariableServiceInitia" INFO - Performance: MM record summary - total: 2, added: 2, failed: 0 ``` Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
a784dd4 to
2f0c6ea
Compare
Description
Closes #444
Refactors performance code interacting with MM to be more ergonomic and use the MM Communication service (instead of the MM Communication protocol). Use zerocopy in some places to reduce overhead from scroll. General other improvements for error handling and adding more testing.
perf: Update dependencies for MM communication support
Add patina_mm dependency to workspace and performance component to
enable MM communication. Replace scroll with zerocopy for improved
serialization performance and reduced dependency weight.
This establishes the foundation for modernizing MM communication in the
performance component by replacing HOB-based communication with a
service-based approach.
patina_performance: Add MM module
Add a dedicated MM communication module for performance related
MM definitions and functionality such as record fetching.
configurable buffer sizes
patina_sdk/performance: Improve perf record serialization infra
performance record headers.
types are not leaking into performance code.
primitives
patina_performance: Update configuration with explicit defaults
Enhance
PerfConfigwith explicit default values and improveddocumentation to provide clearer configuration semantics.
DEFAULT_ENABLE_COMPONENTandDEFAULT_ENABLED_MEASUREMENTSconstantsDefaulttrait instead of derive to bettercontrol defaults
PerfConfigusage ergonomicspatina_performance: Use the MM Communication service
Drop HOB-based MM comm buffers and the Communicate protocol being
used in the performance component to instead use the Communicate
service.
Implements more robust error handling, general code cleanup, and
additional tests.
Uses the
MmCommunicationserviceAdds better error handling using the
MmPerformanceErrorenumImplements chunked MM record fetching with configurable buffer
sizes
Adds
PerformanceRecordIteratorfor more memory-efficient perfrecord processing
Adds unit tests covering different scenarios such as zero records,
single record, and multi-chunk scenarios
Mocks the
MmCommunicationservice implementations to betterisolate testing
patina_sdk: Refactor perf measurement module to drop MM comm protocol
Remove protocol-based MM communication in the patina_sdk perf code
and clean up the
event_callbacknamespace.module
patina_sdk/performance: Remove temp SMM module
Remove the temporary _smm module that provided scroll-based MM
communication.
The new MM communication approach in the mm.rs module provides
the same functionality with improved error handling, better
resource management, and integration with the Patina service
architecture.
patina_performance: Add records module
Adds structures that represent performance records so they can
be parsed and printed in debug messages.
patina_mm: Add MM communication buffer update protocol
Implements the MM communication buffer update protocol to support`
dynamic updates to MM communication buffers during boot. This is
an option that can be enabled in the MM Comm buffer config. The
protocol is currently published the Mu MM Supervisor Standalone MM
implementation.
High-level changes:
An example of a pending MM Communication buffer being applied when
the perf component triggers a SW MMI:
Add additional MM Communicator unit tests
Coverage for:
Improve MM perf record debuggability
Prints additional information about MM performance records retrieved,
including record-specific information. That allows better visibility
into the records themselves and MM communication between the Patina
Performance component the MM performance code.
An example of two MM performance records received from the MM UEFI
variable driver:
How This Was Tested
cargo make allPERF_TRACE_ENABLEIntegration Instructions
Update performance configuration to include the following fields:
If the MM Communication Buffer Update protocol is installed on the platform (protocol with GUID
2a22e38f-9d1c-49d0-bdce-7ddac16da45d), then use the following configration:Where
updatable_buffer_idis the ID of the comm buffer that should be updated with the information in the protocol.