vfio: Add support for mmapping sub-page MMIO BARs
authorYongji Xie <xyjxie@linux.vnet.ibm.com>
Mon, 31 Oct 2016 15:53:04 +0000 (09:53 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Mon, 31 Oct 2016 15:53:04 +0000 (09:53 -0600)
commit95251725e335af2b885e2ab33dd29c86f8084663
tree03cc9d5501f66c63cb3c9ddf31cc2ee18a6c4baa
parenta52a4c471703e995ceb06f6157d70747823e8a0d
vfio: Add support for mmapping sub-page MMIO BARs

Now the kernel commit 05f0c03fbac1 ("vfio-pci: Allow to mmap
sub-page MMIO BARs if the mmio page is exclusive") allows VFIO
to mmap sub-page BARs. This is the corresponding QEMU patch.
With those patches applied, we could passthrough sub-page BARs
to guest, which can help to improve IO performance for some devices.

In this patch, we expand MemoryRegions of these sub-page
MMIO BARs to PAGE_SIZE in vfio_pci_write_config(), so that
the BARs could be passed to KVM ioctl KVM_SET_USER_MEMORY_REGION
with a valid size. The expanding size will be recovered when
the base address of sub-page BAR is changed and not page aligned
any more in guest. And we also set the priority of these BARs'
memory regions to zero in case of overlap with BARs which share
the same page with sub-page BARs in guest.

Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio/common.c
hw/vfio/pci.c