Skip to contentSkip to conversation

memory/intel_iommu: Generate error for incompatible usage

PATCH In review Alex Williamson 6 participants 13 messages Jun 15, 2016 – Jun 29, 2016

lore
Share & tools
lore
#0 lore raw

cover memory/intel_iommu: Generate error for incompatible usage

VT-d emulation is currently incompatible with device assignment due to intel_iommu's lack of support for memory_region_notify_iommu(). Alexey has proposed a nice addition to the MemoryRegionIOMMUOps structure that adds callbacks when the first iommu notifier is registered and the last is removed. For POWER this will allow them to switch the view of the iommu depending on whether anyone in userspace is watching. For VT-d I expect that eventually we'll use these callbacks to enable and disable code paths so that we avoid notifier overhead when there are no registered notifiy-ees. For now, we don't support calling memory_region_notify_iommu(), so this signals an incompatible hardware configuration. If we choose to make CM=0 a user selectable option, something like this might continue to be useful if we only support notifies via invalidations rather than full VT-d data structure shadowing.

Even though we're currently working on enabling users like vfio-pci with VT-d, I believe this is correct for the current state of things. We might even want to consider this stable for v2.6.x so that downstreams pick it up to avoid incompatible configurations.

Alexey, I hope I'm not stepping on your toes by extracting this from your latest patch series. Please let us know whether you approve. Thanks,

Alex

---

Alex Williamson (1):
intel_iommu: Throw hw_error on notify_started

Alexey Kardashevskiy (1):
memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks

 hw/i386/intel_iommu.c |   12 ++++++++++++
 hw/vfio/common.c      |    5 +++--
 include/exec/memory.h |    8 +++++++-
 memory.c              |   10 +++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)
#1 lore raw

PATCH 1/2 memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks

From: Alexey Kardashevskiy <[email protected]>

The IOMMU driver may change behavior depending on whether a notifier client is present. In the case of POWER, this represents a change in the visibility of the IOTLB, for other drivers such as intel-iommu and future AMD-Vi emulation, notifier support is not yet enabled and this provides the opportunity to flag that incompatibility.

[new log & extracted from [PATCH qemu v17 12/12] spapr_iommu, vfio, memory: Notify IOMMU about starting/stopping listening]
---
 hw/vfio/common.c      |    5 +++--
 include/exec/memory.h |    8 +++++++-
 memory.c              |   10 +++++++++-
 3 files changed, 19 insertions(+), 4 deletions(-)
