kvm tools: Don't use 64bit BARs
PATCH 1/2 kvm tools: Don't use 64bit BARs
We don't really support that, so no point in using 64bit BARs.
Signed-off-by Sasha Levin <[email protected]>
--- tools/kvm/virtio/pci.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
tools/kvm/virtio/pci.c +4 -4
@@ -307,10 +307,10 @@ int virtio_pci__init(struct kvm *kvm, struct virtio_trans *vtrans, void *dev, .subsys_vendor_id = cpu_to_le16(PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET), .subsys_id = cpu_to_le16(subsys_id), .bar[0] = cpu_to_le32(vpci->base_addr | PCI_BASE_ADDRESS_SPACE_IO), - .bar[1 ] =cpu_to_le32 (vpci->msix_io_block |PCI_BASE_ADDRESS_SPACE_MEMORY - | PCI_BASE_ADDRESS_MEM_TYPE_64), - .bar[3 ] =cpu_to_le32 (vpci->msix_pba_block |PCI_BASE_ADDRESS_SPACE_MEMORY - | PCI_BASE_ADDRESS_MEM_TYPE_64), + .bar[1 ] =cpu_to_le32 (vpci->msix_io_block + | PCI_BASE_ADDRESS_SPACE_MEMORY), + .bar[3 ] =cpu_to_le32 (vpci->msix_pba_block + | PCI_BASE_ADDRESS_SPACE_MEMORY), .status = cpu_to_le16(PCI_STATUS_CAP_LIST), .capabilities = (void *)&vpci->pci_hdr.msix - (void *)&vpci->pci_hdr, .bar_size[0] = IOPORT_SIZE,
Signature · 1 line
1.7.8
PATCH 2/2 kvm tools: Free up the MSI-X PBA BAR
Free up the BAR to make space for the new virtio BARs. It isn't required to have the PBA and the table in the separate BARs, and uniting them will just give us extra BARs to play with.
Signed-off-by Sasha Levin <[email protected]>
--- tools/kvm/include/kvm/virtio-pci.h | 1 - tools/kvm/virtio/pci.c | 35 +++++++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-)
tools/kvm/include/kvm/virtio-pci.h +0 -1
@@ -30,7 +30,6 @@ struct virtio_pci {u32 vq_vector[VIRTIO_PCI_MAX_VQ ];u32 gsis[VIRTIO_PCI_MAX_VQ ];u32 msix_io_block; -u32 msix_pba_block;u64 msix_pba;struct msix_table msix_table[VIRTIO_PCI_MAX_VQ +VIRTIO_PCI_MAX_CONFIG ];
tools/kvm/virtio/pci.c +15 -20
@@ -220,23 +220,21 @@ static struct ioport_operations virtio_pci__io_ops = {static void callback_mmio_table (u64 addr,u8 *data,u32 len,u8 is_write,void *ptr) {struct virtio_pci *vpci = ptr; -void *table = &vpci->msix_table; +void *table; +u32 offset; -if (is_write) -memcpy (table + addr - vpci->msix_io_block, data, len); -else -memcpy (data, table + addr - vpci->msix_io_block, len); -} - -static void callback_mmio_pba (u64 addr,u8 *data,u32 len,u8 is_write,void *ptr) -{ -struct virtio_pci *vpci = ptr; -void *pba = &vpci->msix_pba; +if (addr > vpci->msix_io_block +PCI_IO_SIZE ) { + table = &vpci->msix_pba; + offset = vpci->msix_io_block +PCI_IO_SIZE ; + }else { + table = &vpci->msix_table; + offset = vpci->msix_io_block; + }if (is_write) -memcpy (pba + addr - vpci->msix_pba_block, data, len); +memcpy (table + addr - offset, data, len);else -memcpy (data, pba + addr - vpci->msix_pba_block, len); +memcpy (data, table + addr - offset, len); }int virtio_pci__signal_vq (struct kvm *kvm,struct virtio_trans *vtrans,u32 vq)
@@ -289,12 +287,10 @@ int virtio_pci__init(struct kvm *kvm, struct virtio_trans *vtrans, void *dev,u8 pin, line, ndev; vpci->dev = dev; - vpci->msix_io_block =pci_get_io_space_block (PCI_IO_SIZE ); - vpci->msix_pba_block =pci_get_io_space_block (PCI_IO_SIZE ); + vpci->msix_io_block =pci_get_io_space_block (PCI_IO_SIZE *2 ); vpci->base_addr =ioport__register (IOPORT_EMPTY , &virtio_pci__io_ops,IOPORT_SIZE , vtrans);kvm__register_mmio (kvm, vpci->msix_io_block,PCI_IO_SIZE , callback_mmio_table, vpci); -kvm__register_mmio (kvm, vpci->msix_pba_block,PCI_IO_SIZE , callback_mmio_pba, vpci); vpci->pci_hdr = (struct pci_device_header ) { .vendor_id =cpu_to_le16 (PCI_VENDOR_ID_REDHAT_QUMRANET ),
@@ -306,11 +302,10 @@ int virtio_pci__init(struct kvm *kvm, struct virtio_trans *vtrans, void *dev, .class[2] = (class >> 16) & 0xff, .subsys_vendor_id = cpu_to_le16(PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET), .subsys_id = cpu_to_le16(subsys_id), - .bar[0] = cpu_to_le32(vpci->base_addr | PCI_BASE_ADDRESS_SPACE_IO), + .bar[0 ] =cpu_to_le32 (vpci->base_addr + | PCI_BASE_ADDRESS_SPACE_IO), .bar[1 ] =cpu_to_le32 (vpci->msix_io_block | PCI_BASE_ADDRESS_SPACE_MEMORY), - .bar[3 ] =cpu_to_le32 (vpci->msix_pba_block - | PCI_BASE_ADDRESS_SPACE_MEMORY), .status = cpu_to_le16(PCI_STATUS_CAP_LIST), .capabilities = (void *)&vpci->pci_hdr.msix - (void *)&vpci->pci_hdr, .bar_size[0] = IOPORT_SIZE,
@@ -338,7 +333,7 @@ int virtio_pci__init(struct kvm *kvm, struct virtio_trans *vtrans, void *dev,* we're not in short of BARs */ vpci->pci_hdr.msix.table_offset =cpu_to_le32 (1 );/* Use BAR 1 */ - vpci->pci_hdr.msix.pba_offset =cpu_to_le32 (3 );/* Use BAR 3 */ + vpci->pci_hdr.msix.pba_offset =cpu_to_le32 (1 |PCI_IO_SIZE );/* Use BAR 3 */ vpci->config_vector =0 ;if (irq__register_device (subsys_id, &ndev, &pin, &line) <0 )
Signature · 1 line
1.7.8