mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 02:55:45 +00:00
pci, vmm: Pass PCI BDF to vfio and vfio_user
On AArch64, PCI BDF is used for devId in MSI-X routing entry. Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
parent
cf68f03ab6
commit
1db7718589
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
msi_num_enabled_vectors, BarReprogrammingParams, MsiConfig, MsixCap, MsixConfig,
|
msi_num_enabled_vectors, BarReprogrammingParams, MsiConfig, MsixCap, MsixConfig,
|
||||||
PciBarConfiguration, PciBarRegionType, PciCapabilityId, PciClassCode, PciConfiguration,
|
PciBarConfiguration, PciBarRegionType, PciBdf, PciCapabilityId, PciClassCode, PciConfiguration,
|
||||||
PciDevice, PciDeviceError, PciHeaderType, PciSubclass, MSIX_TABLE_ENTRY_SIZE,
|
PciDevice, PciDeviceError, PciHeaderType, PciSubclass, MSIX_TABLE_ENTRY_SIZE,
|
||||||
};
|
};
|
||||||
use byteorder::{ByteOrder, LittleEndian};
|
use byteorder::{ByteOrder, LittleEndian};
|
||||||
@ -557,6 +557,7 @@ impl VfioCommon {
|
|||||||
cap: u8,
|
cap: u8,
|
||||||
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
||||||
vfio_wrapper: &dyn Vfio,
|
vfio_wrapper: &dyn Vfio,
|
||||||
|
bdf: PciBdf,
|
||||||
) {
|
) {
|
||||||
let msg_ctl = vfio_wrapper.read_config_word((cap + 2).into());
|
let msg_ctl = vfio_wrapper.read_config_word((cap + 2).into());
|
||||||
|
|
||||||
@ -577,7 +578,11 @@ impl VfioCommon {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let msix_config = MsixConfig::new(msix_cap.table_size(), interrupt_source_group.clone(), 0);
|
let msix_config = MsixConfig::new(
|
||||||
|
msix_cap.table_size(),
|
||||||
|
interrupt_source_group.clone(),
|
||||||
|
bdf.into(),
|
||||||
|
);
|
||||||
|
|
||||||
self.interrupt.msix = Some(VfioMsix {
|
self.interrupt.msix = Some(VfioMsix {
|
||||||
bar: msix_config,
|
bar: msix_config,
|
||||||
@ -615,6 +620,7 @@ impl VfioCommon {
|
|||||||
&mut self,
|
&mut self,
|
||||||
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
||||||
vfio_wrapper: &dyn Vfio,
|
vfio_wrapper: &dyn Vfio,
|
||||||
|
bdf: PciBdf,
|
||||||
) {
|
) {
|
||||||
let mut cap_next = vfio_wrapper.read_config_byte(PCI_CONFIG_CAPABILITY_OFFSET);
|
let mut cap_next = vfio_wrapper.read_config_byte(PCI_CONFIG_CAPABILITY_OFFSET);
|
||||||
|
|
||||||
@ -636,7 +642,12 @@ impl VfioCommon {
|
|||||||
if irq_info.count > 0 {
|
if irq_info.count > 0 {
|
||||||
// Parse capability only if the VFIO device
|
// Parse capability only if the VFIO device
|
||||||
// supports MSI-X.
|
// supports MSI-X.
|
||||||
self.parse_msix_capabilities(cap_next, interrupt_manager, vfio_wrapper);
|
self.parse_msix_capabilities(
|
||||||
|
cap_next,
|
||||||
|
interrupt_manager,
|
||||||
|
vfio_wrapper,
|
||||||
|
bdf,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -968,6 +979,7 @@ impl VfioPciDevice {
|
|||||||
msi_interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
msi_interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
||||||
legacy_interrupt_group: Option<Arc<dyn InterruptSourceGroup>>,
|
legacy_interrupt_group: Option<Arc<dyn InterruptSourceGroup>>,
|
||||||
iommu_attached: bool,
|
iommu_attached: bool,
|
||||||
|
bdf: PciBdf,
|
||||||
) -> Result<Self, VfioPciError> {
|
) -> Result<Self, VfioPciError> {
|
||||||
let device = Arc::new(device);
|
let device = Arc::new(device);
|
||||||
device.reset();
|
device.reset();
|
||||||
@ -997,7 +1009,7 @@ impl VfioPciDevice {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
common.parse_capabilities(msi_interrupt_manager, &vfio_wrapper);
|
common.parse_capabilities(msi_interrupt_manager, &vfio_wrapper, bdf);
|
||||||
common.initialize_legacy_interrupt(legacy_interrupt_group, &vfio_wrapper)?;
|
common.initialize_legacy_interrupt(legacy_interrupt_group, &vfio_wrapper)?;
|
||||||
|
|
||||||
let vfio_pci_device = VfioPciDevice {
|
let vfio_pci_device = VfioPciDevice {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
use crate::vfio::{Interrupt, Vfio, VfioCommon, VfioError};
|
use crate::vfio::{Interrupt, Vfio, VfioCommon, VfioError};
|
||||||
use crate::{BarReprogrammingParams, PciBarRegionType, VfioPciError};
|
use crate::{BarReprogrammingParams, PciBarRegionType, VfioPciError};
|
||||||
use crate::{
|
use crate::{
|
||||||
PciClassCode, PciConfiguration, PciDevice, PciDeviceError, PciHeaderType, PciSubclass,
|
PciBdf, PciClassCode, PciConfiguration, PciDevice, PciDeviceError, PciHeaderType, PciSubclass,
|
||||||
};
|
};
|
||||||
use hypervisor::HypervisorVmError;
|
use hypervisor::HypervisorVmError;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
@ -67,6 +67,7 @@ impl VfioUserPciDevice {
|
|||||||
client: Arc<Mutex<Client>>,
|
client: Arc<Mutex<Client>>,
|
||||||
msi_interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
msi_interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
||||||
legacy_interrupt_group: Option<Arc<dyn InterruptSourceGroup>>,
|
legacy_interrupt_group: Option<Arc<dyn InterruptSourceGroup>>,
|
||||||
|
bdf: PciBdf,
|
||||||
) -> Result<Self, VfioUserPciDeviceError> {
|
) -> Result<Self, VfioUserPciDeviceError> {
|
||||||
// This is used for the BAR and capabilities only
|
// This is used for the BAR and capabilities only
|
||||||
let configuration = PciConfiguration::new(
|
let configuration = PciConfiguration::new(
|
||||||
@ -104,7 +105,7 @@ impl VfioUserPciDevice {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
common.parse_capabilities(msi_interrupt_manager, &vfio_wrapper);
|
common.parse_capabilities(msi_interrupt_manager, &vfio_wrapper, bdf);
|
||||||
common
|
common
|
||||||
.initialize_legacy_interrupt(legacy_interrupt_group, &vfio_wrapper)
|
.initialize_legacy_interrupt(legacy_interrupt_group, &vfio_wrapper)
|
||||||
.map_err(VfioUserPciDeviceError::InitializeLegacyInterrupts)?;
|
.map_err(VfioUserPciDeviceError::InitializeLegacyInterrupts)?;
|
||||||
|
@ -3025,6 +3025,7 @@ impl DeviceManager {
|
|||||||
&self.msi_interrupt_manager,
|
&self.msi_interrupt_manager,
|
||||||
legacy_interrupt_group,
|
legacy_interrupt_group,
|
||||||
device_cfg.iommu,
|
device_cfg.iommu,
|
||||||
|
pci_device_bdf,
|
||||||
)
|
)
|
||||||
.map_err(DeviceManagerError::VfioPciCreate)?;
|
.map_err(DeviceManagerError::VfioPciCreate)?;
|
||||||
|
|
||||||
@ -3171,6 +3172,7 @@ impl DeviceManager {
|
|||||||
client.clone(),
|
client.clone(),
|
||||||
&self.msi_interrupt_manager,
|
&self.msi_interrupt_manager,
|
||||||
legacy_interrupt_group,
|
legacy_interrupt_group,
|
||||||
|
pci_device_bdf,
|
||||||
)
|
)
|
||||||
.map_err(DeviceManagerError::VfioUserCreate)?;
|
.map_err(DeviceManagerError::VfioUserCreate)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user