diff options
author | Alexey Kardashevskiy | 2018-03-13 18:17:31 +0100 |
---|---|---|
committer | Alex Williamson | 2018-03-13 18:17:31 +0100 |
commit | ae0215b2bb56a9d5321a185dde133bfdd306a4c0 (patch) | |
tree | f1c9b9a0e00f478aabaeb163dcf42e9c41a908f5 /hw/vfio/pci.c | |
parent | vfio/pci: Relax DMA map errors for MMIO regions (diff) | |
download | qemu-ae0215b2bb56a9d5321a185dde133bfdd306a4c0.tar.gz qemu-ae0215b2bb56a9d5321a185dde133bfdd306a4c0.tar.xz qemu-ae0215b2bb56a9d5321a185dde133bfdd306a4c0.zip |
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>
Diffstat (limited to 'hw/vfio/pci.c')
-rw-r--r-- | hw/vfio/pci.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index b9d2c12b82..02974f4eb9 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1295,6 +1295,15 @@ static void vfio_pci_fixup_msix_region(VFIOPCIDevice *vdev) VFIORegion *region = &vdev->bars[vdev->msix->table_bar].region; /* + * If the host driver allows mapping of a MSIX data, we are going to + * do map the entire BAR and emulate MSIX table on top of that. + */ + if (vfio_has_region_cap(&vdev->vbasedev, region->nr, + VFIO_REGION_INFO_CAP_MSIX_MAPPABLE)) { + return; + } + + /* * We expect to find a single mmap covering the whole BAR, anything else * means it's either unsupported or already setup. */ |