devices: vfio: use separate MSI and MSI-X sockets
Previously, the VFIO code was using a single IRQ VM control socket
within an Arc<> container for both MSI and MSI-X; however, MsgSocket is
not technically Sync. In order to remove the Sync trait from MsgSocket,
split the MSI and MSI-X uses into two separate sockets and remove the
Arc wrapper.
BUG=None
TEST=./build_test
Change-Id: Ib620521be3d02bc9b66c1cc771c34feb8622993c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2436399
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
diff --git a/devices/src/pci/msix.rs b/devices/src/pci/msix.rs
index 5766f2e..3cfb95a 100644
--- a/devices/src/pci/msix.rs
+++ b/devices/src/pci/msix.rs
@@ -8,7 +8,6 @@
use std::convert::TryInto;
use std::fmt::{self, Display};
use std::os::unix::io::{AsRawFd, RawFd};
-use std::sync::Arc;
use vm_control::{MaybeOwnedFd, VmIrqRequest, VmIrqRequestSocket, VmIrqResponse};
use data_model::DataInit;
@@ -57,7 +56,7 @@
irq_vec: Vec<IrqfdGsi>,
masked: bool,
enabled: bool,
- msi_device_socket: Arc<VmIrqRequestSocket>,
+ msi_device_socket: VmIrqRequestSocket,
msix_num: u16,
}
@@ -96,7 +95,7 @@
}
impl MsixConfig {
- pub fn new(msix_vectors: u16, vm_socket: Arc<VmIrqRequestSocket>) -> Self {
+ pub fn new(msix_vectors: u16, vm_socket: VmIrqRequestSocket) -> Self {
assert!(msix_vectors <= MAX_MSIX_VECTORS_PER_DEVICE);
let mut table_entries: Vec<MsixTableEntry> = Vec::new();
@@ -515,6 +514,12 @@
}
}
+impl AsRawFd for MsixConfig {
+ fn as_raw_fd(&self) -> RawFd {
+ self.msi_device_socket.as_raw_fd()
+ }
+}
+
// It is safe to implement DataInit; all members are simple numbers and any value is valid.
unsafe impl DataInit for MsixCap {}