vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2)
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 4 Jul 2016 03:33:04 +0000 (13:33 +1000)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 5 Jul 2016 04:30:54 +0000 (14:30 +1000)
commit318f67ce13710a09c6dcf34da7b6b0ebc845c5c9
treeb2d5db8b41b139f4bbc1f5a40cc7a39f934e8528
parent606b54986df4e3964eee2d74460bd06ed2f384e5
vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2)

This makes use of the new "memory registering" feature. The idea is
to provide the userspace ability to notify the host kernel about pages
which are going to be used for DMA. Having this information, the host
kernel can pin them all once per user process, do locked pages
accounting (once) and not spent time on doing that in real time with
possible failures which cannot be handled nicely in some cases.

This adds a prereg memory listener which listens on address_space_memory
and notifies a VFIO container about memory which needs to be
pinned/unpinned. VFIO MMIO regions (i.e. "skip dump" regions) are skipped.

The feature is only enabled for SPAPR IOMMU v2. The host kernel changes
are required. Since v2 does not need/support VFIO_IOMMU_ENABLE, this does
not call it when v2 is detected and enabled.

This enforces guest RAM blocks to be host page size aligned; however
this is not new as KVM already requires memory slots to be host page
size aligned.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[dwg: Fix compile error on 32-bit host]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/vfio/Makefile.objs
hw/vfio/common.c
hw/vfio/spapr.c [new file with mode: 0644]
hw/vfio/trace-events
include/hw/vfio/vfio-common.h