summaryrefslogtreecommitdiff
path: root/drivers/vfio/vfio_iommu_type1.c
diff options
context:
space:
mode:
authorJike Song <jike.song@intel.com>2016-12-01 13:20:05 +0800
committerAlex Williamson <alex.williamson@redhat.com>2016-12-01 09:38:47 -0700
commit22195cbd3451a75abaf30651a61cf85c89061327 (patch)
tree9178b97be1c3800c8832adabde709868e452a130 /drivers/vfio/vfio_iommu_type1.c
parentd256459fae4dba66d50850f2d948306503818913 (diff)
vfio: vfio_register_notifier: classify iommu notifier
Currently vfio_register_notifier assumes that there is only one notifier chain, which is in vfio_iommu. However, the user might also be interested in events other than vfio_iommu, for example, vfio_group. Refactor vfio_{un}register_notifier implementation to make it feasible. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com> Signed-off-by: Jike Song <jike.song@intel.com> [aw: merge with commit 816ca69ea9c7 ("vfio: Fix handling of error returned by 'vfio_group_get_from_dev()'"), remove typedef] Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/vfio_iommu_type1.c')
-rw-r--r--drivers/vfio/vfio_iommu_type1.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 51810a95416e..b88ad1e5e7ff 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1584,10 +1584,18 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
}
static int vfio_iommu_type1_register_notifier(void *iommu_data,
+ unsigned long *events,
struct notifier_block *nb)
{
struct vfio_iommu *iommu = iommu_data;
+ /* clear known events */
+ *events &= ~VFIO_IOMMU_NOTIFY_DMA_UNMAP;
+
+ /* refuse to register if still events remaining */
+ if (*events)
+ return -EINVAL;
+
return blocking_notifier_chain_register(&iommu->notifier, nb);
}