]> xenbits.xensource.com Git - xen.git/commitdiff
IOMMU/x86: per-domain control structure is not HVM-specific
authorJan Beulich <jbeulich@suse.com>
Fri, 27 May 2016 12:48:00 +0000 (14:48 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 27 May 2016 12:48:00 +0000 (14:48 +0200)
... and hence should not live in the HVM part of the PV/HVM union. In
fact it's not even architecture specific (there already is a per-arch
extension type to it), so it gets moved out right to common struct
domain.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
master commit: af07377007d595b5d6422291bb1c932c16d1036f
master date: 2016-05-04 09:44:32 +0200

26 files changed:
xen/arch/x86/domctl.c
xen/arch/x86/hvm/io.c
xen/arch/x86/tboot.c
xen/drivers/passthrough/amd/iommu_cmd.c
xen/drivers/passthrough/amd/iommu_guest.c
xen/drivers/passthrough/amd/iommu_intr.c
xen/drivers/passthrough/amd/iommu_map.c
xen/drivers/passthrough/amd/pci_amd_iommu.c
xen/drivers/passthrough/arm/smmu.c
xen/drivers/passthrough/device_tree.c
xen/drivers/passthrough/io.c
xen/drivers/passthrough/iommu.c
xen/drivers/passthrough/pci.c
xen/drivers/passthrough/vtd/intremap.c
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/passthrough/vtd/quirks.c
xen/drivers/passthrough/x86/iommu.c
xen/include/asm-arm/domain.h
xen/include/asm-arm/hvm/iommu.h [deleted file]
xen/include/asm-arm/iommu.h
xen/include/asm-x86/hvm/domain.h
xen/include/asm-x86/hvm/iommu.h
xen/include/asm-x86/iommu.h
xen/include/xen/hvm/iommu.h [deleted file]
xen/include/xen/iommu.h
xen/include/xen/sched.h