hw/vfio/common.c +3 -2
index e51ed3a..94f4a6c 100644
@@ -463,7 +463,8 @@ static void vfio_listener_region_del(MemoryListener *listener,
 
         QLIST_FOREACH(giommu, &container->giommu_list, giommu_next) {
             if (giommu->iommu == section->mr) {
-                memory_region_unregister_iommu_notifier(&giommu->n);
+                memory_region_unregister_iommu_notifier(giommu->iommu,
+                                                        &giommu->n);
                 QLIST_REMOVE(giommu, giommu_next);
                 g_free(giommu);
                 break;
@@ -999,7 +1000,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
         QLIST_REMOVE(container, next);
 
         QLIST_FOREACH_SAFE(giommu, &container->giommu_list, giommu_next, tmp) {
-            memory_region_unregister_iommu_notifier(&giommu->n);
+            memory_region_unregister_iommu_notifier(giommu->iommu, &giommu->n);
             QLIST_REMOVE(giommu, giommu_next);
             g_free(giommu);
         }
include/exec/memory.h +7 -1
index 4ab6800..a6862fc 100644
@@ -151,6 +151,10 @@ typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps;
 struct MemoryRegionIOMMUOps {
     /* Return a TLB entry that contains a given address. */
     IOMMUTLBEntry (*translate)(MemoryRegion *iommu, hwaddr addr, bool is_write);
+    /* Called when the first notifier is set */
+    void (*notify_started)(MemoryRegion *iommu);
+    /* Called when the last notifier is removed */
+    void (*notify_stopped)(MemoryRegion *iommu);
 };
 
 typedef struct CoalescedMemoryRange CoalescedMemoryRange;
@@ -611,9 +615,11 @@ void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n,
  * memory_region_unregister_iommu_notifier: unregister a notifier for
  * changes to IOMMU translation entries.
  *
+ * @mr: the memory region which was observed and for which notity_stopped()
+ *      needs to be called
  * @n: the notifier to be removed.
  */
-void memory_region_unregister_iommu_notifier(Notifier *n);
+void memory_region_unregister_iommu_notifier(MemoryRegion *mr, Notifier *n);
 
 /**
  * memory_region_name: get a memory region's name
memory.c +9 -1
index 8ba496d..008ebe3 100644
@@ -1499,6 +1499,10 @@ bool memory_region_is_logging(MemoryRegion *mr, uint8_t client)
 
 void memory_region_register_iommu_notifier(MemoryRegion *mr, Notifier *n)
 {
+    if (mr->iommu_ops->notify_started &&
+        QLIST_EMPTY(&mr->iommu_notify.notifiers)) {
+        mr->iommu_ops->notify_started(mr);
+    }
     notifier_list_add(&mr->iommu_notify, n);
 }
 
@@ -1522,9 +1526,13 @@ void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n,
     }
 }
 
-void memory_region_unregister_iommu_notifier(Notifier *n)
+void memory_region_unregister_iommu_notifier(MemoryRegion *mr, Notifier *n)
 {
     notifier_remove(n);
+    if (mr->iommu_ops->notify_stopped &&
+        QLIST_EMPTY(&mr->iommu_notify.notifiers)) {
+        mr->iommu_ops->notify_stopped(mr);
+    }
 }
 
 void memory_region_notify_iommu(MemoryRegion *mr,
#2 lore raw

PATCH 2/2 intel_iommu: Throw hw_error on notify_started

In reply to Alex Williamson

We don't currently support the MemoryRegionIOMMUOps notifier, so throw an error should a device require it.

---
 hw/i386/intel_iommu.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/i386/intel_iommu.c +12 -0
index 347718f..5eba704 100644
@@ -24,6 +24,7 @@
 #include "exec/address-spaces.h"
 #include "intel_iommu_internal.h"
 #include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
 
 /*#define DEBUG_INTEL_IOMMU*/
 #ifdef DEBUG_INTEL_IOMMU
@@ -1871,6 +1872,16 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
     return ret;
 }
 
+static void vtd_iommu_notify_started(MemoryRegion *iommu)
+{
+    VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
+
+    hw_error("Device at bus %s addr %02x.%d requires iommu notifier which "
+             "is currently not supported by intel-iommu emulation",
+             vtd_as->bus->qbus.name, PCI_SLOT(vtd_as->devfn),
+             PCI_FUNC(vtd_as->devfn));
+}
+
 static const VMStateDescription vtd_vmstate = {
     .name = "iommu-intel",
     .unmigratable = 1,
@@ -1938,6 +1949,7 @@ static void vtd_init(IntelIOMMUState *s)
     memset(s->womask, 0, DMAR_REG_SIZE);
 
     s->iommu_ops.translate = vtd_iommu_translate;
+    s->iommu_ops.notify_started = vtd_iommu_notify_started;
     s->root = 0;
     s->root_extended = false;
     s->dmar_enabled = false;
Reviewed-by on v1 2/2
#3 lore raw

Re: [Qemu-devel] [PATCH 2/2] intel_iommu: Throw hw_error on notify_started

Quoted 4 lines · Alex Williamson

We don't currently support the MemoryRegionIOMMUOps notifier, so throw an error should a device require it.

Quoted 42 lines
---
 hw/i386/intel_iommu.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/i386/intel_iommu.c +12 -0
index 347718f..5eba704 100644
@@ -24,6 +24,7 @@
 #include "exec/address-spaces.h"
 #include "intel_iommu_internal.h"
 #include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
 
 /*#define DEBUG_INTEL_IOMMU*/
 #ifdef DEBUG_INTEL_IOMMU
@@ -1871,6 +1872,16 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
     return ret;
 }
 
+static void vtd_iommu_notify_started(MemoryRegion *iommu)
+{
+    VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
+
+    hw_error("Device at bus %s addr %02x.%d requires iommu notifier which "
+             "is currently not supported by intel-iommu emulation",
+             vtd_as->bus->qbus.name, PCI_SLOT(vtd_as->devfn),
+             PCI_FUNC(vtd_as->devfn));
+}
+
 static const VMStateDescription vtd_vmstate = {
     .name = "iommu-intel",
     .unmigratable = 1,
@@ -1938,6 +1949,7 @@ static void vtd_init(IntelIOMMUState *s)
     memset(s->womask, 0, DMAR_REG_SIZE);
 
     s->iommu_ops.translate = vtd_iommu_translate;
+    s->iommu_ops.notify_started = vtd_iommu_notify_started;
     s->root = 0;
     s->root_extended = false;
     s->dmar_enabled = false;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Reviewed-by on v1 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] intel_iommu: Throw hw_error on notify_started

In reply to Alex Williamson
Quoted 39 lines · Alex Williamson

We don't currently support the MemoryRegionIOMMUOps notifier, so throw an error should a device require it.

---
  hw/i386/intel_iommu.c |   12 ++++++++++++
  1 file changed, 12 insertions(+)
hw/i386/intel_iommu.c +11 -0
index 347718f..5eba704 100644
@@ -24,6 +24,7 @@
  #include "exec/address-spaces.h"
  #include "intel_iommu_internal.h"
  #include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
 
  /*#define DEBUG_INTEL_IOMMU*/
  #ifdef DEBUG_INTEL_IOMMU
@@ -1871,6 +1872,16 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
      return ret;
  }
 
+static void vtd_iommu_notify_started(MemoryRegion *iommu)
+{
+    VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
+
+    hw_error("Device at bus %s addr %02x.%d requires iommu notifier which "
+             "is currently not supported by intel-iommu emulation",
+             vtd_as->bus->qbus.name, PCI_SLOT(vtd_as->devfn),
+             PCI_FUNC(vtd_as->devfn));
+}
+
  static const VMStateDescription vtd_vmstate = {
      .name = "iommu-intel",
      .unmigratable = 1,

hw/i386/intel_iommu.c static void vtd_init(IntelIOMMUState *s) · line 1955

Quoted 7 lines
hw/i386/intel_iommu.c +1 -0
@@ -1938,6 +1949,7 @@ static void vtd_init(IntelIOMMUState *s)
      memset(s->womask, 0, DMAR_REG_SIZE);
 
      s->iommu_ops.translate = vtd_iommu_translate;
+    s->iommu_ops.notify_started = vtd_iommu_notify_started;
      s->root = 0;
      s->root_extended = false;
      s->dmar_enabled = false;

Thanks,
Marcel

#5 lore raw
In reply to Alex Williamson
Quoted 15 lines · Alex Williamson

VT-d emulation is currently incompatible with device assignment due to intel_iommu's lack of support for memory_region_notify_iommu(). Alexey has proposed a nice addition to the MemoryRegionIOMMUOps structure that adds callbacks when the first iommu notifier is registered and the last is removed. For POWER this will allow them to switch the view of the iommu depending on whether anyone in userspace is watching. For VT-d I expect that eventually we'll use these callbacks to enable and disable code paths so that we avoid notifier overhead when there are no registered notifiy-ees. For now, we don't support calling memory_region_notify_iommu(), so this signals an incompatible hardware configuration. If we choose to make CM=0 a user selectable option, something like this might continue to be useful if we only support notifies via invalidations rather than full VT-d data structure shadowing.

Quoted 8 lines

Even though we're currently working on enabling users like vfio-pci with VT-d, I believe this is correct for the current state of things. We might even want to consider this stable for v2.6.x so that downstreams pick it up to avoid incompatible configurations.

Alexey, I hope I'm not stepping on your toes by extracting this from your latest patch series. Please let us know whether you approve. Thanks,

I am totally fine with either way of accepting my patches, after all the idea was yours, I just put it in the code :)

Quoted 18 lines

Alex

---

Alex Williamson (1):
intel_iommu: Throw hw_error on notify_started

Alexey Kardashevskiy (1):
memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks

 hw/i386/intel_iommu.c |   12 ++++++++++++
 hw/vfio/common.c      |    5 +++--
 include/exec/memory.h |    8 +++++++-
 memory.c              |   10 +++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)
