-
Notifications
You must be signed in to change notification settings - Fork 161
acpi_spec: add MCFG definitions and parsing #1985
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
acpi_spec: add MCFG definitions and parsing #1985
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds MCFG (Memory Mapped Configuration) table definitions and parsing to the acpi_spec crate. The MCFG table describes memory-mapped configuration space base addresses for PCIe root complex devices, enabling Enhanced Configuration Access Mechanism (ECAM) support.
Key changes:
- Adds complete MCFG table structure definitions with proper zerocopy traits
- Implements parsing functionality with comprehensive error handling
- Provides both borrowed and owned parsing variants for different use cases
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| vm/acpi_spec/src/mcfg.rs | New module implementing MCFG table structures, parsing logic, and error handling |
| vm/acpi_spec/src/lib.rs | Exports the new mcfg module |
| pub struct McfgSegmentBusRange { | ||
| pub ecam_base: u64_ne, | ||
| pub segment: u16_ne, | ||
| pub start_bus: u8, | ||
| pub end_bus: u8, | ||
| pub rsvd: u32_ne, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a bitfield(u128), and then you're guaranteed that the size will be correct.
In general, I prefer bitfields for structures that are up to 128 bits in length that need to match some hardware spec. That is perhaps stylistic without any real basis. Interested what you / others think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I think using a bitfield to represent a structure where all members are on byte boundaries is confusing, so I would lean towards keeping it as-is with the const assert. However, I am still in the process of refining my personal stylistic preferences in Rust
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my rule of thumb is generally to use bitfields if there are actual bit fields, but if all members are standard integers then it's not usually something I use. I don't think we codify that anywhere, but regardless as long as you assert the size correctly I don't think either approach is wrong.
This change adds currently unused MCFG definitions and parsing to the `acpi_spec` crate. The MCFG table describes the memory-mapped configuration space base address for each PCIe root complex device on a system. Future changes will actually utilize these MCFG definitions to expose enhanced configuration access mechanism (ECAM) addresses to guests. See microsoft#1976 for a preview.
This change adds currently unused MCFG definitions and parsing to the
acpi_speccrate. The MCFG table describes the memory-mapped configuration space base address for each PCIe root complex device on a system.Future changes will actually utilize these MCFG definitions to expose enhanced configuration access mechanism (ECAM) addresses to guests. See #1976 for a preview.