aboutsummaryrefslogtreecommitdiff
path: root/hw/vfio/ccw.c
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2018-08-17 09:27:16 -0600
committerAlex Williamson <alex.williamson@redhat.com>2018-08-17 09:27:16 -0600
commit238e91728503d400e1c4e644e3a9b80f9e621682 (patch)
treeab1e426f7787fc7ea16e1556c737d27a01afac6f /hw/vfio/ccw.c
parentc65ee433153b5925e183a00ebf568e160077c694 (diff)
downloadqemu-238e91728503d400e1c4e644e3a9b80f9e621682.zip
qemu-238e91728503d400e1c4e644e3a9b80f9e621682.tar.gz
qemu-238e91728503d400e1c4e644e3a9b80f9e621682.tar.bz2
vfio/ccw/pci: Allow devices to opt-in for ballooning
If a vfio assigned device makes use of a physical IOMMU, then memory ballooning is necessarily inhibited due to the page pinning, lack of page level granularity at the IOMMU, and sufficient notifiers to both remove the page on balloon inflation and add it back on deflation. However, not all devices are backed by a physical IOMMU. In the case of mediated devices, if a vendor driver is well synchronized with the guest driver, such that only pages actively used by the guest driver are pinned by the host mdev vendor driver, then there should be no overlap between pages available for the balloon driver and pages actively in use by the device. Under these conditions, ballooning should be safe. vfio-ccw devices are always mediated devices and always operate under the constraints above. Therefore we can consider all vfio-ccw devices as balloon compatible. The situation is far from straightforward with vfio-pci. These devices can be physical devices with physical IOMMU backing or mediated devices where it is unknown whether a physical IOMMU is in use or whether the vendor driver is well synchronized to the working set of the guest driver. The safest approach is therefore to assume all vfio-pci devices are incompatible with ballooning, but allow user opt-in should they have further insight into mediated devices. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'hw/vfio/ccw.c')
-rw-r--r--hw/vfio/ccw.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 351b305..e96bbdc 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -349,6 +349,15 @@ static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice *vcdev,
}
}
+ /*
+ * All vfio-ccw devices are believed to operate in a way compatible with
+ * memory ballooning, ie. pages pinned in the host are in the current
+ * working set of the guest driver and therefore never overlap with pages
+ * available to the guest balloon driver. This needs to be set before
+ * vfio_get_device() for vfio common to handle the balloon inhibitor.
+ */
+ vcdev->vdev.balloon_allowed = true;
+
if (vfio_get_device(group, vcdev->cdev.mdevid, &vcdev->vdev, errp)) {
goto out_err;
}