Signature · 1 line
Alexey
#6 lore raw
Quoted 21 lines · Alexey Kardashevskiy
Quoted 20 lines · Alex Williamson

VT-d emulation is currently incompatible with device assignment due to intel_iommu's lack of support for memory_region_notify_iommu(). Alexey has proposed a nice addition to the MemoryRegionIOMMUOps structure that adds callbacks when the first iommu notifier is registered and the last is removed. For POWER this will allow them to switch the view of the iommu depending on whether anyone in userspace is watching. For VT-d I expect that eventually we'll use these callbacks to enable and disable code paths so that we avoid notifier overhead when there are no registered notifiy-ees. For now, we don't support calling memory_region_notify_iommu(), so this signals an incompatible hardware configuration. If we choose to make CM=0 a user selectable option, something like this might continue to be useful if we only support notifies via invalidations rather than full VT-d data structure shadowing.

Even though we're currently working on enabling users like vfio-pci with VT-d, I believe this is correct for the current state of things. We might even want to consider this stable for v2.6.x so that downstreams pick it up to avoid incompatible configurations.

Quoted 6 lines
Quoted 3 lines

Alexey, I hope I'm not stepping on your toes by extracting this from your latest patch series. Please let us know whether you approve. Thanks,

I am totally fine with either way of accepting my patches, after all the idea was yours, I just put it in the code :)

