Message ID | 20250219175941.135390-2-eric.auger@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | hw/vfio/pci: Prevent BARs from being dma mapped in d3hot state | expand |
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 0c60be5b15..92c58f14a0 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -182,6 +182,17 @@ struct VFIODeviceOps { * Returns zero to indicate success and negative for error */ int (*vfio_load_config)(VFIODevice *vdev, QEMUFile *f); + + /** + * @is_dma_map_allowed + * + * Returns if the device regions can be dma mapped + * It may happen that the device state is not compatible + * with such operation + * + * @vdev: #VFIODevice whose power state needs to be tested + */ + bool (*vfio_is_dma_map_allowed)(VFIODevice *vdev); }; typedef struct VFIOGroup {
It may happen that a VFIO device state prevents its regions from beeing DMA mapped. Specifically this happens with VFIO PCI device in D3hot power state whose BARs cannot be dma mapped. The behavior was introduced by kernel commit: 2b2c651baf1c ("vfio/pci: Invalidate mmaps and block the access in D3hot power state") We introduce a new VFIODeviceOps callback to retrieve whether DMA MAP is allowed. This callback will be called from the generic code, in vfio_listener_region_add. Signed-off-by: Eric Auger <eric.auger@redhat.com> --- include/hw/vfio/vfio-common.h | 11 +++++++++++ 1 file changed, 11 insertions(+)