Skip to contentSkip to conversation

iommu: exports set_entry

PATCH In review Jean Guyader 2 participants 2 messages Nov 15, 2010 – Nov 18, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 iommu: exports set_entry

Exports iommu_set_entry to the rest of xen.

---

xen/drivers/passthrough/iommu.c +17 -0
diff -r 93ae9939b4a5 xen/drivers/passthrough/iommu.c
@@ -418,6 +418,23 @@
         ops->suspend();
 }
 
+int iommu_set_entry(struct domain *d, unsigned long gfn, unsigned long mfn,
+                    unsigned int flags, int map)
+{
+    const struct iommu_ops *ops = iommu_get_ops();
+    if ( iommu_enabled )
+        return ops->set_entry(d, gfn, mfn, flags, map);
+    return -1;
+}
+
+int iommu_flush_iotlb(struct domain *d, unsigned long gfn, unsigned int nr)
+{
+    const struct iommu_ops *ops = iommu_get_ops();
+    if ( iommu_enabled )
+        return ops->flush_iotlb(d, gfn, nr);
+    return -1;
+}
+
 /*
  * Local variables:
  * mode: C
xen/drivers/passthrough/vtd/iommu.c +2 -0
diff -r 93ae9939b4a5 xen/drivers/passthrough/vtd/iommu.c
@@ -2197,6 +2197,8 @@
     .read_msi_from_ire = msi_msg_read_remap_rte,
     .suspend = vtd_suspend,
     .resume = vtd_resume,
+    .set_entry = intel_iommu_set_entry,
+    .flush_iotlb = intel_iommu_flush_iotlb
 };
 
 /*
xen/include/xen/iommu.h +7 -0
diff -r 93ae9939b4a5 xen/include/xen/iommu.h
@@ -84,6 +84,10 @@
                    unsigned int flags);
 int iommu_unmap_page(struct domain *d, unsigned long gfn);
 
+int iommu_set_entry(struct domain *d, unsigned long gfn, unsigned long mfn,
+                    unsigned int flags, int map);
+int iommu_flush_iotlb(struct domain *d, unsigned long gfn, unsigned int nr);
+
 void iommu_domain_teardown(struct domain *d);
 int hvm_do_IRQ_dpci(struct domain *d, unsigned int irq);
 int dpci_ioport_intercept(ioreq_t *p);
@@ -130,6 +134,9 @@
     unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg);
     void (*suspend)(void);
     void (*resume)(void);
+    int (*set_entry)(struct domain *d, unsigned long gfn, unsigned long mfn,
+                     unsigned int flags, int map);
+    int (*flush_iotlb)(struct domain *d, unsigned long gfn, unsigned int nr);
 };
 
 void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

xen/drivers/passthrough/iommu.c line 426

Quoted 13 lines · Jean Guyader

diff -r 93ae9939b4a5 xen/drivers/passthrough/iommu.c

xen/drivers/passthrough/iommu.c +6 -0
@@ -418,6 +418,23 @@
         ops->suspend();
 }
 
+int iommu_set_entry(struct domain *d, unsigned long gfn, unsigned long mfn,
+                    unsigned int flags, int map)
+{
+    const struct iommu_ops *ops = iommu_get_ops();
+    if ( iommu_enabled )
+        return ops->set_entry(d, gfn, mfn, flags, map);

Needs a check that set_entry() isn't NULL or it'll crash on AMD IOMMUs.

xen/drivers/passthrough/iommu.c line 434

Quoted 8 lines
xen/drivers/passthrough/iommu.c +8 -0
+    return -1;
+}
+
+int iommu_flush_iotlb(struct domain *d, unsigned long gfn, unsigned int nr)
+{
+    const struct iommu_ops *ops = iommu_get_ops();
+    if ( iommu_enabled )
+        return ops->flush_iotlb(d, gfn, nr);

Likewise.

Quoted 47 lines
xen/drivers/passthrough/iommu.c +3 -0
+    return -1;
+}
+
 /*
  * Local variables:
  * mode: C

diff -r 93ae9939b4a5 xen/drivers/passthrough/vtd/iommu.c

xen/drivers/passthrough/vtd/iommu.c +2 -0
@@ -2197,6 +2197,8 @@
     .read_msi_from_ire = msi_msg_read_remap_rte,
     .suspend = vtd_suspend,
     .resume = vtd_resume,
+    .set_entry = intel_iommu_set_entry,
+    .flush_iotlb = intel_iommu_flush_iotlb
 };
 
 /*

diff -r 93ae9939b4a5 xen/include/xen/iommu.h

xen/include/xen/iommu.h +7 -0
@@ -84,6 +84,10 @@
                    unsigned int flags);
 int iommu_unmap_page(struct domain *d, unsigned long gfn);
 
+int iommu_set_entry(struct domain *d, unsigned long gfn, unsigned long mfn,
+                    unsigned int flags, int map);
+int iommu_flush_iotlb(struct domain *d, unsigned long gfn, unsigned int nr);
+
 void iommu_domain_teardown(struct domain *d);
 int hvm_do_IRQ_dpci(struct domain *d, unsigned int irq);
 int dpci_ioport_intercept(ioreq_t *p);
@@ -130,6 +134,9 @@
     unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg);
     void (*suspend)(void);
     void (*resume)(void);
+    int (*set_entry)(struct domain *d, unsigned long gfn, unsigned long mfn,
+                     unsigned int flags, int map);
+    int (*flush_iotlb)(struct domain *d, unsigned long gfn, unsigned int nr);
 };
 
 void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)