Alex, when are you planning on sending pull request with this patch? I am asking as I'd prefer to respin "spapr_pci/spapr_pci_vfio: Support Dynamic DMA" on top of it (assuming David rebases his queue on top of it) and avoid doing unnecessary work. Thanks.

Quoted 19 lines
Quoted 19 lines

Alex

---

Alex Williamson (1):
intel_iommu: Throw hw_error on notify_started

Alexey Kardashevskiy (1):
memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks

 hw/i386/intel_iommu.c |   12 ++++++++++++
 hw/vfio/common.c      |    5 +++--
 include/exec/memory.h |    8 +++++++-
 memory.c              |   10 +++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)
Signature · 1 line
Alexey
#7 lore raw
Quoted 26 lines · On Mon, 27 Jun 2016 14:46:12 +1000 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 25 lines · Alexey Kardashevskiy
Quoted 23 lines · Alex Williamson

VT-d emulation is currently incompatible with device assignment due to intel_iommu's lack of support for memory_region_notify_iommu(). Alexey has proposed a nice addition to the MemoryRegionIOMMUOps structure that adds callbacks when the first iommu notifier is registered and the last is removed. For POWER this will allow them to switch the view of the iommu depending on whether anyone in userspace is watching. For VT-d I expect that eventually we'll use these callbacks to enable and disable code paths so that we avoid notifier overhead when there are no registered notifiy-ees. For now, we don't support calling memory_region_notify_iommu(), so this signals an incompatible hardware configuration. If we choose to make CM=0 a user selectable option, something like this might continue to be useful if we only support notifies via invalidations rather than full VT-d data structure shadowing.

Even though we're currently working on enabling users like vfio-pci with VT-d, I believe this is correct for the current state of things. We might even want to consider this stable for v2.6.x so that downstreams pick it up to avoid incompatible configurations.

Alexey, I hope I'm not stepping on your toes by extracting this from your latest patch series. Please let us know whether you approve. Thanks,

Quoted 7 lines
Quoted 2 lines

I am totally fine with either way of accepting my patches, after all the idea was yours, I just put it in the code :)

Alex, when are you planning on sending pull request with this patch? I am asking as I'd prefer to respin "spapr_pci/spapr_pci_vfio: Support Dynamic DMA" on top of it (assuming David rebases his queue on top of it) and avoid doing unnecessary work. Thanks.

The only file I maintain from this series is just minor collateral from the api change. I'll therefore redirect this question to Paolo, but I'm happy to pull it through my tree with his ack. Thanks,

Alex

Quoted 16 lines
Quoted 14 lines
Quoted 14 lines

---

Alex Williamson (1):
intel_iommu: Throw hw_error on notify_started

