vmm: Take PCI segment ID into BAR size allocation

Move the decision on whether to use a 64-bit bar up to the DeviceManager
so that it can use both the device type (e.g. block) and the PCI segment
ID to decide what size bar should be used.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2021-10-11 16:51:15 +01:00
parent cf1c2bf0e8
commit 88378d17a2
2 changed files with 11 additions and 11 deletions
+6
View File
@@ -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)?;