qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC PATCH 08/20] Memory: add notifier flag check in memory


From: Liu, Yi L
Subject: [Qemu-devel] [RFC PATCH 08/20] Memory: add notifier flag check in memory_replay()
Date: Wed, 26 Apr 2017 18:06:38 +0800

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]