Alexey Kardashevskiy (1):
memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks

 hw/i386/intel_iommu.c |   12 ++++++++++++
 hw/vfio/common.c      |    5 +++--
 include/exec/memory.h |    8 +++++++-
 memory.c              |   10 +++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)  
Reviewed-by Tested-by on the v1 series
#8 lore raw
In reply to Alex Williamson
Quoted 15 lines · Alex Williamson

VT-d emulation is currently incompatible with device assignment due to intel_iommu's lack of support for memory_region_notify_iommu(). Alexey has proposed a nice addition to the MemoryRegionIOMMUOps structure that adds callbacks when the first iommu notifier is registered and the last is removed. For POWER this will allow them to switch the view of the iommu depending on whether anyone in userspace is watching. For VT-d I expect that eventually we'll use these callbacks to enable and disable code paths so that we avoid notifier overhead when there are no registered notifiy-ees. For now, we don't support calling memory_region_notify_iommu(), so this signals an incompatible hardware configuration. If we choose to make CM=0 a user selectable option, something like this might continue to be useful if we only support notifies via invalidations rather than full VT-d data structure shadowing.

Quoted 4 lines

Even though we're currently working on enabling users like vfio-pci with VT-d, I believe this is correct for the current state of things. We might even want to consider this stable for v2.6.x so that downstreams pick it up to avoid incompatible configurations.

(This is much more friendly than a dead loop.)

Quoted 21 lines

Alexey, I hope I'm not stepping on your toes by extracting this from your latest patch series. Please let us know whether you approve. Thanks,

Alex

---

Alex Williamson (1):
intel_iommu: Throw hw_error on notify_started

Alexey Kardashevskiy (1):
memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks

 hw/i386/intel_iommu.c |   12 ++++++++++++
 hw/vfio/common.c      |    5 +++--
 include/exec/memory.h |    8 +++++++-
 memory.c              |   10 +++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)
#9 lore raw
In reply to Alex Williamson

Paolo & Michael,

Any comments on this series? I think we need Paolo's ack for the memory changes and either of your ack for hw/i386/. I'm happy to pull this through my tree with your approval though. Thanks,

Alex

Quoted 40 lines · On Wed, 15 Jun 2016 09:56:03 -0600 Alex Williamson…

VT-d emulation is currently incompatible with device assignment due to intel_iommu's lack of support for memory_region_notify_iommu(). Alexey has proposed a nice addition to the MemoryRegionIOMMUOps structure that adds callbacks when the first iommu notifier is registered and the last is removed. For POWER this will allow them to switch the view of the iommu depending on whether anyone in userspace is watching. For VT-d I expect that eventually we'll use these callbacks to enable and disable code paths so that we avoid notifier overhead when there are no registered notifiy-ees. For now, we don't support calling memory_region_notify_iommu(), so this signals an incompatible hardware configuration. If we choose to make CM=0 a user selectable option, something like this might continue to be useful if we only support notifies via invalidations rather than full VT-d data structure shadowing.

Even though we're currently working on enabling users like vfio-pci with VT-d, I believe this is correct for the current state of things. We might even want to consider this stable for v2.6.x so that downstreams pick it up to avoid incompatible configurations.

Alexey, I hope I'm not stepping on your toes by extracting this from your latest patch series. Please let us know whether you approve. Thanks,

Alex

---

Alex Williamson (1):
intel_iommu: Throw hw_error on notify_started

Alexey Kardashevskiy (1):
memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks

 hw/i386/intel_iommu.c |   12 ++++++++++++
 hw/vfio/common.c      |    5 +++--
 include/exec/memory.h |    8 +++++++-
 memory.c              |   10 +++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)
#10 lore raw
Quoted 5 lines · Alex Williamson

Paolo & Michael,

Any comments on this series? I think we need Paolo's ack for the memory changes and either of your ack for hw/i386/. I'm happy to pull this through my tree with your approval though. Thanks,

I think I already acked the callbacks, in any case the patches look good.

Paolo

Quoted 46 lines

Alex

Quoted 40 lines · On Wed, 15 Jun 2016 09:56:03 -0600 Alex Williamson…

