vfio: Add support for mmapping sub-page MMIO BARs

Enterprise / Virtualization / QEMU - Yongji Xie [linux.vnet.ibm.com] - 31 October 2016 10:53 UTC

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.

9525172 vfio: Add support for mmapping sub-page MMIO BARs
hw/vfio/common.c | 3 +--
hw/vfio/pci.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 2 deletions(-)

Upstream: git.qemu.org


  • Share