On Fri, Jan 13, 2017 at 05:37:43PM +0800, Jason Wang wrote:
[...]
> >>>diff --git a/memory.c b/memory.c
> >>>index 2bfc37f..e88bb54 100644
> >>>--- a/memory.c
> >>>+++ b/memory.c
> >>>@@ -1671,7 +1671,9 @@ void memory_region_notify_iommu(MemoryRegion *mr,
> >>> }
> >>> QLIST_FOREACH(iommu_notifier, &mr->iommu_notify, node) {
> >>>- if (iommu_notifier->notifier_flags & request_flags) {
> >>>+ if (iommu_notifier->notifier_flags & request_flags &&
> >>>+ iommu_notifier->start <= entry.iova &&
> >>>+ iommu_notifier->end >= entry.iova) {
> >>> iommu_notifier->notify(iommu_notifier, &entry);
> >>> }
> >>> }
> >>This seems breaks vhost device IOTLB. How about keep the the behavior
> >>somehow?
> >Thanks to point out. How about I squash this into this patch?
> >
> >--------8<--------
> >diff --git a/memory.c b/memory.c
> >index e88bb54..6de02dd 100644
> >--- a/memory.c
> >+++ b/memory.c
> >@@ -1608,8 +1608,14 @@ void
> >memory_region_register_iommu_notifier(MemoryRegion *mr,
> > return;
> > }
> >+ if (n->start == 0 && n->end == 0) {
> >+ /* If these are not specified, we listen to the whole range */
> >+ n->end = (hwaddr)(-1);
> >+ }
> >+
> > /* We need to register for at least one bitfield */
> > assert(n->notifier_flags != IOMMU_NOTIFIER_NONE);
> >+ assert(n->start <= n->end);
> > QLIST_INSERT_HEAD(&mr->iommu_notify, n, node);
> > memory_region_update_iommu_notify_flags(mr);
> > }
> >-------->8--------
> >
> >-- peterx
>
> This should work, or you can introduce a memory_region_iommu_notifier_init()
> to force user to explicitly initialize start and end.
Hmm, this sounds better, considering that IOMMUNotifier is getting
more fields to be inited. Thanks,
-- peterx