vfio/pci: Relax DMA map errors for MMIO regions
commit567b5b309abe744b1098018a2eb157e7109c9f30
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Tue, 13 Mar 2018 17:17:30 +0000 (13 11:17 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 13 Mar 2018 17:17:30 +0000 (13 11:17 -0600)
treefc07cc15198fb1c7e242867c18e35e97f8b12f63
parent8b818e059bf071749f96fa4a10934eb533777f9a
vfio/pci: Relax DMA map errors for MMIO regions

At the moment if vfio_memory_listener is registered in the system memory
address space, it maps/unmaps every RAM memory region for DMA.
It expects system page size aligned memory sections so vfio_dma_map
would not fail and so far this has been the case. A mapping failure
would be fatal. A side effect of such behavior is that some MMIO pages
would not be mapped silently.

However we are going to change MSIX BAR handling so we will end having
non-aligned sections in vfio_memory_listener (more details is in
the next patch) and vfio_dma_map will exit QEMU.

In order to avoid fatal failures on what previously was not a failure and
was just silently ignored, this checks the section alignment to
the smallest supported IOMMU page size and prints an error if not aligned;
it also prints an error if vfio_dma_map failed despite the page size check.
Both errors are not fatal; only MMIO RAM regions are checked
(aka "RAM device" regions).

If the amount of errors printed is overwhelming, the MSIX relocation
could be used to avoid excessive error output.

This is unlikely to cause any behavioral change.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[aw: Fix Int128 bit ops]
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio/common.c