index 40fb3df98f5e14e9f934aaf787da84ccef775907..26496185a0818ee2c743396e51a544bf5651a8be 100644 (file)
@@ -646,7 +646,7 @@ long arch_do_domctl(
 
     case XEN_DOMCTL_ioport_mapping:
     {
-        struct hvm_iommu *hd;
+        struct domain_iommu *hd;
         unsigned int fgp = domctl->u.ioport_mapping.first_gport;
         unsigned int fmp = domctl->u.ioport_mapping.first_mport;
         unsigned int np = domctl->u.ioport_mapping.nr_ports;
@@ -672,7 +672,7 @@ long arch_do_domctl(
         if ( ret )
             break;
 
-        hd = domain_hvm_iommu(d);
+        hd = dom_iommu(d);
         if ( add )
         {
             printk(XENLOG_G_INFO
index b62aab21085b3f07a7690732abdf637afce4506f..d10c5f33d8dad895938ebc2144b01f64a44858cc 100644 (file)
@@ -347,13 +347,13 @@ static int dpci_ioport_write(uint32_t mport, ioreq_t *p)
 int dpci_ioport_intercept(ioreq_t *p)
 {
     struct domain *d = current->domain;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *dio = dom_iommu(d);
     struct g2m_ioport *g2m_ioport;
     unsigned int mport, gport = p->addr;
     unsigned int s = 0, e = 0;
     int rc;
 
-    list_for_each_entry( g2m_ioport, &hd->arch.g2m_ioport_list, list )
+    list_for_each_entry( g2m_ioport, &dio->arch.g2m_ioport_list, list )
     {
         s = g2m_ioport->gport;
         e = s + g2m_ioport->np;
index ca4839e7111bcebfff331839eee70d000d611551..ec4bcc2a138c8082d1224e9d58c7fb1c1b17648b 100644 (file)
@@ -228,9 +228,10 @@ static void tboot_gen_domain_integrity(const uint8_t key[TB_KEY_SIZE],
 
         if ( !is_idle_domain(d) )
         {
-            struct hvm_iommu *hd = domain_hvm_iommu(d);
-            update_iommu_mac(&ctx, hd->arch.pgd_maddr,
-                             agaw_to_level(hd->arch.agaw));
+            const struct domain_iommu *dio = dom_iommu(d);
+
+            update_iommu_mac(&ctx, dio->arch.pgd_maddr,
+                             agaw_to_level(dio->arch.agaw));
         }
     }
 
index 4faa01b46a72fa91f87b69644da95c224b773c7c..c4f1855ebbf62a30de683db02601d38f84c5bfd2 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 #include <xen/sched.h>
-#include <xen/hvm/iommu.h>
 #include <asm/amd-iommu.h>
 #include <asm/hvm/svm/amd-iommu-proto.h>
 #include "../ats.h"
index 98e7b38847fad199bdfc3f063f7b2d9838479f0a..bf8dd104df73079852ba6391e95c544df64163a1 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <xen/sched.h>
 #include <asm/p2m.h>
-#include <asm/hvm/iommu.h>
 #include <asm/amd-iommu.h>
 #include <asm/hvm/svm/amd-iommu-proto.h>
 
@@ -60,12 +59,12 @@ static uint16_t guest_bdf(struct domain *d, uint16_t machine_bdf)
 
 static inline struct guest_iommu *domain_iommu(struct domain *d)
 {
-    return domain_hvm_iommu(d)->arch.g_iommu;
+    return dom_iommu(d)->arch.g_iommu;
 }
 
 static inline struct guest_iommu *vcpu_iommu(struct vcpu *v)
 {
-    return domain_hvm_iommu(v->domain)->arch.g_iommu;
+    return dom_iommu(v->domain)->arch.g_iommu;
 }
 
 static void guest_iommu_enable(struct guest_iommu *iommu)
@@ -872,7 +871,7 @@ static void guest_iommu_reg_init(struct guest_iommu *iommu)
 int guest_iommu_init(struct domain* d)
 {
     struct guest_iommu *iommu;
-    struct hvm_iommu *hd  = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
 
     if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled )
         return 0;
@@ -908,7 +907,7 @@ void guest_iommu_destroy(struct domain *d)
     tasklet_kill(&iommu->cmd_buffer_tasklet);
     xfree(iommu);
 
-    domain_hvm_iommu(d)->arch.g_iommu = NULL;
+    dom_iommu(d)->arch.g_iommu = NULL;
 }
 
 static int guest_iommu_mmio_range(struct vcpu *v, unsigned long addr)
index d3f37258aab354b474e56ddd535cbb778dfc99fd..27c9729e07a72bda103648ebc769374f3e2365a4 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <xen/err.h>
 #include <xen/sched.h>
-#include <xen/hvm/iommu.h>
 #include <asm/amd-iommu.h>
 #include <asm/hvm/svm/amd-iommu-proto.h>
 #include <asm/io_apic.h>
index a8c60ec57beed61f30ba2ec77c161351d555ba2d..fcce75b688b0dbc871e5c6f0acffd82c63a1e8c6 100644 (file)
@@ -22,7 +22,6 @@
 #include <xen/acpi.h>
 #include <xen/sched.h>
 #include <asm/p2m.h>
-#include <xen/hvm/iommu.h>
 #include <asm/amd-iommu.h>
 #include <asm/hvm/svm/amd-iommu-proto.h>
 #include "../ats.h"
@@ -341,7 +340,7 @@ static int iommu_update_pde_count(struct domain *d, unsigned long pt_mfn,
     unsigned long first_mfn;
     u64 *table, *pde, *ntable;
     u64 ntable_maddr, mask;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
     bool_t ok = 0;
 
     ASSERT( spin_is_locked(&hd->arch.mapping_lock) && pt_mfn );
@@ -396,7 +395,7 @@ static int iommu_merge_pages(struct domain *d, unsigned long pt_mfn,
     u64 *table, *pde, *ntable;
     u64 ntable_mfn;
     unsigned long first_mfn;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
 
     ASSERT( spin_is_locked(&hd->arch.mapping_lock) && pt_mfn );
 
@@ -446,7 +445,7 @@ static int iommu_pde_from_gfn(struct domain *d, unsigned long pfn,
     unsigned long  next_table_mfn;
     unsigned int level;
     struct page_info *table;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
 
     table = hd->arch.root_table;
     level = hd->arch.paging_mode;
@@ -555,7 +554,7 @@ static int update_paging_mode(struct domain *d, unsigned long gfn)
     struct page_info *old_root = NULL;
     void *new_root_vaddr;
     unsigned long old_root_mfn;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
 
     level = hd->arch.paging_mode;
     old_root = hd->arch.root_table;
@@ -634,7 +633,7 @@ int amd_iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn,
                        unsigned int flags)
 {
     bool_t need_flush = 0;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
     unsigned long pt_mfn[7];
     unsigned int merge_level;
 
@@ -714,7 +713,7 @@ out:
 int amd_iommu_unmap_page(struct domain *d, unsigned long gfn)
 {
     unsigned long pt_mfn[7];
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
 
     BUG_ON( !hd->arch.root_table );
 
@@ -781,7 +780,7 @@ int amd_iommu_reserve_domain_unity_map(struct domain *domain,
 /* Share p2m table with iommu. */
 void amd_iommu_share_p2m(struct domain *d)
 {
-    struct hvm_iommu *hd  = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
     struct page_info *p2m_table;
     mfn_t pgd_mfn;
 
index e83bb35e484c521fc150c9dfbf3f9ed855740317..2e4832a6cf4c447435681036770982b7b81565d0 100644 (file)
@@ -24,7 +24,6 @@
 #include <xen/pci_regs.h>
 #include <xen/paging.h>
 #include <xen/softirq.h>
-#include <asm/hvm/iommu.h>
 #include <asm/amd-iommu.h>
 #include <asm/hvm/svm/amd-iommu-proto.h>
 #include "../ats.h"
@@ -118,8 +117,7 @@ static void amd_iommu_setup_domain_device(
     int req_id, valid = 1;
     int dte_i = 0;
     u8 bus = pdev->bus;
-
-    struct hvm_iommu *hd = domain_hvm_iommu(domain);
+    const struct domain_iommu *hd = dom_iommu(domain);
 
     BUG_ON( !hd->arch.root_table || !hd->arch.paging_mode ||
             !iommu->dev_table.buffer );
@@ -225,7 +223,7 @@ int __init amd_iov_detect(void)
     return scan_pci_devices();
 }
 
-static int allocate_domain_resources(struct hvm_iommu *hd)
+static int allocate_domain_resources(struct domain_iommu *hd)
 {
     /* allocate root table */
     spin_lock(&hd->arch.mapping_lock);
@@ -260,7 +258,7 @@ static int get_paging_mode(unsigned long entries)
 
 static int amd_iommu_domain_init(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
 
     /* allocate page directroy */
     if ( allocate_domain_resources(hd) != 0 )
@@ -342,7 +340,7 @@ void amd_iommu_disable_domain_device(struct domain *domain,
         AMD_IOMMU_DEBUG("Disable: device id = %#x, "
                         "domain = %d, paging mode = %d\n",
                         req_id,  domain->domain_id,
-                        domain_hvm_iommu(domain)->arch.paging_mode);
+                        dom_iommu(domain)->arch.paging_mode);
     }
     spin_unlock_irqrestore(&iommu->lock, flags);
 
@@ -359,7 +357,7 @@ static int reassign_device(struct domain *source, struct domain *target,
 {
     struct amd_iommu *iommu;
     int bdf;
-    struct hvm_iommu *t = domain_hvm_iommu(target);
+    struct domain_iommu *t = dom_iommu(target);
 
     bdf = PCI_BDF2(pdev->bus, pdev->devfn);
     iommu = find_iommu_for_device(pdev->seg, bdf);
@@ -459,7 +457,7 @@ static void deallocate_page_table(struct page_info *pg)
 
 static void deallocate_iommu_page_tables(struct domain *d)
 {
-    struct hvm_iommu *hd  = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
 
     if ( iommu_use_hap_pt(d) )
         return;
@@ -599,7 +597,7 @@ static void amd_dump_p2m_table_level(struct page_info* pg, int level,
 
 static void amd_dump_p2m_table(struct domain *d)
 {
-    struct hvm_iommu *hd  = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
 
     if ( !hd->arch.root_table )
         return;
index 42bde75a57a84f5332aae3c827e17c22e5ee60b9..b246ac6a5a798f47608c6640734f11f6e1cb4d76 100644 (file)
@@ -673,7 +673,7 @@ static void arm_smmu_tlb_inv_context(struct arm_smmu_domain_cfg *cfg)
 
 static void arm_smmu_iotlb_flush_all(struct domain *d)
 {
-    struct arm_smmu_domain *smmu_domain = domain_hvm_iommu(d)->arch.priv;
+    struct arm_smmu_domain *smmu_domain = dom_iommu(d)->arch.priv;
     struct arm_smmu_domain_cfg *cfg;
 
     spin_lock(&smmu_domain->lock);
@@ -1030,7 +1030,7 @@ arm_smmu_alloc_domain_context(struct domain *d,
     unsigned int irq;
     int ret, start;
     struct arm_smmu_domain_cfg *cfg;
-    struct arm_smmu_domain *smmu_domain = domain_hvm_iommu(d)->arch.priv;
+    struct arm_smmu_domain *smmu_domain = dom_iommu(d)->arch.priv;
 
     ASSERT(spin_is_locked(&smmu_domain->lock));
 
@@ -1092,7 +1092,7 @@ out_free_mem:
 static void arm_smmu_destroy_domain_context(struct arm_smmu_domain_cfg *cfg)
 {
     struct domain *d = cfg->domain;
-    struct arm_smmu_domain *smmu_domain = domain_hvm_iommu(d)->arch.priv;
+    struct arm_smmu_domain *smmu_domain = dom_iommu(d)->arch.priv;
     struct arm_smmu_device *smmu = cfg->smmu;
     void __iomem *cb_base;
     unsigned int irq;
@@ -1140,7 +1140,7 @@ static int arm_smmu_attach_dev(struct domain *d,
 {
     struct arm_smmu_device *smmu = arm_smmu_find_smmu_by_dev(dev);
     struct arm_smmu_master *master;
-    struct arm_smmu_domain *smmu_domain = domain_hvm_iommu(d)->arch.priv;
+    struct arm_smmu_domain *smmu_domain = dom_iommu(d)->arch.priv;
     struct arm_smmu_domain_cfg *cfg = NULL;
     struct arm_smmu_domain_cfg *curr;
     int ret;
@@ -1200,7 +1200,7 @@ static int arm_smmu_attach_dev(struct domain *d,
 static int arm_smmu_detach_dev(struct domain *d,
                                const struct dt_device_node *dev)
 {
-    struct arm_smmu_domain *smmu_domain = domain_hvm_iommu(d)->arch.priv;
+    struct arm_smmu_domain *smmu_domain = dom_iommu(d)->arch.priv;
     struct arm_smmu_master *master;
     struct arm_smmu_device *smmu = arm_smmu_find_smmu_by_dev(dev);
     struct arm_smmu_domain_cfg *cfg;
@@ -1519,7 +1519,7 @@ static int arm_smmu_iommu_domain_init(struct domain *d)
     spin_lock_init(&smmu_domain->lock);
     INIT_LIST_HEAD(&smmu_domain->contexts);
 
-    domain_hvm_iommu(d)->arch.priv = smmu_domain;
+    dom_iommu(d)->arch.priv = smmu_domain;
 
     return 0;
 }
@@ -1530,7 +1530,7 @@ static void __hwdom_init arm_smmu_iommu_hwdom_init(struct domain *d)
 
 static void arm_smmu_iommu_domain_teardown(struct domain *d)
 {
-    struct arm_smmu_domain *smmu_domain = domain_hvm_iommu(d)->arch.priv;
+    struct arm_smmu_domain *smmu_domain = dom_iommu(d)->arch.priv;
 
     ASSERT(list_empty(&smmu_domain->contexts));
     xfree(smmu_domain);
index 3e47df54444e9b45f96895270d08255783a937e7..76bd266bef5fece248996b6607b923e2b0bf7360 100644 (file)
@@ -28,7 +28,7 @@ static spinlock_t dtdevs_lock = SPIN_LOCK_UNLOCKED;
 int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev)
 {
     int rc = -EBUSY;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
 
     if ( !iommu_enabled || !hd->platform_ops )
         return -EINVAL;
@@ -57,7 +57,7 @@ fail:
 
 int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
     int rc;
 
     if ( !iommu_enabled || !hd->platform_ops )
@@ -75,7 +75,7 @@ int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev)
     list_del(&dev->domain_list);
 
     dt_device_set_used_by(dev, hardware_domain->domain_id);
-    list_add(&dev->domain_list, &domain_hvm_iommu(hardware_domain)->dt_devices);
+    list_add(&dev->domain_list, &dom_iommu(hardware_domain)->dt_devices);
 
 fail:
     spin_unlock(&dtdevs_lock);
@@ -85,16 +85,14 @@ fail:
 
 int iommu_dt_domain_init(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
-
-    INIT_LIST_HEAD(&hd->dt_devices);
+    INIT_LIST_HEAD(&dom_iommu(d)->dt_devices);
 
     return 0;
 }
 
 void iommu_dt_domain_destroy(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
     struct dt_device_node *dev, *_dev;
     int rc;
 
index 4cd32b5985663a05ff54173eedb9a5652635a720..aa3e4b1607ea11809d57b8b1618a726324a292b4 100644 (file)
@@ -22,7 +22,6 @@
 #include <xen/iommu.h>
 #include <xen/irq.h>
 #include <asm/hvm/irq.h>
-#include <asm/hvm/iommu.h>
 #include <asm/hvm/support.h>
 #include <xen/hvm/irq.h>
 #include <xen/tasklet.h>
index db56aa6272b1ee1d8fe85dcfaf5d47af9a90b642..330f443413789fe10b40a25c5e98c37f4e213c10 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <xen/sched.h>
 #include <xen/iommu.h>
-#include <asm/hvm/iommu.h>
 #include <xen/paging.h>
 #include <xen/guest_access.h>
 #include <xen/event.h>
@@ -116,7 +115,7 @@ static void __init parse_iommu_param(char *s)
 
 int iommu_domain_init(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
     int ret = 0;
 
     ret = arch_iommu_domain_init(d);
@@ -146,7 +145,7 @@ static void __hwdom_init check_hwdom_reqs(struct domain *d)
 
 void __hwdom_init iommu_hwdom_init(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
 
     check_hwdom_reqs(d);
 
@@ -180,7 +179,7 @@ void __hwdom_init iommu_hwdom_init(struct domain *d)
 
 void iommu_teardown(struct domain *d)
 {
-    const struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
 
     d->need_iommu = 0;
     hd->platform_ops->teardown(d);
@@ -189,9 +188,7 @@ void iommu_teardown(struct domain *d)
 
 void iommu_domain_destroy(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
-
-    if ( !iommu_enabled || !hd->platform_ops )
+    if ( !iommu_enabled || !dom_iommu(d)->platform_ops )
         return;
 
     if ( need_iommu(d) )
@@ -203,7 +200,7 @@ void iommu_domain_destroy(struct domain *d)
 int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn,
                    unsigned int flags)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
 
     if ( !iommu_enabled || !hd->platform_ops )
         return 0;
@@ -213,7 +210,7 @@ int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn,
 
 int iommu_unmap_page(struct domain *d, unsigned long gfn)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
 
     if ( !iommu_enabled || !hd->platform_ops )
         return 0;
@@ -240,7 +237,7 @@ static void iommu_free_pagetables(unsigned long unused)
 
 void iommu_iotlb_flush(struct domain *d, unsigned long gfn, unsigned int page_count)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
 
     if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush )
         return;
@@ -250,7 +247,7 @@ void iommu_iotlb_flush(struct domain *d, unsigned long gfn, unsigned int page_co
 
 void iommu_iotlb_flush_all(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
 
     if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush_all )
         return;
@@ -346,12 +343,10 @@ void iommu_crash_shutdown(void)
 
 bool_t iommu_has_feature(struct domain *d, enum iommu_feature feature)
 {
-    const struct hvm_iommu *hd = domain_hvm_iommu(d);
-
     if ( !iommu_enabled )
         return 0;
 
-    return test_bit(feature, hd->features);
+    return test_bit(feature, dom_iommu(d)->features);
 }
 
 static void iommu_dump_p2m_table(unsigned char key)
index 1eba8332c4da1187fe6b5bfa67b578e11874892e..1e7a46c7a2a9f30b8b8114048d0793b544253680 100644 (file)
@@ -22,7 +22,6 @@
 #include <xen/prefetch.h>
 #include <xen/iommu.h>
 #include <xen/irq.h>
-#include <asm/hvm/iommu.h>
 #include <asm/hvm/irq.h>
 #include <xen/delay.h>
 #include <xen/keyhandler.h>
@@ -1228,7 +1227,7 @@ void iommu_read_msi_from_ire(
 
 int iommu_add_device(struct pci_dev *pdev)
 {
-    struct hvm_iommu *hd;
+    const struct domain_iommu *hd;
     int rc;
     u8 devfn;
 
@@ -1237,7 +1236,7 @@ int iommu_add_device(struct pci_dev *pdev)
 
     ASSERT(spin_is_locked(&pcidevs_lock));
 
-    hd = domain_hvm_iommu(pdev->domain);
+    hd = dom_iommu(pdev->domain);
     if ( !iommu_enabled || !hd->platform_ops )
         return 0;
 
@@ -1259,14 +1258,14 @@ int iommu_add_device(struct pci_dev *pdev)
 
 int iommu_enable_device(struct pci_dev *pdev)
 {
-    struct hvm_iommu *hd;
+    const struct domain_iommu *hd;
 
     if ( !pdev->domain )
         return -EINVAL;
 
     ASSERT(spin_is_locked(&pcidevs_lock));
 
-    hd = domain_hvm_iommu(pdev->domain);
+    hd = dom_iommu(pdev->domain);
     if ( !iommu_enabled || !hd->platform_ops ||
          !hd->platform_ops->enable_device )
         return 0;
@@ -1276,13 +1275,13 @@ int iommu_enable_device(struct pci_dev *pdev)
 
 int iommu_remove_device(struct pci_dev *pdev)
 {
-    struct hvm_iommu *hd;
+    const struct domain_iommu *hd;
     u8 devfn;
 
     if ( !pdev->domain )
         return -EINVAL;
 
-    hd = domain_hvm_iommu(pdev->domain);
+    hd = dom_iommu(pdev->domain);
     if ( !iommu_enabled || !hd->platform_ops )
         return 0;
 
@@ -1322,7 +1321,7 @@ static int device_assigned(u16 seg, u8 bus, u8 devfn)
 
 static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
     struct pci_dev *pdev;
     int rc = 0;
 
@@ -1389,7 +1388,7 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn)
 /* caller should hold the pcidevs_lock */
 int deassign_device(struct domain *d, u16 seg, u8 bus, u8 devfn)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
     struct pci_dev *pdev = NULL;
     int ret = 0;
 
@@ -1437,7 +1436,7 @@ static int iommu_get_device_group(
     struct domain *d, u16 seg, u8 bus, u8 devfn,
     XEN_GUEST_HANDLE_64(uint32) buf, int max_sdevs)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
     struct pci_dev *pdev;
     int group_id, sdev_id;
     u32 bdf;
index 03336865bb20f68f634736c2cf64cd6957273656..ce58456705cee12cd3014128fbea0e22681ff7c2 100644 (file)
@@ -21,7 +21,6 @@
 #include <xen/irq.h>
 #include <xen/sched.h>
 #include <xen/iommu.h>
-#include <asm/hvm/iommu.h>
 #include <xen/time.h>
 #include <xen/list.h>
 #include <xen/pci.h>
index c08533925a3a8860d29f67a63b32ff340e9bb061..52b9948655b46525f38cf4e458059ead6f84c654 100644 (file)
@@ -25,7 +25,6 @@
 #include <xen/domain_page.h>
 #include <xen/iocap.h>
 #include <xen/iommu.h>
-#include <asm/hvm/iommu.h>
 #include <xen/numa.h>
 #include <xen/softirq.h>
 #include <xen/time.h>
@@ -253,7 +252,7 @@ static u64 addr_to_dma_page_maddr(struct domain *domain, u64 addr, int alloc)
 {
     struct acpi_drhd_unit *drhd;
     struct pci_dev *pdev;
-    struct hvm_iommu *hd = domain_hvm_iommu(domain);
+    struct domain_iommu *hd = dom_iommu(domain);
     int addr_width = agaw_to_width(hd->arch.agaw);
     struct dma_pte *parent, *pte = NULL;
     int level = agaw_to_level(hd->arch.agaw);
@@ -561,7 +560,7 @@ static void iommu_flush_all(void)
 static void __intel_iommu_iotlb_flush(struct domain *d, unsigned long gfn,
         int dma_old_pte_present, unsigned int page_count)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
     struct acpi_drhd_unit *drhd;
     struct iommu *iommu;
     int flush_dev_iotlb;
@@ -612,7 +611,7 @@ static void intel_iommu_iotlb_flush_all(struct domain *d)
 /* clear one page's page table */
 static void dma_pte_clear_one(struct domain *domain, u64 addr)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(domain);
+    struct domain_iommu *hd = dom_iommu(domain);
     struct dma_pte *page = NULL, *pte = NULL;
     u64 pg_maddr;
 
@@ -1245,9 +1244,7 @@ void __init iommu_free(struct acpi_drhd_unit *drhd)
 
 static int intel_iommu_domain_init(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
-
-    hd->arch.agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH);
+    dom_iommu(d)->arch.agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH);
 
     return 0;
 }
@@ -1281,7 +1278,7 @@ int domain_context_mapping_one(
     struct iommu *iommu,
     u8 bus, u8 devfn, const struct pci_dev *pdev)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(domain);
+    struct domain_iommu *hd = dom_iommu(domain);
     struct context_entry *context, *context_entries;
     u64 maddr, pgd_maddr;
     u16 seg = iommu->intel->drhd->segment;
@@ -1651,10 +1648,9 @@ static int domain_context_unmap(
 
     if ( found == 0 )
     {
-        struct hvm_iommu *hd = domain_hvm_iommu(domain);
         int iommu_domid;
 
-        clear_bit(iommu->index, &hd->arch.iommu_bitmap);
+        clear_bit(iommu->index, &dom_iommu(domain)->arch.iommu_bitmap);
 
         iommu_domid = domain_iommu_domid(domain, iommu);
         if ( iommu_domid == -1 )
@@ -1673,7 +1669,7 @@ out:
 
 static void iommu_domain_teardown(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
     struct mapped_rmrr *mrmrr, *tmp;
 
     if ( list_empty(&acpi_drhd_units) )
@@ -1698,7 +1694,7 @@ static int intel_iommu_map_page(
     struct domain *d, unsigned long gfn, unsigned long mfn,
     unsigned int flags)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
     struct dma_pte *page = NULL, *pte = NULL, old, new = { 0 };
     u64 pg_maddr;
 
@@ -1764,7 +1760,7 @@ void iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte,
 {
     struct acpi_drhd_unit *drhd;
     struct iommu *iommu = NULL;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
     int flush_dev_iotlb;
     int iommu_domid;
 
@@ -1805,7 +1801,6 @@ static int __init vtd_ept_page_compatible(struct iommu *iommu)
  */
 static void iommu_set_pgd(struct domain *d)
 {
-    struct hvm_iommu *hd  = domain_hvm_iommu(d);
     mfn_t pgd_mfn;
 
     ASSERT( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled );
@@ -1814,7 +1809,8 @@ static void iommu_set_pgd(struct domain *d)
         return;
 
     pgd_mfn = pagetable_get_mfn(p2m_get_pagetable(p2m_get_hostp2m(d)));
-    hd->arch.pgd_maddr = pagetable_get_paddr(pagetable_from_mfn(pgd_mfn));
+    dom_iommu(d)->arch.pgd_maddr =
+        pagetable_get_paddr(pagetable_from_mfn(pgd_mfn));
 }
 
 static int rmrr_identity_mapping(struct domain *d, bool_t map,
@@ -1823,7 +1819,7 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map,
     unsigned long base_pfn = rmrr->base_address >> PAGE_SHIFT_4K;
     unsigned long end_pfn = PAGE_ALIGN_4K(rmrr->end_address) >> PAGE_SHIFT_4K;
     struct mapped_rmrr *mrmrr;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
 
     ASSERT(spin_is_locked(&pcidevs_lock));
     ASSERT(rmrr->base_address < rmrr->end_address);
@@ -2470,12 +2466,12 @@ static void vtd_dump_p2m_table_level(paddr_t pt_maddr, int level, paddr_t gpa,
 
 static void vtd_dump_p2m_table(struct domain *d)
 {
-    struct hvm_iommu *hd;
+    const struct domain_iommu *hd;
 
     if ( list_empty(&acpi_drhd_units) )
         return;
 
-    hd = domain_hvm_iommu(d);
+    hd = dom_iommu(d);
     printk("p2m table has %d levels\n", agaw_to_level(hd->arch.agaw));
     vtd_dump_p2m_table_level(hd->arch.pgd_maddr, agaw_to_level(hd->arch.agaw), 0, 0);
 }
index 87b4d97a854a17a4cd59c58ca85d65cfa0feb276..3f08e911810cf01e4a81f91206a110b76c15fdbc 100644 (file)
@@ -22,7 +22,6 @@
 #include <xen/xmalloc.h>
 #include <xen/domain_page.h>
 #include <xen/iommu.h>
-#include <asm/hvm/iommu.h>
 #include <xen/numa.h>
 #include <xen/softirq.h>
 #include <xen/time.h>
index ce0ca5aa39a9de25bc3ebcf16efbd91f86376de4..b8fd2a5c5abf3a4d630a96ffe69c8a6f37923a6a 100644 (file)
@@ -42,7 +42,7 @@ int __init iommu_setup_hpet_msi(struct msi_desc *msi)
 
 int arch_iommu_populate_page_table(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
     struct page_info *page;
     int rc = 0, n = 0;
 
@@ -112,7 +112,7 @@ void __hwdom_init arch_iommu_check_autotranslated_hwdom(struct domain *d)
 
 int arch_iommu_domain_init(struct domain *d)
 {
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct domain_iommu *hd = dom_iommu(d);
 
     spin_lock_init(&hd->arch.mapping_lock);
     INIT_LIST_HEAD(&hd->arch.g2m_ioport_list);
@@ -123,7 +123,7 @@ int arch_iommu_domain_init(struct domain *d)
 
 void arch_iommu_domain_destroy(struct domain *d)
 {
-    struct hvm_iommu *hd  = domain_hvm_iommu(d);
+    const struct domain_iommu *hd = dom_iommu(d);
     struct list_head *ioport_list, *tmp;
     struct g2m_ioport *ioport;
 
index 8b7dd852741991b0a41db3e215b0b1fa5ea4f91a..00c45b0221afb91611d0b8a3e985176d1b673bf2 100644 (file)
 #include <asm/gic.h>
 #include <public/hvm/params.h>
 #include <xen/serial.h>
-#include <xen/hvm/iommu.h>
 
 struct hvm_domain
 {
     uint64_t              params[HVM_NR_PARAMS];
-    struct hvm_iommu      iommu;
 }  __cacheline_aligned;
 
 #ifdef CONFIG_ARM_64
diff --git a/xen/include/asm-arm/hvm/iommu.h b/xen/include/asm-arm/hvm/iommu.h
deleted file mode 100644 (file)
index 461c8cf..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __ASM_ARM_HVM_IOMMU_H_
-#define __ASM_ARM_HVM_IOMMU_H_
-
-struct arch_hvm_iommu
-{
-    /* Private information for the IOMMU drivers */
-    void *priv;
-};
-
-#endif /* __ASM_ARM_HVM_IOMMU_H_ */
index 9322f083a5925b2e710d78d62e76fb26f301a61b..2ad0a6b5497c153d8970ecb80f56c9b1464ebc9c 100644 (file)
 #ifndef __ARCH_ARM_IOMMU_H__
 #define __ARCH_ARM_IOMMU_H__
 
+struct arch_iommu
+{
+    /* Private information for the IOMMU drivers */
+    void *priv;
+};
+
 /* Always share P2M Table between the CPU and the IOMMU */
 #define iommu_use_hap_pt(d) (1)
-#define domain_hvm_iommu(d) (&d->arch.hvm_domain.iommu)
 
 const struct iommu_ops *iommu_get_ops(void);
 void __init iommu_set_ops(const struct iommu_ops *ops);
index 0702bf5aa8db33cc37a045078c4b333551bbd58d..f1a56a07b317851efca209bf209a7f0431237826 100644 (file)
@@ -27,7 +27,6 @@
 #include <asm/hvm/vlapic.h>
 #include <asm/hvm/vioapic.h>
 #include <asm/hvm/io.h>
-#include <xen/hvm/iommu.h>
 #include <asm/hvm/viridian.h>
 #include <asm/hvm/vmx/vmcs.h>
 #include <asm/hvm/svm/vmcb.h>
@@ -122,9 +121,6 @@ struct hvm_domain {
     spinlock_t             uc_lock;
     bool_t                 is_in_uc_mode;
 
-    /* Pass-through */
-    struct hvm_iommu       hvm_iommu;
-
     /* hypervisor intercepted msix table */
     struct list_head       msixtbl_list;
     spinlock_t             msixtbl_list_lock;
index 46cb12605493e69e2c5754698037cc29e2604447..c6c03378f697bc4579ec94e1e2ce5b5fd5944926 100644 (file)
@@ -46,7 +46,7 @@ struct g2m_ioport {
     unsigned int np;
 };
 
-struct arch_hvm_iommu
+struct arch_iommu
 {
     u64 pgd_maddr;                 /* io page directory machine address */
     spinlock_t mapping_lock;            /* io page table lock */
index e7a65da71a141d91f0ffcc694750dcc05b7a459d..e8e450b3db0351368db5b9129a407904175ea9a8 100644 (file)
 #ifndef __ARCH_X86_IOMMU_H__
 #define __ARCH_X86_IOMMU_H__
 
+#include <asm/hvm/iommu.h> /* For now - should really be merged here. */
+
 #define MAX_IOMMUS 32
 
 /* Does this domain have a P2M table we can use as its IOMMU pagetable? */
 #define iommu_use_hap_pt(d) (hap_enabled(d) && iommu_hap_pt_share)
-#define domain_hvm_iommu(d)     (&d->arch.hvm_domain.hvm_iommu)
 
 void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);
 unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
diff --git a/xen/include/xen/hvm/iommu.h b/xen/include/xen/hvm/iommu.h
deleted file mode 100644 (file)
index 693346c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2006, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Copyright (C) Allen Kay <allen.m.kay@intel.com>
- */
-
-#ifndef __XEN_HVM_IOMMU_H__
-#define __XEN_HVM_IOMMU_H__
-
-#include <xen/iommu.h>
-#include <xen/list.h>
-#include <asm/hvm/iommu.h>
-
-struct hvm_iommu {
-    struct arch_hvm_iommu arch;
-
-    /* iommu_ops */
-    const struct iommu_ops *platform_ops;
-
-#ifdef HAS_DEVICE_TREE
-    /* List of DT devices assigned to this domain */
-    struct list_head dt_devices;
-#endif
-
-    /* Features supported by the IOMMU */
-    DECLARE_BITMAP(features, IOMMU_FEAT_count);
-};
-
-#define iommu_set_feature(d, f)   set_bit((f), domain_hvm_iommu(d)->features)
-#define iommu_clear_feature(d, f) clear_bit((f), domain_hvm_iommu(d)->features)
-
-#endif /* __XEN_HVM_IOMMU_H__ */
index 8eb764a001c2f6ed3e1db824022fd456dc07daee..3079cdbb5efe51006292bb7cd2e5e1e7d06f99da 100644 (file)
@@ -84,6 +84,24 @@ enum iommu_feature
 
 bool_t iommu_has_feature(struct domain *d, enum iommu_feature feature);
 
+struct domain_iommu {
+    struct arch_iommu arch;
+
+    /* iommu_ops */
+    const struct iommu_ops *platform_ops;
+
+#ifdef HAS_DEVICE_TREE
+    /* List of DT devices assigned to this domain */
+    struct list_head dt_devices;
+#endif
+
+    /* Features supported by the IOMMU */
+    DECLARE_BITMAP(features, IOMMU_FEAT_count);
+};
+
+#define dom_iommu(d)              (&(d)->iommu)
+#define iommu_set_feature(d, f)   set_bit(f, dom_iommu(d)->features)
+#define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features)
 
 #ifdef HAS_PCI
 void pt_pci_init(void);
index 46fc6e3eff5bbb3242696f8df3093e3a36d3b55c..e799a16e35e0532f1424346098cbb3296a8bb4d9 100644 (file)
@@ -8,6 +8,7 @@
 #include <xen/timer.h>
 #include <xen/rangeset.h>
 #include <xen/domain.h>
+#include <xen/iommu.h>
 #include <xen/rcupdate.h>
 #include <xen/cpumask.h>
 #include <xen/nodemask.h>
@@ -357,6 +358,8 @@ struct domain
     enum guest_type guest_type;
 
 #ifdef HAS_PASSTHROUGH
+    struct domain_iommu iommu;
+
     /* Does this guest need iommu mappings (-1 meaning "being set up")? */
     s8               need_iommu;
 #endif