diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs index ed6d6a6fc..7da606ba7 100644 --- a/virtio-devices/src/transport/pci_device.rs +++ b/virtio-devices/src/transport/pci_device.rs @@ -350,6 +350,7 @@ impl VirtioPciDevice { interrupt_manager: &Arc>, pci_device_bdf: u32, activate_evt: EventFd, + use_64bit_bar: bool, ) -> Result { let device_clone = device.clone(); let locked_device = device_clone.lock().unwrap(); @@ -389,22 +390,15 @@ impl VirtioPciDevice { (None, None) }; - // All device types *except* virtio block devices should be allocated a 64-bit bar - // The block devices should be given a 32-bit BAR so that they are easily accessible - // to firmware without requiring excessive identity mapping. - let mut use_64bit_bar = true; let (class, subclass) = match VirtioDeviceType::from(locked_device.device_type()) { VirtioDeviceType::Net => ( PciClassCode::NetworkController, &PciNetworkControllerSubclass::EthernetController as &dyn PciSubclass, ), - VirtioDeviceType::Block => { - use_64bit_bar = false; - ( - PciClassCode::MassStorage, - &PciMassStorageSubclass::MassStorage as &dyn PciSubclass, - ) - } + VirtioDeviceType::Block => ( + PciClassCode::MassStorage, + &PciMassStorageSubclass::MassStorage as &dyn PciSubclass, + ), _ => ( PciClassCode::Other, &PciVirtioSubclass::NonTransitionalBase as &dyn PciSubclass, diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 4fdcb7ff3..0d053dad6 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -3236,6 +3236,7 @@ impl DeviceManager { }; let memory = self.memory_manager.lock().unwrap().guest_memory(); + let device_type = virtio_device.lock().unwrap().device_type(); let mut virtio_pci_device = VirtioPciDevice::new( id.clone(), memory, @@ -3247,6 +3248,11 @@ impl DeviceManager { self.activate_evt .try_clone() .map_err(DeviceManagerError::EventFd)?, + // All device types *except* virtio block devices should be allocated a 64-bit bar + // The block devices should be given a 32-bit BAR so that they are easily accessible + // to firmware without requiring excessive identity mapping. + // The exception being if not on the default PCI segment. + pci_segment_id > 0 || device_type != VirtioDeviceType::Block as u32, ) .map_err(DeviceManagerError::VirtioDevice)?;