vfio-pci: Allow mmap of MSIX BAR
commitae0215b2bb56a9d5321a185dde133bfdd306a4c0
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Tue, 13 Mar 2018 17:17:31 +0000 (13 11:17 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 13 Mar 2018 17:17:31 +0000 (13 11:17 -0600)
treef1c9b9a0e00f478aabaeb163dcf42e9c41a908f5
parent567b5b309abe744b1098018a2eb157e7109c9f30
vfio-pci: Allow mmap of MSIX BAR

At the moment we unconditionally avoid mapping MSIX data of a BAR and
emulate MSIX table in QEMU. However it is 1) not always necessary as
a platform may provide a paravirt interface for MSIX configuration;
2) can affect the speed of MMIO access by emulating them in QEMU when
frequently accessed registers share same system page with MSIX data,
this is particularly a problem for systems with the page size bigger
than 4KB.

A new capability - VFIO_REGION_INFO_CAP_MSIX_MAPPABLE - has been added
to the kernel [1] which tells the userspace that mapping of the MSIX data
is possible now. This makes use of it so from now on QEMU tries mapping
the entire BAR as a whole and emulate MSIX on top of that.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a32295c612c57990d17fb0f41e7134394b2f35f6

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio/common.c
hw/vfio/pci.c
include/hw/vfio/vfio-common.h