VT-d emulation is currently incompatible with device assignment due to intel_iommu's lack of support for memory_region_notify_iommu(). Alexey has proposed a nice addition to the MemoryRegionIOMMUOps structure that adds callbacks when the first iommu notifier is registered and the last is removed. For POWER this will allow them to switch the view of the iommu depending on whether anyone in userspace is watching. For VT-d I expect that eventually we'll use these callbacks to enable and disable code paths so that we avoid notifier overhead when there are no registered notifiy-ees. For now, we don't support calling memory_region_notify_iommu(), so this signals an incompatible hardware configuration. If we choose to make CM=0 a user selectable option, something like this might continue to be useful if we only support notifies via invalidations rather than full VT-d data structure shadowing.

Even though we're currently working on enabling users like vfio-pci with VT-d, I believe this is correct for the current state of things. We might even want to consider this stable for v2.6.x so that downstreams pick it up to avoid incompatible configurations.

Alexey, I hope I'm not stepping on your toes by extracting this from your latest patch series. Please let us know whether you approve. Thanks,

Alex

---

Alex Williamson (1):
intel_iommu: Throw hw_error on notify_started

Alexey Kardashevskiy (1):
memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks

 hw/i386/intel_iommu.c |   12 ++++++++++++
 hw/vfio/common.c      |    5 +++--
 include/exec/memory.h |    8 +++++++-
 memory.c              |   10 +++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)
#11 lore raw
Quoted 8 lines · On Wed, 29 Jun 2016 12:53:39 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Alex Williamson

Paolo & Michael,

Any comments on this series? I think we need Paolo's ack for the memory changes and either of your ack for hw/i386/. I'm happy to pull this through my tree with your approval though. Thanks,

I think I already acked the callbacks, in any case the patches look good.

Hmm, I can't find any evidence of that and I'm not terribly comfortable inferring an Acked-by where it is not explicitly given. Can you send a formal sign-off or point me to where I can find the one you're thinking of? Thanks,

Alex

Quoted 44 lines
Quoted 44 lines
Quoted 40 lines · On Wed, 15 Jun 2016 09:56:03 -0600 Alex Williamson…

VT-d emulation is currently incompatible with device assignment due to intel_iommu's lack of support for memory_region_notify_iommu(). Alexey has proposed a nice addition to the MemoryRegionIOMMUOps structure that adds callbacks when the first iommu notifier is registered and the last is removed. For POWER this will allow them to switch the view of the iommu depending on whether anyone in userspace is watching. For VT-d I expect that eventually we'll use these callbacks to enable and disable code paths so that we avoid notifier overhead when there are no registered notifiy-ees. For now, we don't support calling memory_region_notify_iommu(), so this signals an incompatible hardware configuration. If we choose to make CM=0 a user selectable option, something like this might continue to be useful if we only support notifies via invalidations rather than full VT-d data structure shadowing.

Even though we're currently working on enabling users like vfio-pci with VT-d, I believe this is correct for the current state of things. We might even want to consider this stable for v2.6.x so that downstreams pick it up to avoid incompatible configurations.

Alexey, I hope I'm not stepping on your toes by extracting this from your latest patch series. Please let us know whether you approve. Thanks,

Alex

---

Alex Williamson (1):
intel_iommu: Throw hw_error on notify_started

Alexey Kardashevskiy (1):
memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks

 hw/i386/intel_iommu.c |   12 ++++++++++++
 hw/vfio/common.c      |    5 +++--
 include/exec/memory.h |    8 +++++++-
 memory.c              |   10 +++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)  
Acked-by
#12 lore raw
Quoted 9 lines · Alex Williamson
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

Any comments on this series? I think we need Paolo's ack for the memory changes and either of your ack for hw/i386/. I'm happy to pull this through my tree with your approval though. Thanks,

I think I already acked the callbacks, in any case the patches look good.

Hmm, I can't find any evidence of that and I'm not terribly comfortable inferring an Acked-by where it is not explicitly given. Can you send a formal sign-off or point me to where I can find the one you're thinking of? Thanks,

You're right, I had seen Alexey's patch but I hadn't acked it. Sorry for the delay then!

Paolo