[RFC PATCH 08/20] Memory: add notifier flag check in memory_replay()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



memory_region_iommu_replay is used to do replay with MAP/UNMAP notifier.
However, other notifiers may be passed in, so add a check against notifier
flag to avoid potential error. e.g. memory_region_iommu_replay_all loops
all registered notifiers, may just pass in wrong notifier.

Signed-off-by: Liu, Yi L <yi.l.liu@xxxxxxxxxxxxxxx>
---
 memory.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/memory.c b/memory.c
index 9c253cc..0728e62 100644
--- a/memory.c
+++ b/memory.c
@@ -1630,6 +1630,14 @@ void memory_region_iommu_replay(MemoryRegion *mr, IOMMUNotifier *n,
     hwaddr addr, granularity;
     IOMMUTLBEntry iotlb;
 
+    if (!(n->notifier_flags & IOMMU_NOTIFIER_MAP_UNMAP)) {
+        /* If notifier flag is not IOMMU_NOTIFIER_UNMAP or
+         * IOMMU_NOTIFIER_MAP, return. This check is necessary
+         * as there is notifier other than MAP/UNMAP
+         */
+        return;
+    }
+
     /* If the IOMMU has its own replay callback, override */
     if (mr->iommu_ops->replay) {
         mr->iommu_ops->replay(mr, n);
-- 
1.9.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux