Skip to content

Commit 80aa1de

Browse files
committed
pci: add unit tests for MSI-X code
Also, drop some of effectively dead code that Cloud Hypervisor was using because they were not relying on KVM to handle interrupt controllers. Finally, fixup some error cases on guest reads which need to return all-ones when bad accesses happen. Signed-off-by: Babis Chalios <[email protected]>
1 parent 8d2fa9d commit 80aa1de

File tree

6 files changed

+417
-90
lines changed

6 files changed

+417
-90
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pci/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ vm-memory = { version = "0.16.1", features = [
2727

2828
[dev-dependencies]
2929
serde_test = "1.0.177"
30+
vmm-sys-util = "0.14.0"

src/pci/src/configuration.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,11 +843,14 @@ impl PciConfiguration {
843843
if let Some(msix_cap_reg_idx) = self.msix_cap_reg_idx {
844844
if let Some(msix_config) = &self.msix_config {
845845
if msix_cap_reg_idx == reg_idx && offset == 2 && data.len() == 2 {
846+
// 2-bytes write in the Message Control field
846847
msix_config
847848
.lock()
848849
.unwrap()
849850
.set_msg_ctl(LittleEndian::read_u16(data));
850851
} else if msix_cap_reg_idx == reg_idx && offset == 0 && data.len() == 4 {
852+
// 4 bytes write at the beginning. Ignore the first 2 bytes which are the
853+
// capability id and next capability pointer
851854
msix_config
852855
.lock()
853856
.unwrap()

src/pci/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ pub use self::configuration::{
3030
pub use self::device::{
3131
BarReprogrammingParams, DeviceRelocation, Error as PciDeviceError, PciDevice,
3232
};
33-
pub use self::msix::{
34-
Error as MsixError, MsixCap, MsixConfig, MsixConfigState, MsixTableEntry, MSIX_CONFIG_ID,
35-
MSIX_TABLE_ENTRY_SIZE,
36-
};
33+
pub use self::msix::{Error as MsixError, MsixCap, MsixConfig, MsixConfigState, MsixTableEntry};
3734

3835
/// PCI has four interrupt pins A->D.
3936
#[derive(Copy, Clone)]

0 commit comments

Comments
 (0)