diff --git a/arch/src/aarch64/layout.rs b/arch/src/aarch64/layout.rs index b464b592e..ab71381ab 100644 --- a/arch/src/aarch64/layout.rs +++ b/arch/src/aarch64/layout.rs @@ -82,6 +82,8 @@ pub const MEM_32BIT_DEVICES_SIZE: u64 = 0x2000_0000; /// PCI MMCONFIG space (start: after the device space at 1 GiB, length: 256MiB) pub const PCI_MMCONFIG_START: GuestAddress = GuestAddress(0x3000_0000); pub const PCI_MMCONFIG_SIZE: u64 = 256 << 20; +// One bus with potentially 256 devices (32 slots x 8 functions). +pub const PCI_MMIO_CONFIG_SIZE_PER_SEGMENT: u64 = 4096 * 256; /// Start of RAM on 64 bit ARM. pub const RAM_64BIT_START: u64 = 0x4000_0000; diff --git a/arch/src/x86_64/layout.rs b/arch/src/x86_64/layout.rs index bda64ae21..929387875 100644 --- a/arch/src/x86_64/layout.rs +++ b/arch/src/x86_64/layout.rs @@ -93,6 +93,8 @@ pub const MEM_32BIT_DEVICES_SIZE: u64 = 640 << 20; pub const PCI_MMCONFIG_START: GuestAddress = GuestAddress(MEM_32BIT_DEVICES_START.0 + MEM_32BIT_DEVICES_SIZE); pub const PCI_MMCONFIG_SIZE: u64 = 256 << 20; +// One bus with potentially 256 devices (32 slots x 8 functions). +pub const PCI_MMIO_CONFIG_SIZE_PER_SEGMENT: u64 = 4096 * 256; // TSS is 3 pages after the PCI MMCONFIG space pub const KVM_TSS_START: GuestAddress = GuestAddress(PCI_MMCONFIG_START.0 + PCI_MMCONFIG_SIZE); diff --git a/vmm/src/pci_segment.rs b/vmm/src/pci_segment.rs index 4633542aa..1e759cbb7 100644 --- a/vmm/src/pci_segment.rs +++ b/vmm/src/pci_segment.rs @@ -22,9 +22,6 @@ use uuid::Uuid; use vm_allocator::AddressAllocator; use vm_device::BusDevice; -// One bus with potentially 256 devices (32 slots x 8 functions). -const PCI_MMIO_CONFIG_SIZE: u64 = 4096 * 256; - pub(crate) struct PciSegment { pub(crate) id: u16, pub(crate) pci_bus: Arc>, @@ -62,14 +59,15 @@ impl PciSegment { ))); let pci_config_mmio = Arc::new(Mutex::new(PciConfigMmio::new(Arc::clone(&pci_bus)))); - let mmio_config_address = layout::PCI_MMCONFIG_START.0 + PCI_MMIO_CONFIG_SIZE * id as u64; + let mmio_config_address = + layout::PCI_MMCONFIG_START.0 + layout::PCI_MMIO_CONFIG_SIZE_PER_SEGMENT * id as u64; address_manager .mmio_bus .insert( Arc::clone(&pci_config_mmio) as Arc>, mmio_config_address, - PCI_MMIO_CONFIG_SIZE, + layout::PCI_MMIO_CONFIG_SIZE_PER_SEGMENT, ) .map_err(DeviceManagerError::BusError)?; @@ -363,7 +361,7 @@ impl Aml for PciSegment { &aml::Memory32Fixed::new( true, self.mmio_config_address as u32, - PCI_MMIO_CONFIG_SIZE as u32, + layout::PCI_MMIO_CONFIG_SIZE_PER_SEGMENT as u32, ), &aml::AddressSpace::new_memory( aml::AddressSpaceCachable::NotCacheable, @@ -392,7 +390,7 @@ impl Aml for PciSegment { &aml::Memory32Fixed::new( true, self.mmio_config_address as u32, - PCI_MMIO_CONFIG_SIZE as u32, + layout::PCI_MMIO_CONFIG_SIZE_PER_SEGMENT as u32, ), &aml::AddressSpace::new_memory( aml::AddressSpaceCachable::NotCacheable,