Skip to contentSkip to conversation

IOMMU support for ARM

PATCH Superseded Julien Grall 3 participants 30 messages May 13, 2014 – May 14, 2014

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v5 cover IOMMU support for ARM

Hello,

This is the fifth version of this patch series to add support for IOMMU on ARM. It also adds driver to support ARM SMMU which is used for instance on Midway.

The ARM IOMMU architecture assumes that the page table is shared between the processor and each IOMMU.

Major changes in v5:
- A bunch of patch from the previous version has been pushed upstream
- Drop protected-devices patch [1] as it's not needed
- Add flush_tlb_domain helper
- Rework "Clean cache PT ..." to only flush by small item

For all the other changes see in each patch.

This series also depends on the interrupt reworking serie [2].

A working tree can be found here:
git://xenbits.xen.org/people/julieng/xen-unstable.git branch ssmu-v5

Sincerely yours,

[1] https://patches.linaro.org/28811/
[2] http://lists.xen.org/archives/html/xen-devel/2014-05/msg01523.html

Julien Grall (14):
xen/arm: Introduce flush_tlb_domain
xen/passthrough: amd: Remove domain_id from hvm_iommu xen/passthrough: amd: rename iommu_has_feature into
amd_iommu_has_feature
xen/passthrough: vtd: iommu_set_hwdom_mapping is VTD specific xen/passthrough: rework hwdom_pvh_reqs to use it also on ARM xen/passthrough: iommu: Split generic IOMMU code xen/passthrough: iommu: Introduce arch specific code xen/passthrough: iommu: Basic support of device tree assignment xen/passthrough: Introduce IOMMU ARM architecture
MAINTAINERS: Add drivers/passthrough/arm
xen/arm: Don't give IOMMU devices to dom0 when iommu is disabled xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent
walk
xen/arm: grant: Add another entry to map MFN 1:1 in dom0 p2m drivers/passthrough: arm: Add support for SMMU drivers

 MAINTAINERS                                   |    2 +
 xen/arch/arm/Rules.mk                         |    1 +
 xen/arch/arm/device.c                         |   15 +
 xen/arch/arm/domain.c                         |    7 +
 xen/arch/arm/domain_build.c                   |   30 +-
 xen/arch/arm/mm.c                             |   33 +-
 xen/arch/arm/p2m.c                            |   71 +-
 xen/arch/arm/setup.c                          |    2 +
 xen/arch/x86/domctl.c                         |    6 +-
 xen/arch/x86/hvm/io.c                         |    2 +-
 xen/arch/x86/tboot.c                          |    3 +-
 xen/common/device_tree.c                      |    4 +
 xen/drivers/passthrough/Makefile              |    6 +-
 xen/drivers/passthrough/amd/iommu_cmd.c       |    3 +-
 xen/drivers/passthrough/amd/iommu_detect.c    |    2 +-
 xen/drivers/passthrough/amd/iommu_guest.c     |    8 +-
 xen/drivers/passthrough/amd/iommu_init.c      |   16 +-
 xen/drivers/passthrough/amd/iommu_map.c       |   56 +-
 xen/drivers/passthrough/amd/pci_amd_iommu.c   |   53 +-
 xen/drivers/passthrough/arm/Makefile          |    2 +
 xen/drivers/passthrough/arm/iommu.c           |   70 +
 xen/drivers/passthrough/arm/smmu.c            | 1751 +++++++++++++++++++++++++
 xen/drivers/passthrough/device_tree.c         |  108 ++
 xen/drivers/passthrough/iommu.c               |  516 +-------
 xen/drivers/passthrough/pci.c                 |  387 ++++++
 xen/drivers/passthrough/vtd/extern.h          |    2 +
 xen/drivers/passthrough/vtd/iommu.c           |   76 +-
 xen/drivers/passthrough/vtd/x86/vtd.c         |    2 +-
 xen/drivers/passthrough/x86/Makefile          |    1 +
 xen/drivers/passthrough/x86/iommu.c           |  145 ++
 xen/include/asm-arm/device.h                  |   13 +-
 xen/include/asm-arm/domain.h                  |    2 +
 xen/include/asm-arm/flushtlb.h                |    3 +
 xen/include/asm-arm/hvm/iommu.h               |   10 +
 xen/include/asm-arm/iommu.h                   |   36 +
 xen/include/asm-x86/hvm/iommu.h               |   22 +
 xen/include/asm-x86/hvm/svm/amd-iommu-proto.h |    2 +-
 xen/include/asm-x86/iommu.h                   |   43 +
 xen/include/xen/device_tree.h                 |   14 +
 xen/include/xen/hvm/iommu.h                   |   27 +-
 xen/include/xen/iommu.h                       |   87 +-
 41 files changed, 2961 insertions(+), 678 deletions(-)
 create mode 100644 xen/drivers/passthrough/arm/Makefile
 create mode 100644 xen/drivers/passthrough/arm/iommu.c
 create mode 100644 xen/drivers/passthrough/arm/smmu.c
 create mode 100644 xen/drivers/passthrough/device_tree.c
 create mode 100644 xen/drivers/passthrough/x86/iommu.c
 create mode 100644 xen/include/asm-arm/hvm/iommu.h
 create mode 100644 xen/include/asm-arm/iommu.h
 create mode 100644 xen/include/asm-x86/iommu.h
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v5 1/14 xen/arm: Introduce flush_tlb_domain

The pattern p2m_load_VTTBR(d) -> flush_tlb -> p2m_load_VTTBR(current->domain) is used in few places.

Replace this usage by flush_tlb_domain which will take care of this pattern. This will help to the lisibility of apply_p2m_changes which begin to be big.

---
Changes in v5:
- Patch added

---
 xen/arch/arm/p2m.c             |   35 +++++++++++++++++------------------
 xen/include/asm-arm/flushtlb.h |    3 +++
 2 files changed, 20 insertions(+), 18 deletions(-)
xen/arch/arm/p2m.c +17 -18
index 603c097..61450cf 100644
@@ -72,6 +72,21 @@ void p2m_restore_state(struct vcpu *n)
     isb();
 }
 
+void flush_tlb_domain(struct domain *d)
+{
+    /* Update the VTTBR if necessary with the domain d. In this case,
+     * it's only necessary to flush TLBs on every CPUs with the current VMID
+     * (our domain).
+     */
+    if ( d != current->domain )
+        p2m_load_VTTBR(d);
+
+    flush_tlb();
+
+    if ( d != current->domain )
+        p2m_load_VTTBR(current->domain);
+}
+
 static int p2m_first_level_index(paddr_t addr)
 {
     /*
@@ -450,19 +465,7 @@ static int apply_p2m_changes(struct domain *d,
     }
 
     if ( flush )
-    {
-        /* Update the VTTBR if necessary with the domain where mappings
-         * are created. In this case it's only necessary to flush TLBs
-         * on every CPUs with the current VMID (our domain).
-         */
-        if ( d != current->domain )
-            p2m_load_VTTBR(d);
-
-        flush_tlb();
-
-        if ( d != current->domain )
-            p2m_load_VTTBR(current->domain);
-    }
+        flush_tlb_domain(d);
 
     if ( op == ALLOCATE || op == INSERT )
     {
@@ -550,14 +553,10 @@ int p2m_alloc_table(struct domain *d)
     d->arch.vttbr = page_to_maddr(p2m->first_level)
         | ((uint64_t)p2m->vmid&0xff)<<48;
 
-    p2m_load_VTTBR(d);
-
     /* Make sure that all TLBs corresponding to the new VMID are flushed
      * before using it
      */
-    flush_tlb();
-
-    p2m_load_VTTBR(current->domain);
+    flush_tlb_domain(d);
 
     spin_unlock(&p2m->lock);
 
xen/include/asm-arm/flushtlb.h +3 -0
index 329fbb4..5722c67 100644
@@ -25,6 +25,9 @@ do {                                                                    \
 /* Flush specified CPUs' TLBs */
 void flush_tlb_mask(const cpumask_t *mask);
 
+/* Flush CPU's TLBs for the speficied domain */
+void flush_tlb_domain(struct domain *d);
+
 #endif /* __ASM_ARM_FLUSHTLB_H__ */
 /*
  * Local variables:
Signature · 1 line
1.7.10.4
Acked-by on v5 1/14
#2 lore raw

Re: [PATCH v5 01/14] xen/arm: Introduce flush_tlb_domain

Quoted 5 lines · Julien Grall

The pattern p2m_load_VTTBR(d) -> flush_tlb -> p2m_load_VTTBR(current->domain) is used in few places.

Replace this usage by flush_tlb_domain which will take care of this pattern. This will help to the lisibility of apply_p2m_changes which begin to be big.

"lisibility"? Did you mean to type "visibility"? I think the word you really wanted was "readability".

xen/include/asm-arm/flushtlb.h do { \ · line 28

Quoted 9 lines
xen/include/asm-arm/flushtlb.h +1 -0
index 329fbb4..5722c67 100644
@@ -25,6 +25,9 @@ do {                                                                    \
 /* Flush specified CPUs' TLBs */
 void flush_tlb_mask(const cpumask_t *mask);
 
+/* Flush CPU's TLBs for the speficied domain */

"Specified"

Other than those two nits:

If you can confirm what you meant by "lisibility" I can probably fixup both on commit.

Quoted 5 lines
xen/include/asm-arm/flushtlb.h +2 -0
+void flush_tlb_domain(struct domain *d);
+
 #endif /* __ASM_ARM_FLUSHTLB_H__ */
 /*
  * Local variables:
#3 lore raw

Re: [PATCH v5 01/14] xen/arm: Introduce flush_tlb_domain

Quoted 9 lines · Ian Campbell
Quoted 5 lines · Julien Grall

The pattern p2m_load_VTTBR(d) -> flush_tlb -> p2m_load_VTTBR(current->domain) is used in few places.

Replace this usage by flush_tlb_domain which will take care of this pattern. This will help to the lisibility of apply_p2m_changes which begin to be big.

"lisibility"? Did you mean to type "visibility"? I think the word you really wanted was "readability".

I meant readability. It was a quick & bad translation from French.

Quoted 8 lines
Quoted 8 lines
xen/include/asm-arm/flushtlb.h +0 -0
index 329fbb4..5722c67 100644
@@ -25,6 +25,9 @@ do {                                                                    \
 /* Flush specified CPUs' TLBs */
 void flush_tlb_mask(const cpumask_t *mask);
 
Quoted 6 lines

xen/include/asm-arm/flushtlb.h do { \ · line 28

Quoted 1 line
xen/include/asm-arm/flushtlb.h +1 -0
+/* Flush CPU's TLBs for the speficied domain */

"Specified"

Other than those two nits:

Thanks!

Signature · 1 line
Julien Grall
#4 lore raw

PATCH v5 2/14 xen/passthrough: amd: Remove domain_id from hvm_iommu

In reply to Julien Grall

The structure hvm_iommu contains a shadow value of domain->domain_id. There is no reason to not directly use domain->domain_id.

---
Changes in v3:
- Patch added

---
 xen/drivers/passthrough/amd/iommu_cmd.c     |    3 +--
 xen/drivers/passthrough/amd/iommu_map.c     |    2 +-
 xen/drivers/passthrough/amd/pci_amd_iommu.c |    8 +++-----
 xen/include/xen/hvm/iommu.h                 |    1 -
 4 files changed, 5 insertions(+), 9 deletions(-)
xen/drivers/passthrough/amd/iommu_cmd.c +1 -2
index d27bd3c..4faa01b 100644
@@ -354,8 +354,7 @@ static void _amd_iommu_flush_pages(struct domain *d,
 {
     unsigned long flags;
     struct amd_iommu *iommu;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
-    unsigned int dom_id = hd->domain_id;
+    unsigned int dom_id = d->domain_id;
 
     /* send INVALIDATE_IOMMU_PAGES command */
     for_each_amd_iommu ( iommu )
xen/drivers/passthrough/amd/iommu_map.c +1 -1
index 1294561..b79e470 100644
@@ -614,7 +614,7 @@ static int update_paging_mode(struct domain *d, unsigned long gfn)
                 /* valid = 0 only works for dom0 passthrough mode */
                 amd_iommu_set_root_page_table((u32 *)device_entry,
                                               page_to_maddr(hd->root_table),
-                                              hd->domain_id,
+                                              d->domain_id,
                                               hd->paging_mode, 1);
 
                 amd_iommu_flush_device(iommu, req_id);
xen/drivers/passthrough/amd/pci_amd_iommu.c +3 -5
index 366c750..51b75fc 100644
@@ -138,7 +138,7 @@ static void amd_iommu_setup_domain_device(
     {
         /* bind DTE to domain page-tables */
         amd_iommu_set_root_page_table(
-            (u32 *)dte, page_to_maddr(hd->root_table), hd->domain_id,
+            (u32 *)dte, page_to_maddr(hd->root_table), domain->domain_id,
             hd->paging_mode, valid);
 
         if ( pci_ats_device(iommu->seg, bus, pdev->devfn) &&
@@ -152,7 +152,7 @@ static void amd_iommu_setup_domain_device(
                         "domain = %d, paging mode = %d\n",
                         req_id, pdev->type,
                         page_to_maddr(hd->root_table),
-                        hd->domain_id, hd->paging_mode);
+                        domain->domain_id, hd->paging_mode);
     }
 
     spin_unlock_irqrestore(&iommu->lock, flags);
@@ -274,8 +274,6 @@ static int amd_iommu_domain_init(struct domain *d)
                       IOMMU_PAGING_MODE_LEVEL_2 :
                       get_paging_mode(max_page);
 
-    hd->domain_id = d->domain_id;
-
     guest_iommu_init(d);
 
     return 0;
@@ -334,7 +332,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_hvm_iommu(domain)->domain_id,
+                        req_id,  domain->domain_id,
                         domain_hvm_iommu(domain)->paging_mode);
     }
     spin_unlock_irqrestore(&iommu->lock, flags);
xen/include/xen/hvm/iommu.h +0 -1
index 8c98274..dc9c766 100644
@@ -38,7 +38,6 @@ struct hvm_iommu {
     struct list_head mapped_rmrrs;
 
     /* amd iommu support */
-    int domain_id;
     int paging_mode;
     struct page_info *root_table;
     struct guest_iommu *g_iommu;
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH v5 3/14 xen/passthrough: amd: rename iommu_has_feature into amd_iommu_has_feature

In reply to Julien Grall

This function is AMD specific and the name will clash with a newly function added in the IOMMU framework.

---
 xen/drivers/passthrough/amd/iommu_detect.c    |    2 +-
 xen/drivers/passthrough/amd/iommu_init.c      |   16 ++++++++--------
 xen/include/asm-x86/hvm/svm/amd-iommu-proto.h |    2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)
xen/drivers/passthrough/amd/iommu_detect.c +1 -1
index be1b761..98e5cc2 100644
@@ -95,7 +95,7 @@ void __init get_iommu_features(struct amd_iommu *iommu)
 
     while ( feature_str[i] )
     {
-        if ( iommu_has_feature(iommu, i) )
+        if ( amd_iommu_has_feature(iommu, i) )
             printk( " %s\n", feature_str[i]);
         i++;
     }
xen/drivers/passthrough/amd/iommu_init.c +8 -8
index 6ae44d9..b2f74ef 100644
@@ -884,7 +884,7 @@ static void enable_iommu(struct amd_iommu *iommu)
     register_iommu_event_log_in_mmio_space(iommu);
     register_iommu_exclusion_range(iommu);
 
-    if ( iommu_has_feature(iommu, IOMMU_EXT_FEATURE_PPRSUP_SHIFT) )
+    if ( amd_iommu_has_feature(iommu, IOMMU_EXT_FEATURE_PPRSUP_SHIFT) )
         register_iommu_ppr_log_in_mmio_space(iommu);
 
     desc = irq_to_desc(iommu->msi.irq);
@@ -898,15 +898,15 @@ static void enable_iommu(struct amd_iommu *iommu)
     set_iommu_command_buffer_control(iommu, IOMMU_CONTROL_ENABLED);
     set_iommu_event_log_control(iommu, IOMMU_CONTROL_ENABLED);
 
-    if ( iommu_has_feature(iommu, IOMMU_EXT_FEATURE_PPRSUP_SHIFT) )
+    if ( amd_iommu_has_feature(iommu, IOMMU_EXT_FEATURE_PPRSUP_SHIFT) )
         set_iommu_ppr_log_control(iommu, IOMMU_CONTROL_ENABLED);
 
-    if ( iommu_has_feature(iommu, IOMMU_EXT_FEATURE_GTSUP_SHIFT) )
+    if ( amd_iommu_has_feature(iommu, IOMMU_EXT_FEATURE_GTSUP_SHIFT) )
         set_iommu_guest_translation_control(iommu, IOMMU_CONTROL_ENABLED);
 
     set_iommu_translation_control(iommu, IOMMU_CONTROL_ENABLED);
 
-    if ( iommu_has_feature(iommu, IOMMU_EXT_FEATURE_IASUP_SHIFT) )
+    if ( amd_iommu_has_feature(iommu, IOMMU_EXT_FEATURE_IASUP_SHIFT) )
         amd_iommu_flush_all_caches(iommu);
 
     iommu->enabled = 1;
@@ -1009,7 +1009,7 @@ static int __init amd_iommu_init_one(struct amd_iommu *iommu)
     if ( allocate_event_log(iommu) == NULL )
         goto error_out;
 
-    if ( iommu_has_feature(iommu, IOMMU_EXT_FEATURE_PPRSUP_SHIFT) )
+    if ( amd_iommu_has_feature(iommu, IOMMU_EXT_FEATURE_PPRSUP_SHIFT) )
         if ( allocate_ppr_log(iommu) == NULL )
             goto error_out;
 
@@ -1283,10 +1283,10 @@ static void disable_iommu(struct amd_iommu *iommu)
     set_iommu_command_buffer_control(iommu, IOMMU_CONTROL_DISABLED);
     set_iommu_event_log_control(iommu, IOMMU_CONTROL_DISABLED);
 
-    if ( iommu_has_feature(iommu, IOMMU_EXT_FEATURE_PPRSUP_SHIFT) )
+    if ( amd_iommu_has_feature(iommu, IOMMU_EXT_FEATURE_PPRSUP_SHIFT) )
         set_iommu_ppr_log_control(iommu, IOMMU_CONTROL_DISABLED);
 
-    if ( iommu_has_feature(iommu, IOMMU_EXT_FEATURE_GTSUP_SHIFT) )
+    if ( amd_iommu_has_feature(iommu, IOMMU_EXT_FEATURE_GTSUP_SHIFT) )
         set_iommu_guest_translation_control(iommu, IOMMU_CONTROL_DISABLED);
 
     set_iommu_translation_control(iommu, IOMMU_CONTROL_DISABLED);
@@ -1356,7 +1356,7 @@ void amd_iommu_resume(void)
     }
 
     /* flush all cache entries after iommu re-enabled */
-    if ( !iommu_has_feature(iommu, IOMMU_EXT_FEATURE_IASUP_SHIFT) )
+    if ( !amd_iommu_has_feature(iommu, IOMMU_EXT_FEATURE_IASUP_SHIFT) )
     {
         invalidate_all_devices();
         invalidate_all_domain_pages();
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +1 -1
index b5abc8f..cf43e29 100644
@@ -210,7 +210,7 @@ static inline int iommu_has_cap(struct amd_iommu *iommu, uint32_t bit)
     return !!(iommu->cap.header & (1u << bit));
 }
 
-static inline int iommu_has_feature(struct amd_iommu *iommu, uint32_t bit)
+static inline int amd_iommu_has_feature(struct amd_iommu *iommu, uint32_t bit)
 {
     if ( !iommu_has_cap(iommu, PCI_CAP_EFRSUP_SHIFT) )
         return 0;
Signature · 1 line
1.7.10.4
#6 lore raw

PATCH v5 4/14 xen/passthrough: vtd: iommu_set_hwdom_mapping is VTD specific

In reply to Julien Grall

This function was exported in common header. Rename it and move the declaration in drivers/passtrough/vtd/extern.h

---
Changes in v5:
- Rename iommu_vtd_set_hwdom_mapping into vtd_set_hwdom_mapping

Changes in v4:
- Patch added

---
 xen/drivers/passthrough/vtd/extern.h  |    2 ++
 xen/drivers/passthrough/vtd/iommu.c   |    2 +-
 xen/drivers/passthrough/vtd/x86/vtd.c |    2 +-
 xen/include/xen/iommu.h               |    1 -
 4 files changed, 4 insertions(+), 3 deletions(-)
xen/drivers/passthrough/vtd/extern.h +2 -0
index 14cd90e..8ca1f7e 100644
@@ -103,4 +103,6 @@ void pci_vtd_quirk(struct pci_dev *pdev);
 int platform_supports_intremap(void);
 int platform_supports_x2apic(void);
 
+void vtd_set_hwdom_mapping(struct domain *d);
+
 #endif // _VTD_EXTERN_H_
xen/drivers/passthrough/vtd/iommu.c +1 -1
index c94b0d1..ae9049e 100644
@@ -1249,7 +1249,7 @@ static void __hwdom_init intel_iommu_hwdom_init(struct domain *d)
     if ( !iommu_passthrough && !need_iommu(d) )
     {
         /* Set up 1:1 page table for dom0 */
-        iommu_set_hwdom_mapping(d);
+        vtd_set_hwdom_mapping(d);
     }
 
     setup_hwdom_pci_devices(d, setup_hwdom_device);
xen/drivers/passthrough/vtd/x86/vtd.c +1 -1
index 218e223..9a458eb 100644
@@ -107,7 +107,7 @@ void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq)
     spin_unlock(&d->event_lock);
 }
 
-void __hwdom_init iommu_set_hwdom_mapping(struct domain *d)
+void __hwdom_init vtd_set_hwdom_mapping(struct domain *d)
 {
     unsigned long i, j, tmp, top;
 
xen/include/xen/iommu.h +0 -1
index f8da9f2..1fd8fb9 100644
@@ -127,7 +127,6 @@ void iommu_suspend(void);
 void iommu_resume(void);
 void iommu_crash_shutdown(void);
 
-void iommu_set_hwdom_mapping(struct domain *d);
 void iommu_share_p2m_table(struct domain *d);
 
 int iommu_do_domctl(struct xen_domctl *, struct domain *d,
Signature · 1 line
1.7.10.4
#7 lore raw

PATCH v5 5/14 xen/passthrough: rework hwdom_pvh_reqs to use it also on ARM

In reply to Julien Grall

Hardware domain on ARM will have the same requirements as hwdom PVH when iommu is enabled. Both PVH and ARM guest has paging mode translate enabled, so Xen can use it to know if it needs to check the requirements.

Rename the function and remove "pvh" word in the panic message.

---
Changes in v4:
- Rebase on the latest staging (hwdom series was pushed)
- Remove is_phv_domain bits ... and update the next patch
(should be #7) to create in new function arch_iommu_check_dom0_reqs.
- Update printed message to be more readable
Changes in v2:
- IOMMU can be disabled on ARM if the platform doesn't have IOMMU.

---
 xen/drivers/passthrough/iommu.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
xen/drivers/passthrough/iommu.c +7 -4
index 96a79ce..ccb354d 100644
@@ -130,13 +130,17 @@ int iommu_domain_init(struct domain *d)
     return hd->platform_ops->init(d);
 }
 
-static void __hwdom_init check_hwdom_pvh_reqs(struct domain *d)
+static void __hwdom_init check_hwdom_reqs(struct domain *d)
 {
+    if ( !paging_mode_translate(d) )
+        return;
+
     if ( !iommu_enabled )
         panic("Presently, iommu must be enabled for pvh dom0\n");
 
     if ( iommu_passthrough )
-        panic("For pvh dom0, dom0-passthrough must not be enabled\n");
+        panic("Dom0 uses paging translated mode, dom0-passthrough must not be "
+              "enabled\n");
 
     iommu_dom0_strict = 1;
 }
@@ -145,8 +149,7 @@ void __hwdom_init iommu_hwdom_init(struct domain *d)
 {
     struct hvm_iommu *hd = domain_hvm_iommu(d);
 
-    if ( is_pvh_domain(d) )
-        check_hwdom_pvh_reqs(d);
+    check_hwdom_reqs(d);
 
     if ( !iommu_enabled )
         return;
Signature · 1 line
1.7.10.4
#8 lore raw

PATCH v5 6/14 xen/passthrough: iommu: Split generic IOMMU code

In reply to Julien Grall

The generic IOMMU framework code (xen/drivers/passthrough/iommu.c) contains functions specific to x86 and PCI.

Split the framework in 3 distincts files:
- iommu.c: contains generic functions shared between x86 and ARM (when it will be supported)
- pci.c: contains specific functions for PCI passthrough
- x86/iommu.c: contains specific functions for x86

io.c contains x86 HVM specific code. Only compile for x86.

This patch is mostly code movement in new files.

---
Changes in v5:
- Rename arch_iommu_check_hwdom_reqs into arch_iommu_check_autotranslated_hwdom

Changes in v4:
- Rebase on the latest xen (hwdom series was pushed)
- Move iommu_populate_page_table in x86/iommu.c and rename it arch_iommu_populate_page_table
- Introduce arch_iommu_check_hwdom_reqs which will check if the IOMMU is enabled. On ARM the IOMMU is not required because most of current hardware don't provide IOMMU
- iommu_set_hwdom_mapping has been moved in vdt/extern.h (made by another patch)

Changes in v3:
- share_p2m_table should stay in common code
- update_ire_from_msi and read_msi_from_ire should go in pci code
- remove switch case in iommu_do_domctl

Changes in v2:
- Update commit message
- Removing spurious change in drivers/passthrough/vtd/iommu.c
- Move iommu_x86.c in x86/iommu.c
- Merge iommu_pci.c in pci.c
- Introduce iommu_do_pci_domctl

---
 xen/drivers/passthrough/Makefile     |    4 +-
 xen/drivers/passthrough/iommu.c      |  486 ++--------------------------------
 xen/drivers/passthrough/pci.c        |  387 +++++++++++++++++++++++++++
 xen/drivers/passthrough/x86/Makefile |    1 +
 xen/drivers/passthrough/x86/iommu.c  |  120 +++++++++
 xen/include/asm-x86/iommu.h          |   41 +++
 xen/include/xen/hvm/iommu.h          |    1 +
 xen/include/xen/iommu.h              |   51 ++--
 8 files changed, 596 insertions(+), 495 deletions(-)
 create mode 100644 xen/drivers/passthrough/x86/iommu.c
 create mode 100644 xen/include/asm-x86/iommu.h
xen/drivers/passthrough/Makefile +2 -2
index 7c40fa5..6e08f89 100644
@@ -3,5 +3,5 @@ subdir-$(x86) += amd
 subdir-$(x86_64) += x86
 
 obj-y += iommu.o
-obj-y += io.o
-obj-y += pci.o
+obj-$(x86) += io.o
+obj-$(HAS_PCI) += pci.o
xen/drivers/passthrough/iommu.c +15 -471

536 lines not on this page · raw message

xen/drivers/passthrough/pci.c +387 -0

399 lines not on this page · raw message

xen/drivers/passthrough/x86/Makefile +1 -0
index c124a51..a70cf94 100644
@@ -1 +1,2 @@
 obj-y += ats.o
+obj-y += iommu.o
xen/drivers/passthrough/x86/iommu.c new file +120 -0

120 lines not on this page · raw message

xen/include/asm-x86/iommu.h new file +41 -0

41 lines not on this page · raw message

xen/include/xen/hvm/iommu.h +1 -0
index dc9c766..9b32fa6 100644
@@ -21,6 +21,7 @@
 #define __XEN_HVM_IOMMU_H__
 
 #include <xen/iommu.h>
+#include <asm/hvm/iommu.h>
 
 struct g2m_ioport {
     struct list_head list;
xen/include/xen/iommu.h +29 -22

125 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#9 lore raw

PATCH v5 7/14 xen/passthrough: iommu: Introduce arch specific code

In reply to Julien Grall

Currently the structure hvm_iommu (xen/include/xen/hvm/iommu.h) contains x86 specific fields.

This patch creates:
- arch_hvm_iommu structure which will contain architecture depend fields
- arch_iommu_domain_{init,destroy} function to execute arch specific during domain creation/destruction

Also move iommu_use_hap_pt and domain_hvm_iommu in asm-x86/iommu.h.

---
Changes in v5:
- Remove trailing white space in amd_dump_p2m_table

Changes in v4:
- Rebase on Xen upstream
- Remove spurious iommu_share_p2m_table in passthrough/x86/iommu.c
- Keep the original order in arch_hvm_iommu

---
 xen/arch/x86/domctl.c                       |    6 +--
 xen/arch/x86/hvm/io.c                       |    2 +-
 xen/arch/x86/tboot.c                        |    3 +-
 xen/drivers/passthrough/amd/iommu_guest.c   |    8 +--
 xen/drivers/passthrough/amd/iommu_map.c     |   54 +++++++++----------
 xen/drivers/passthrough/amd/pci_amd_iommu.c |   49 +++++++++---------
 xen/drivers/passthrough/iommu.c             |   18 +++----
 xen/drivers/passthrough/vtd/iommu.c         |   74 +++++++++++++--------------
 xen/drivers/passthrough/x86/iommu.c         |   25 +++++++++
 xen/include/asm-x86/hvm/iommu.h             |   22 ++++++++
 xen/include/asm-x86/iommu.h                 |    4 +-
 xen/include/xen/hvm/iommu.h                 |   19 +------
 xen/include/xen/iommu.h                     |    7 +--
 13 files changed, 158 insertions(+), 133 deletions(-)
xen/arch/x86/domctl.c +3 -3
index ff24e0e..f8b0a79 100644
@@ -752,7 +752,7 @@ long arch_do_domctl(
                    "ioport_map:add: dom%d gport=%x mport=%x nr=%x\n",
                    d->domain_id, fgp, fmp, np);
 
-            list_for_each_entry(g2m_ioport, &hd->g2m_ioport_list, list)
+            list_for_each_entry(g2m_ioport, &hd->arch.g2m_ioport_list, list)
                 if (g2m_ioport->mport == fmp )
                 {
                     g2m_ioport->gport = fgp;
@@ -771,7 +771,7 @@ long arch_do_domctl(
                 g2m_ioport->gport = fgp;
                 g2m_ioport->mport = fmp;
                 g2m_ioport->np = np;
-                list_add_tail(&g2m_ioport->list, &hd->g2m_ioport_list);
+                list_add_tail(&g2m_ioport->list, &hd->arch.g2m_ioport_list);
             }
             if ( !ret )
                 ret = ioports_permit_access(d, fmp, fmp + np - 1);
@@ -786,7 +786,7 @@ long arch_do_domctl(
             printk(XENLOG_G_INFO
                    "ioport_map:remove: dom%d gport=%x mport=%x nr=%x\n",
                    d->domain_id, fgp, fmp, np);
-            list_for_each_entry(g2m_ioport, &hd->g2m_ioport_list, list)
+            list_for_each_entry(g2m_ioport, &hd->arch.g2m_ioport_list, list)
                 if ( g2m_ioport->mport == fmp )
                 {
                     list_del(&g2m_ioport->list);
xen/arch/x86/hvm/io.c +1 -1
index f5ad9be..e6cb5e2 100644
@@ -355,7 +355,7 @@ int dpci_ioport_intercept(ioreq_t *p)
     unsigned int s = 0, e = 0;
     int rc;
 
-    list_for_each_entry( g2m_ioport, &hd->g2m_ioport_list, list )
+    list_for_each_entry( g2m_ioport, &hd->arch.g2m_ioport_list, list )
     {
         s = g2m_ioport->gport;
         e = s + g2m_ioport->np;
xen/arch/x86/tboot.c +2 -1
index 7bebfc0..a8fb3a0 100644
@@ -228,7 +228,8 @@ 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->pgd_maddr, agaw_to_level(hd->agaw));
+            update_iommu_mac(&ctx, hd->arch.pgd_maddr,
+                             agaw_to_level(hd->arch.agaw));
         }
     }
 
xen/drivers/passthrough/amd/iommu_guest.c +4 -4
index f638bef..5660020 100644
@@ -60,12 +60,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)->g_iommu;
+    return domain_hvm_iommu(d)->arch.g_iommu;
 }
 
 static inline struct guest_iommu *vcpu_iommu(struct vcpu *v)
 {
-    return domain_hvm_iommu(v->domain)->g_iommu;
+    return domain_hvm_iommu(v->domain)->arch.g_iommu;
 }
 
 static void guest_iommu_enable(struct guest_iommu *iommu)
@@ -886,7 +886,7 @@ int guest_iommu_init(struct domain* d)
 
     guest_iommu_reg_init(iommu);
     iommu->domain = d;
-    hd->g_iommu = iommu;
+    hd->arch.g_iommu = iommu;
 
     tasklet_init(&iommu->cmd_buffer_tasklet,
                  guest_iommu_process_command, (unsigned long)d);
@@ -907,7 +907,7 @@ void guest_iommu_destroy(struct domain *d)
     tasklet_kill(&iommu->cmd_buffer_tasklet);
     xfree(iommu);
 
-    domain_hvm_iommu(d)->g_iommu = NULL;
+    domain_hvm_iommu(d)->arch.g_iommu = NULL;
 }
 
 static int guest_iommu_mmio_range(struct vcpu *v, unsigned long addr)
xen/drivers/passthrough/amd/iommu_map.c +27 -27

174 lines not on this page · raw message

xen/drivers/passthrough/amd/pci_amd_iommu.c +25 -24

117 lines not on this page · raw message

xen/drivers/passthrough/iommu.c +6 -12
index fa6a2ac..59f1c3e 100644
@@ -117,10 +117,11 @@ static void __init parse_iommu_param(char *s)
 int iommu_domain_init(struct domain *d)
 {
     struct hvm_iommu *hd = domain_hvm_iommu(d);
+    int ret = 0;
 
-    spin_lock_init(&hd->mapping_lock);
-    INIT_LIST_HEAD(&hd->g2m_ioport_list);
-    INIT_LIST_HEAD(&hd->mapped_rmrrs);
+    ret = arch_iommu_domain_init(d);
+    if ( ret )
+        return ret;
 
     if ( !iommu_enabled )
         return 0;
@@ -188,9 +189,7 @@ void iommu_teardown(struct domain *d)
 
 void iommu_domain_destroy(struct domain *d)
 {
-    struct hvm_iommu *hd  = domain_hvm_iommu(d);
-    struct list_head *ioport_list, *tmp;
-    struct g2m_ioport *ioport;
+    struct hvm_iommu *hd = domain_hvm_iommu(d);
 
     if ( !iommu_enabled || !hd->platform_ops )
         return;
@@ -198,12 +197,7 @@ void iommu_domain_destroy(struct domain *d)
     if ( need_iommu(d) )
         iommu_teardown(d);
 
-    list_for_each_safe ( ioport_list, tmp, &hd->g2m_ioport_list )
-    {
-        ioport = list_entry(ioport_list, struct g2m_ioport, list);
-        list_del(&ioport->list);
-        xfree(ioport);
-    }
+    arch_iommu_domain_destroy(d);
 }
 
 int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn,
xen/drivers/passthrough/vtd/iommu.c +37 -37

236 lines not on this page · raw message

xen/drivers/passthrough/x86/iommu.c +25 -0
index 8386754..ce0ca5a 100644
@@ -110,6 +110,31 @@ void __hwdom_init arch_iommu_check_autotranslated_hwdom(struct domain *d)
         panic("Presently, iommu must be enabled for PVH hardware domain\n");
 }
 
+int arch_iommu_domain_init(struct domain *d)
+{
+    struct hvm_iommu *hd = domain_hvm_iommu(d);
+
+    spin_lock_init(&hd->arch.mapping_lock);
+    INIT_LIST_HEAD(&hd->arch.g2m_ioport_list);
+    INIT_LIST_HEAD(&hd->arch.mapped_rmrrs);
+
+    return 0;
+}
+
+void arch_iommu_domain_destroy(struct domain *d)
+{
+    struct hvm_iommu *hd  = domain_hvm_iommu(d);
+    struct list_head *ioport_list, *tmp;
+    struct g2m_ioport *ioport;
+
+    list_for_each_safe ( ioport_list, tmp, &hd->arch.g2m_ioport_list )
+    {
+        ioport = list_entry(ioport_list, struct g2m_ioport, list);
+        list_del(&ioport->list);
+        xfree(ioport);
+    }
+}
+
 /*
  * Local variables:
  * mode: C
xen/include/asm-x86/hvm/iommu.h +22 -0
index d488edf..46cb126 100644
@@ -39,4 +39,26 @@ static inline int iommu_hardware_setup(void)
     return 0;
 }
 
+struct g2m_ioport {
+    struct list_head list;
+    unsigned int gport;
+    unsigned int mport;
+    unsigned int np;
+};
+
+struct arch_hvm_iommu
+{
+    u64 pgd_maddr;                 /* io page directory machine address */
+    spinlock_t mapping_lock;            /* io page table lock */
+    int agaw;     /* adjusted guest address width, 0 is level 2 30-bit */
+    struct list_head g2m_ioport_list;   /* guest to machine ioport mapping */
+    u64 iommu_bitmap;              /* bitmap of iommu(s) that the domain uses */
+    struct list_head mapped_rmrrs;
+
+    /* amd iommu support */
+    int paging_mode;
+    struct page_info *root_table;
+    struct guest_iommu *g_iommu;
+};
+
 #endif /* __ASM_X86_HVM_IOMMU_H__ */
xen/include/asm-x86/iommu.h +3 -1
index 10edfc2..e7a65da 100644
@@ -17,7 +17,9 @@
 
 #define MAX_IOMMUS 32
 
-#include <asm/msi.h>
+/* 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);
xen/include/xen/hvm/iommu.h +1 -18
index 9b32fa6..f8f8a93 100644
@@ -23,25 +23,8 @@
 #include <xen/iommu.h>
 #include <asm/hvm/iommu.h>
 
-struct g2m_ioport {
-    struct list_head list;
-    unsigned int gport;
-    unsigned int mport;
-    unsigned int np;
-};
-
 struct hvm_iommu {
-    u64 pgd_maddr;                 /* io page directory machine address */
-    spinlock_t mapping_lock;       /* io page table lock */
-    int agaw;     /* adjusted guest address width, 0 is level 2 30-bit */
-    struct list_head g2m_ioport_list;  /* guest to machine ioport mapping */
-    u64 iommu_bitmap;              /* bitmap of iommu(s) that the domain uses */
-    struct list_head mapped_rmrrs;
-
-    /* amd iommu support */
-    int paging_mode;
-    struct page_info *root_table;
-    struct guest_iommu *g_iommu;
+    struct arch_hvm_iommu arch;
 
     /* iommu_ops */
     const struct iommu_ops *platform_ops;
xen/include/xen/iommu.h +2 -5
index cabc8d6..ceb66c0 100644
@@ -35,11 +35,6 @@ extern bool_t iommu_hap_pt_share;
 extern bool_t iommu_debug;
 extern bool_t amd_iommu_perdev_intremap;
 
-/* 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)
-
 #define PAGE_SHIFT_4K       (12)
 #define PAGE_SIZE_4K        (1UL << PAGE_SHIFT_4K)
 #define PAGE_MASK_4K        (((u64)-1) << PAGE_SHIFT_4K)
@@ -55,6 +50,8 @@ void iommu_hwdom_init(struct domain *d);
 void iommu_domain_destroy(struct domain *d);
 int deassign_device(struct domain *d, u16 seg, u8 bus, u8 devfn);
 
+void arch_iommu_domain_destroy(struct domain *d);
+int arch_iommu_domain_init(struct domain *d);
 int arch_iommu_populate_page_table(struct domain *d);
 void arch_iommu_check_autotranslated_hwdom(struct domain *d);
 
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH v5 8/14 xen/passthrough: iommu: Basic support of device tree assignment

In reply to Julien Grall

Add IOMMU helpers to support device tree assignment/deassignment. This patch introduces 2 new fields in the dt_device_node:
- is_protected: Does the device is protected by an IOMMU
- domain_list: Pointer to the next device assigned to the same domain

This commit contains only support to protected a device with DOM0. Device passthrough to another guest won't work out-of-box.

---
Changes in v5:
- Fix typo in comment headers of drivers/passthrough/device_tree.c
- Drop comment of is_protected field

Changes in v4:
- Use hardware_domain instead of dom0 (recently changes in Xen)
- iommu_deassign_dt_device: add back to dom0 list the device
- add comments about the current support of DT device passthrough
- update commit message
- rename next_assigned to domain_list
Changes in v3:
- Remove iommu_dt_domain_{init,destroy} call in common code. Let architecture code to call them
- Fix indentation in xen/include/xen/hvm/iommu.h
Changes in v2:
- Patch added

---
 xen/common/device_tree.c              |    4 ++
 xen/drivers/passthrough/Makefile      |    1 +
 xen/drivers/passthrough/device_tree.c |  108 +++++++++++++++++++++++++++++++++
 xen/include/xen/device_tree.h         |   14 +++++
 xen/include/xen/hvm/iommu.h           |    6 ++
 xen/include/xen/iommu.h               |   16 +++++
 6 files changed, 149 insertions(+)
 create mode 100644 xen/drivers/passthrough/device_tree.c
xen/common/device_tree.c +4 -0
index 6e8e263..f0b17a3 100644
@@ -1695,6 +1695,10 @@ static unsigned long __init unflatten_dt_node(const void *fdt,
         np->full_name = ((char *)np) + sizeof(struct dt_device_node);
         /* By default dom0 owns the device */
         np->used_by = 0;
+        /* By default the device is not protected */
+        np->is_protected = false;
+        INIT_LIST_HEAD(&np->domain_list);
+
         if ( new_format )
         {
             char *fn = np->full_name;
xen/drivers/passthrough/Makefile +1 -0
index 6e08f89..5a0a35e 100644
@@ -5,3 +5,4 @@ subdir-$(x86_64) += x86
 obj-y += iommu.o
 obj-$(x86) += io.o
 obj-$(HAS_PCI) += pci.o
+obj-$(HAS_DEVICE_TREE) += device_tree.o
xen/drivers/passthrough/device_tree.c new file +108 -0

108 lines not on this page · raw message

xen/include/xen/device_tree.h +14 -0
index e677da9..25db076 100644
@@ -16,6 +16,7 @@
 #include <xen/string.h>
 #include <xen/types.h>
 #include <xen/stdbool.h>
+#include <xen/list.h>
 
 #define DEVICE_TREE_MAX_DEPTH 16
 
@@ -111,6 +112,9 @@ struct dt_device_node {
     struct dt_device_node *next; /* TODO: Remove it. Only use to know the last children */
     struct dt_device_node *allnext;
 
+    /* IOMMU specific fields */
+    bool is_protected;
+    struct list_head domain_list;
 };
 
 #define MAX_PHANDLE_ARGS 16
@@ -329,6 +333,16 @@ static inline domid_t dt_device_used_by(const struct dt_device_node *device)
     return device->used_by;
 }
 
+static inline void dt_device_set_protected(struct dt_device_node *device)
+{
+    device->is_protected = true;
+}
+
+static inline bool dt_device_is_protected(const struct dt_device_node *device)
+{
+    return device->is_protected;
+}
+
 static inline bool_t dt_property_name_is_equal(const struct dt_property *pp,
                                                const char *name)
 {
xen/include/xen/hvm/iommu.h +6 -0
index f8f8a93..1259e16 100644
@@ -21,6 +21,7 @@
 #define __XEN_HVM_IOMMU_H__
 
 #include <xen/iommu.h>
+#include <xen/list.h>
 #include <asm/hvm/iommu.h>
 
 struct hvm_iommu {
@@ -28,6 +29,11 @@ struct hvm_iommu {
 
     /* 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
 };
 
 #endif /* __XEN_HVM_IOMMU_H__ */
xen/include/xen/iommu.h +16 -0
index ceb66c0..b7481dac 100644
@@ -90,6 +90,16 @@ void iommu_read_msi_from_ire(struct msi_desc *msi_desc, struct msi_msg *msg);
 #define PT_IRQ_TIME_OUT MILLISECS(8)
 #endif /* HAS_PCI */
 
+#ifdef HAS_DEVICE_TREE
+#include <xen/device_tree.h>
+
+int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev);
+int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev);
+int iommu_dt_domain_init(struct domain *d);
+void iommu_dt_domain_destroy(struct domain *d);
+
+#endif /* HAS_DEVICE_TREE */
+
 struct page_info;
 
 struct iommu_ops {
@@ -106,6 +116,12 @@ struct iommu_ops {
     int (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg);
     void (*read_msi_from_ire)(struct msi_desc *msi_desc, struct msi_msg *msg);
 #endif /* HAS_PCI */
+#ifdef HAS_DEVICE_TREE
+    int (*assign_dt_device)(struct domain *d, const struct dt_device_node *dev);
+    int (*reassign_dt_device)(struct domain *s, struct domain *t,
+                              const struct dt_device_node *dev);
+#endif
+
     void (*teardown)(struct domain *d);
     int (*map_page)(struct domain *d, unsigned long gfn, unsigned long mfn,
                     unsigned int flags);
Signature · 1 line
1.7.10.4
#11 lore raw

PATCH v5 9/14 xen/passthrough: Introduce IOMMU ARM architecture

In reply to Julien Grall

This patch contains the architecture to use IOMMUs on ARM. There is no IOMMU drivers on this patch.

In this implementation, IOMMU page table will be shared with the P2M.

The code will run through the device tree and will initialize every IOMMU. It's possible to have multiple IOMMUs on the same platform, but they must be handled with the same driver. For now, there is no support for using multiple iommu drivers at runtime.

Each new IOMMU drivers should contain:

static const char * const myiommu_dt_compat[] __initconst =

{
    /* list of device compatible with the drivers. Will be matched with
     * the "compatible" property on the device tree
     */
    NULL,
};

DT_DEVICE_START(myiommu, "MY IOMMU", DEVICE_IOMMU)
.compatible = myiommu_compatible, .init = myiommu_init,
DT_DEVICE_END

---
Changes in v5:
- arch_iommu_check_hwdom_reqs has been rename into arch_iommu_check_autotranslated_reqs
- drop path in header comment
- remove spurious line
- fix typo in iommu_set_ops prink

Changes in v4:
- Rebase on latest Xen (hwdom series was pushed)
- Return directly iommu_dt_domain_init in arch_iommu_domain_init
- Rename hvm_iommu field into iommu
- Implement arch_iommu_check_hwdom_reqs

Changes in v3:
- Call iommu_dt_domain_{init,destroy} function in arch code

Changes in v2:
- Fix typoes in commit message
- Remove useless comment in arch/arm/setup.c
- Update copyright date to 2014
- Move iommu_dom0_init earlier
- Call iommu_assign_dt_device in map_device when the device is protected by an IOMMU

---
 xen/arch/arm/Rules.mk                |    1 +
 xen/arch/arm/domain.c                |    7 ++++
 xen/arch/arm/domain_build.c          |   20 ++++++++--
 xen/arch/arm/p2m.c                   |    6 +++
 xen/arch/arm/setup.c                 |    2 +
 xen/drivers/passthrough/Makefile     |    1 +
 xen/drivers/passthrough/arm/Makefile |    1 +
 xen/drivers/passthrough/arm/iommu.c  |   70 ++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/device.h         |    3 +-
 xen/include/asm-arm/domain.h         |    2 +
 xen/include/asm-arm/hvm/iommu.h      |   10 +++++
 xen/include/asm-arm/iommu.h          |   36 +++++++++++++++++
 12 files changed, 155 insertions(+), 4 deletions(-)
 create mode 100644 xen/drivers/passthrough/arm/Makefile
 create mode 100644 xen/drivers/passthrough/arm/iommu.c
 create mode 100644 xen/include/asm-arm/hvm/iommu.h
 create mode 100644 xen/include/asm-arm/iommu.h
xen/arch/arm/Rules.mk +1 -0
index 8d5624b..76b35d9 100644
@@ -9,6 +9,7 @@
 HAS_DEVICE_TREE := y
 HAS_VIDEO := y
 HAS_ARM_HDLCD := y
+HAS_PASSTHROUGH := y
 
 CFLAGS += -I$(BASEDIR)/include
 
xen/arch/arm/domain.c +7 -0
index 40f1c3a..0b77c59 100644
@@ -533,6 +533,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
     if ( is_hardware_domain(d) && (rc = domain_vuart_init(d)) )
         goto fail;
 
+    if ( (rc = iommu_domain_init(d)) != 0 )
+        goto fail;
+
     return 0;
 
 fail:
@@ -544,6 +547,10 @@ fail:
 
 void arch_domain_destroy(struct domain *d)
 {
+    /* IOMMU page table is shared with P2M, always call
+     * iommu_domain_destroy() before p2m_teardown().
+     */
+    iommu_domain_destroy(d);
     p2m_teardown(d);
     domain_vgic_free(d);
     domain_vuart_free(d);
xen/arch/arm/domain_build.c +17 -3
index fd35223..259f2f3 100644
@@ -679,7 +679,7 @@ static int make_timer_node(const struct domain *d, void *fdt,
 }
 
 /* Map the device in the domain */
-static int map_device(struct domain *d, const struct dt_device_node *dev)
+static int map_device(struct domain *d, struct dt_device_node *dev)
 {
     unsigned int nirq;
     unsigned int naddr;
@@ -694,6 +694,18 @@ static int map_device(struct domain *d, const struct dt_device_node *dev)
 
     DPRINT("%s nirq = %d naddr = %u\n", dt_node_full_name(dev), nirq, naddr);
 
+    if ( dt_device_is_protected(dev) )
+    {
+        DPRINT("%s setup iommu\n", dt_node_full_name(dev));
+        res = iommu_assign_dt_device(d, dev);
+        if ( res )
+        {
+            printk(XENLOG_ERR "Failed to setup the IOMMU for %s\n",
+                   dt_node_full_name(dev));
+            return res;
+        }
+    }
+
     /* Map IRQs */
     for ( i = 0; i < nirq; i++ )
     {
@@ -767,7 +779,7 @@ static int map_device(struct domain *d, const struct dt_device_node *dev)
 }
 
 static int handle_node(struct domain *d, struct kernel_info *kinfo,
-                       const struct dt_device_node *node)
+                       struct dt_device_node *node)
 {
     static const struct dt_device_match skip_matches[] __initconst =
     {
@@ -788,7 +800,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
         DT_MATCH_TIMER,
         { /* sentinel */ },
     };
-    const struct dt_device_node *child;
+    struct dt_device_node *child;
     int res;
     const char *name;
     const char *path;
@@ -1016,6 +1028,8 @@ int construct_dom0(struct domain *d)
 
     printk("*** LOADING DOMAIN 0 ***\n");
 
+    iommu_hwdom_init(d);
+
     d->max_pages = ~0U;
 
     kinfo.unassigned_mem = dom0_mem;
xen/arch/arm/p2m.c +6 -0
index 61450cf..816da21 100644
@@ -465,7 +465,13 @@ static int apply_p2m_changes(struct domain *d,
     }
 
     if ( flush )
+    {
+        unsigned long sgfn = paddr_to_pfn(start_gpaddr);
+        unsigned long egfn = paddr_to_pfn(end_gpaddr);
+
         flush_tlb_domain(d);
+        iommu_iotlb_flush(d, sgfn, egfn - sgfn);
+    }
 
     if ( op == ALLOCATE || op == INSERT )
     {
xen/arch/arm/setup.c +2 -0
index 40ba26e..b9ce7a9 100644
@@ -736,6 +736,8 @@ void __init start_xen(unsigned long boot_phys_offset,
     local_irq_enable();
     local_abort_enable();
 
+    iommu_setup();
+
     smp_prepare_cpus(cpus);
 
     initialize_keytable();
xen/drivers/passthrough/Makefile +1 -0
index 5a0a35e..16e9027 100644
@@ -1,6 +1,7 @@
 subdir-$(x86) += vtd
 subdir-$(x86) += amd
 subdir-$(x86_64) += x86
+subdir-$(arm) += arm
 
 obj-y += iommu.o
 obj-$(x86) += io.o
xen/drivers/passthrough/arm/Makefile new file +1 -0
new file mode 100644
index 0000000..0484b79
@@ -0,0 +1 @@
+obj-y += iommu.o
xen/drivers/passthrough/arm/iommu.c new file +70 -0

70 lines not on this page · raw message

xen/include/asm-arm/device.h +2 -1
index 9e47ca6..ed04344 100644
@@ -6,7 +6,8 @@
 
 enum device_type
 {
-    DEVICE_SERIAL
+    DEVICE_SERIAL,
+    DEVICE_IOMMU,
 };
 
 struct device_desc {
xen/include/asm-arm/domain.h +2 -0
index aabeb51..a42b292 100644
@@ -9,6 +9,7 @@
 #include <asm/vfp.h>
 #include <public/hvm/params.h>
 #include <xen/serial.h>
+#include <xen/hvm/iommu.h>
 
 /* Represents state corresponding to a block of 32 interrupts */
 struct vgic_irq_rank {
@@ -72,6 +73,7 @@ struct pending_irq
 struct hvm_domain
 {
     uint64_t              params[HVM_NR_PARAMS];
+    struct hvm_iommu      iommu;
 }  __cacheline_aligned;
 
 #ifdef CONFIG_ARM_64
xen/include/asm-arm/hvm/iommu.h new file +10 -0
new file mode 100644
index 0000000..461c8cf
@@ -0,0 +1,10 @@
+#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_ */
xen/include/asm-arm/iommu.h new file +36 -0
new file mode 100644
index 0000000..9322f08
@@ -0,0 +1,36 @@
+/*
+ * 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.
+*/
+#ifndef __ARCH_ARM_IOMMU_H__
+#define __ARCH_ARM_IOMMU_H__
+
+/* 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);
+
+int __init iommu_hardware_setup(void);
+
+#endif /* __ARCH_ARM_IOMMU_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
1.7.10.4
#12 lore raw

PATCH v5 10/14 MAINTAINERS: Add drivers/passthrough/arm

In reply to Julien Grall

Add the ARM IOMMU directory to "ARM ARCHITECTURE" part

---
Changes in v5:
- Add trailing slash for consistency
- Specificy in "IOMMU VENDOR INDEPENDENT CODE" that the directory arm is not maintened by them

---
 MAINTAINERS |    2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index b53c574..ae915f4 100644
@@ -136,6 +136,7 @@ F:	xen/drivers/char/dt-uart.c
 F:	xen/drivers/char/exynos4210-uart.c
 F:	xen/drivers/char/omap-uart.c
 F:	xen/drivers/char/pl011.c
+F:	xen/drivers/passthrough/arm/
 
 CPU POOLS
 M:	Juergen Gross <[email protected]>
@@ -205,6 +206,7 @@ M:	Jan Beulich <[email protected]>
 S:	Supported
 F:	xen/drivers/passthrough/
 X:	xen/drivers/passthrough/amd/
+X:	xen/drivers/passthrough/arm/
 X:	xen/drivers/passthrough/vtd/
 F:	xen/include/xen/iommu.h
 
Signature · 1 line
1.7.10.4
#13 lore raw

PATCH v5 11/14 xen/arm: Don't give IOMMU devices to dom0 when iommu is disabled

In reply to Julien Grall

When iommu={disable,off,no,false} is given to Xen command line, the IOMMU framework won't specify that the device shouldn't be passthrough to DOM0.

---
Changes in v2:
- Patch added

---
 xen/arch/arm/device.c        |   15 +++++++++++++++
 xen/arch/arm/domain_build.c  |   10 ++++++++++
 xen/include/asm-arm/device.h |   10 ++++++++++
 3 files changed, 35 insertions(+)
xen/arch/arm/device.c +15 -0
index f86b2e3..59e94c0 100644
@@ -67,6 +67,21 @@ int __init device_init(struct dt_device_node *dev, enum device_type type,
     return -EBADF;
 }
 
+enum device_type device_get_type(const struct dt_device_node *dev)
+{
+    const struct device_desc *desc;
+
+    ASSERT(dev != NULL);
+
+    for ( desc = _sdevice; desc != _edevice; desc++ )
+    {
+        if ( device_is_compatible(desc, dev) )
+            return desc->type;
+    }
+
+    return DEVICE_UNKNOWN;
+}
+
 /*
  * Local variables:
  * mode: C
xen/arch/arm/domain_build.c +10 -0
index 259f2f3..ddbb88d 100644
@@ -11,6 +11,7 @@
 #include <xen/device_tree.h>
 #include <xen/libfdt/libfdt.h>
 #include <xen/guest_access.h>
+#include <asm/device.h>
 #include <asm/setup.h>
 #include <asm/platform.h>
 #include <asm/psci.h>
@@ -835,6 +836,15 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
         return 0;
     }
 
+    /* Even if the IOMMU device is not used by Xen, it should not be
+     * passthrough to DOM0
+     */
+    if ( device_get_type(node) == DEVICE_IOMMU )
+    {
+        DPRINT(" IOMMU, skip it\n");
+        return 0;
+    }
+
     /*
      * Some device doesn't need to be mapped in Xen:
      *  - Memory: the guest will see a different view of memory. It will
xen/include/asm-arm/device.h +10 -0
index ed04344..60109cc 100644
@@ -8,6 +8,8 @@ enum device_type
 {
     DEVICE_SERIAL,
     DEVICE_IOMMU,
+    /* Use for error */
+    DEVICE_UNKNOWN,
 };
 
 struct device_desc {
@@ -32,6 +34,14 @@ struct device_desc {
 int __init device_init(struct dt_device_node *dev, enum device_type type,
                        const void *data);
 
+/**
+ * device_get_type - Get the type of the device
+ * @dev: device to match
+ *
+ * Return the device type on success or DEVICE_ANY on failure
+ */
+enum device_type device_get_type(const struct dt_device_node *dev);
+
 #define DT_DEVICE_START(_name, _namestr, _type)                     \
 static const struct device_desc __dev_desc_##_name __used           \
 __attribute__((__section__(".dev.info"))) = {                       \
Signature · 1 line
1.7.10.4
#14 lore raw

PATCH v5 12/14 xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk

In reply to Julien Grall

Some IOMMU don't suppport coherent PT walk. When the p2m is shared with the CPU, Xen has to make sure the PT changes have reached the memory.

Introduce new IOMMU callback that will retrieve the IOMMU feature for a specified domain.

On ARM, the platform can contain multiple IOMMUs. Each of them may not have the same set of feature. The domain parameter will be used to get the set of features for IOMMUs used by this domain.

Cc Jan Beulich <[email protected]>
Cc Xiantao Zhang <[email protected]>

---
Changes in v5:
- Flush on every write_pte instead of unmap page. This will avoid to flush a whole page when only few bytes are modified
- Only get iommu feature once.
- Add bits to flush cache when a new table is created
- Fix typoes in commit message and comment
- Use an enum to describe the feature. Each items are a bit position

Changes in v4:
- Patch added

---
 xen/arch/arm/p2m.c              |   36 ++++++++++++++++++++++++++++--------
 xen/drivers/passthrough/iommu.c |   11 +++++++++++
 xen/include/xen/iommu.h         |    9 +++++++++
 3 files changed, 48 insertions(+), 8 deletions(-)
xen/arch/arm/p2m.c +28 -8
index 816da21..4331866 100644
@@ -253,9 +253,15 @@ static lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr,
     return e;
 }
 
+static inline void p2m_write_pte(lpae_t *p, lpae_t pte, bool_t flush_cache)
+{
+    write_pte(p, pte);
+    if ( flush_cache )
+        clean_xen_dcache(*p);
+}
+
 /* Allocate a new page table page and hook it in via the given entry */
-static int p2m_create_table(struct domain *d,
-                            lpae_t *entry)
+static int p2m_create_table(struct domain *d, lpae_t *entry, bool_t flush_cache)
 {
     struct p2m_domain *p2m = &d->arch.p2m;
     struct page_info *page;
@@ -272,11 +278,13 @@ static int p2m_create_table(struct domain *d,
 
     p = __map_domain_page(page);
     clear_page(p);
+    if ( flush_cache )
+        clean_xen_dcache_va_range(p, PAGE_SIZE);
     unmap_domain_page(p);
 
     pte = mfn_to_p2m_entry(page_to_mfn(page), MATTR_MEM, p2m_invalid);
 
-    write_pte(entry, pte);
+    p2m_write_pte(entry, pte, flush_cache);
 
     return 0;
 }
@@ -308,6 +316,13 @@ static int apply_p2m_changes(struct domain *d,
     unsigned int flush = 0;
     bool_t populate = (op == INSERT || op == ALLOCATE);
     lpae_t pte;
+    bool_t flush_pt;
+
+    /* Some IOMMU don't support coherent PT walk. When the p2m is
+     * shared with the CPU, Xen has to make sure that the PT changes have
+     * reached the memory
+     */
+    flush_pt = need_iommu(d) && !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK);
 
     spin_lock(&p2m->lock);
 
@@ -334,7 +349,8 @@ static int apply_p2m_changes(struct domain *d,
                 continue;
             }
 
-            rc = p2m_create_table(d, &first[first_table_offset(addr)]);
+            rc = p2m_create_table(d, &first[first_table_offset(addr)],
+                                  flush_pt);
             if ( rc < 0 )
             {
                 printk("p2m_populate_ram: L1 failed\n");
@@ -360,7 +376,8 @@ static int apply_p2m_changes(struct domain *d,
                 continue;
             }
 
-            rc = p2m_create_table(d, &second[second_table_offset(addr)]);
+            rc = p2m_create_table(d, &second[second_table_offset(addr)],
+                                  flush_pt);
             if ( rc < 0 ) {
                 printk("p2m_populate_ram: L2 failed\n");
                 goto out;
@@ -411,13 +428,15 @@ static int apply_p2m_changes(struct domain *d,
 
                     pte = mfn_to_p2m_entry(page_to_mfn(page), mattr, t);
 
-                    write_pte(&third[third_table_offset(addr)], pte);
+                    p2m_write_pte(&third[third_table_offset(addr)],
+                                  pte, flush_pt);
                 }
                 break;
             case INSERT:
                 {
                     pte = mfn_to_p2m_entry(maddr >> PAGE_SHIFT, mattr, t);
-                    write_pte(&third[third_table_offset(addr)], pte);
+                    p2m_write_pte(&third[third_table_offset(addr)],
+                                  pte, flush_pt);
                     maddr += PAGE_SIZE;
                 }
                 break;
@@ -433,7 +452,8 @@ static int apply_p2m_changes(struct domain *d,
                     count += 0x10;
 
                     memset(&pte, 0x00, sizeof(pte));
-                    write_pte(&third[third_table_offset(addr)], pte);
+                    p2m_write_pte(&third[third_table_offset(addr)],
+                                  pte, flush_pt);
                     count++;
                 }
                 break;
xen/drivers/passthrough/iommu.c +11 -0
index 59f1c3e..2faab48 100644
@@ -344,6 +344,17 @@ void iommu_crash_shutdown(void)
     iommu_enabled = iommu_intremap = 0;
 }
 
+bool_t iommu_has_feature(struct domain *d, enum iommu_feature feature)
+{
+    const struct iommu_ops *ops = domain_hvm_iommu(d)->platform_ops;
+    uint32_t features = 0;
+
+    if ( iommu_enabled && ops && ops->features )
+        features = ops->features(d);
+
+    return !!(features & (1 << feature));
+}
+
 static void iommu_dump_p2m_table(unsigned char key)
 {
     struct domain *d;
xen/include/xen/iommu.h +9 -0
index b7481dac..2a763ae 100644
@@ -67,6 +67,14 @@ int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn,
                    unsigned int flags);
 int iommu_unmap_page(struct domain *d, unsigned long gfn);
 
+enum iommu_feature
+{
+    IOMMU_FEAT_COHERENT_WALK = 1,
+};
+
+bool_t iommu_has_feature(struct domain *d, enum iommu_feature feature);
+
+
 #ifdef HAS_PCI
 void pt_pci_init(void);
 
@@ -139,6 +147,7 @@ struct iommu_ops {
     void (*iotlb_flush)(struct domain *d, unsigned long gfn, unsigned int page_count);
     void (*iotlb_flush_all)(struct domain *d);
     void (*dump_p2m_table)(struct domain *d);
+    uint32_t (*features)(struct domain *d);
 };
 
 void iommu_suspend(void);
Signature · 1 line
1.7.10.4
#15 lore raw

Re: [PATCH v5 12/14] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk

xen/drivers/passthrough/iommu.c void iommu_crash_shutdown(void) · line 350

Quoted 10 lines
xen/drivers/passthrough/iommu.c +4 -0
@@ -344,6 +344,17 @@ void iommu_crash_shutdown(void)
     iommu_enabled = iommu_intremap = 0;
 }
 
+bool_t iommu_has_feature(struct domain *d, enum iommu_feature feature)
+{
+    const struct iommu_ops *ops = domain_hvm_iommu(d)->platform_ops;
+    uint32_t features = 0;

Please here and further down - don't use fixed width type unless you really need to.

xen/include/xen/iommu.h int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn, · line 72

Quoted 9 lines
xen/include/xen/iommu.h +3 -0
@@ -67,6 +67,14 @@ int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn,
                    unsigned int flags);
 int iommu_unmap_page(struct domain *d, unsigned long gfn);
 
+enum iommu_feature
+{
+    IOMMU_FEAT_COHERENT_WALK = 1,

Why 1? Enumerations are defined to start at zero, and starting at zero is what you really want here. Don't specify a value at all.

xen/include/xen/iommu.h struct iommu_ops { · line 150

Quoted 5 lines
xen/include/xen/iommu.h +1 -0
@@ -139,6 +147,7 @@ struct iommu_ops {
     void (*iotlb_flush)(struct domain *d, unsigned long gfn, unsigned int page_count);
     void (*iotlb_flush_all)(struct domain *d);
     void (*dump_p2m_table)(struct domain *d);
+    uint32_t (*features)(struct domain *d);

I think I said this on an earlier round already - for future extensibility this should return "const unsigned long *", and get accessed by the wrapper function using test_bit(). Or even better without an accessor function at all, just directly having a "const unsigned long *" field here. Unless of course the backend implementation - which isn't part of this patch - would have difficulty setting up a suitable bitfield during (early) initialization.

Jan

#16 lore raw

Re: [PATCH v5 12/14] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk

Hi Ian,

Quoted 20 lines · Jan Beulich

xen/drivers/passthrough/iommu.c void iommu_crash_shutdown(void) · line 350

Quoted 10 lines
xen/drivers/passthrough/iommu.c +4 -0
@@ -344,6 +344,17 @@ void iommu_crash_shutdown(void)
      iommu_enabled = iommu_intremap = 0;
  }
 
+bool_t iommu_has_feature(struct domain *d, enum iommu_feature feature)
+{
+    const struct iommu_ops *ops = domain_hvm_iommu(d)->platform_ops;
+    uint32_t features = 0;

Please here and further down - don't use fixed width type unless you really need to.

Quoted 6 lines
xen/include/xen/iommu.h +0 -0
@@ -67,6 +67,14 @@ int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn,
                     unsigned int flags);
  int iommu_unmap_page(struct domain *d, unsigned long gfn);
 
Quoted 6 lines

xen/include/xen/iommu.h int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn, · line 72

Quoted 3 lines
xen/include/xen/iommu.h +3 -0
+enum iommu_feature
+{
+    IOMMU_FEAT_COHERENT_WALK = 1,

Why 1? Enumerations are defined to start at zero, and starting at zero is what you really want here. Don't specify a value at all.

It's a mistake when I create the enum. I will drop the 1.

Quoted 6 lines

xen/include/xen/iommu.h struct iommu_ops { · line 150

Quoted 5 lines
xen/include/xen/iommu.h +1 -0
@@ -139,6 +147,7 @@ struct iommu_ops {
      void (*iotlb_flush)(struct domain *d, unsigned long gfn, unsigned int page_count);
      void (*iotlb_flush_all)(struct domain *d);
      void (*dump_p2m_table)(struct domain *d);
+    uint32_t (*features)(struct domain *d);
Quoted 7 lines

I think I said this on an earlier round already - for future extensibility this should return "const unsigned long *", and get accessed by the wrapper function using test_bit(). Or even better without an accessor function at all, just directly having a "const unsigned long *" field here. Unless of course the backend implementation - which isn't part of this patch - would have difficulty setting up a suitable bitfield during (early) initialization.

The SMMU drivers handle multiple SMMUs. Each SMMU can have different specifications (e.g coherent walk support or not).

As each domain doesn't use all SMMUs, we might be able to avoid flushing PT on some of them. That's why I've choose to use a callback with the domain in parameter.

I don't like the solution which return "unsigned long *" because we are assuming the driver will always a valid pointer (for instance with 2 unsigned long), even if he doesn't need it.

Regards,

Signature · 1 line
Julien Grall
#17 lore raw

Re: [PATCH v5 12/14] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk

Quoted 18 lines
Quoted 7 lines

xen/include/xen/iommu.h struct iommu_ops { · line 150

Quoted 6 lines · On 14.05.14 at 11:09, <[email protected]> wrote:
xen/include/xen/iommu.h +1 -0
@@ -139,6 +147,7 @@ struct iommu_ops {
      void (*iotlb_flush)(struct domain *d, unsigned long gfn, unsigned int page_count);
      void (*iotlb_flush_all)(struct domain *d);
      void (*dump_p2m_table)(struct domain *d);
+    uint32_t (*features)(struct domain *d);
Quoted 7 lines

I think I said this on an earlier round already - for future extensibility this should return "const unsigned long *", and get accessed by the wrapper function using test_bit(). Or even better without an accessor function at all, just directly having a "const unsigned long *" field here. Unless of course the backend implementation - which isn't part of this patch - would have difficulty setting up a suitable bitfield during (early) initialization.

The SMMU drivers handle multiple SMMUs. Each SMMU can have different specifications (e.g coherent walk support or not).

Quoted 7 lines

As each domain doesn't use all SMMUs, we might be able to avoid flushing PT on some of them. That's why I've choose to use a callback with the domain in parameter.

I don't like the solution which return "unsigned long *" because we are assuming the driver will always a valid pointer (for instance with 2 unsigned long), even if he doesn't need it.

In that case simply make this a bitmap embedded in struct iommu_ops, which the driver has to populate suitably early. That way the individual drivers don't need to care about the eventually growing size.

Jan

#18 lore raw

Re: [PATCH v5 12/14] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk

Quoted 22 lines · Jan Beulich
Quoted 22 lines
Quoted 7 lines

xen/include/xen/iommu.h struct iommu_ops { · line 150

Quoted 6 lines · On 14.05.14 at 11:09, <[email protected]> wrote:
xen/include/xen/iommu.h +1 -0
@@ -139,6 +147,7 @@ struct iommu_ops {
      void (*iotlb_flush)(struct domain *d, unsigned long gfn, unsigned int page_count);
      void (*iotlb_flush_all)(struct domain *d);
      void (*dump_p2m_table)(struct domain *d);
+    uint32_t (*features)(struct domain *d);
Quoted 7 lines

I think I said this on an earlier round already - for future extensibility this should return "const unsigned long *", and get accessed by the wrapper function using test_bit(). Or even better without an accessor function at all, just directly having a "const unsigned long *" field here. Unless of course the backend implementation - which isn't part of this patch - would have difficulty setting up a suitable bitfield during (early) initialization.

The SMMU drivers handle multiple SMMUs. Each SMMU can have different specifications (e.g coherent walk support or not).

As each domain doesn't use all SMMUs, we might be able to avoid flushing PT on some of them. That's why I've choose to use a callback with the domain in parameter.

Quoted 7 lines
Quoted 3 lines

I don't like the solution which return "unsigned long *" because we are assuming the driver will always a valid pointer (for instance with 2 unsigned long), even if he doesn't need it.

In that case simply make this a bitmap embedded in struct iommu_ops, which the driver has to populate suitably early. That way the individual drivers don't need to care about the eventually growing size.

That doesn't really help me. Because a same platform can have a mix of SMMU support coherent walk or not.

For optimization it would be better to have a per-domain feature.

What about creating a callback:
iommu_has_feature(struct domain *d, enum iommu_feature)

and let the driver handling the feature?

Regards,

Signature · 1 line
Julien Grall
#19 lore raw

Re: [PATCH v5 12/14] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk

Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 14.05.14 at 14:45, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 3 lines
Quoted 3 lines

Review struct iommu_ops { · line 147

Quoted 3 lines · On 14.05.14 at 11:09, <[email protected]> wrote:
(quoted diff) +0 -0
@@ -139,6 +147,7 @@ struct iommu_ops {
      void (*iotlb_flush)(struct domain *d, unsigned long gfn, unsigned int 

page_count);

Quoted 23 lines
Quoted 22 lines
Quoted 11 lines

xen/include/xen/iommu.h struct iommu_ops { · line 150

Quoted 3 lines
xen/include/xen/iommu.h +1 -0
      void (*iotlb_flush_all)(struct domain *d);
      void (*dump_p2m_table)(struct domain *d);
+    uint32_t (*features)(struct domain *d);

I think I said this on an earlier round already - for future extensibility this should return "const unsigned long *", and get accessed by the wrapper function using test_bit(). Or even better without an accessor function at all, just directly having a "const unsigned long *" field here. Unless of course the backend implementation - which isn't part of this patch - would have difficulty setting up a suitable bitfield during (early) initialization.

The SMMU drivers handle multiple SMMUs. Each SMMU can have different specifications (e.g coherent walk support or not).

As each domain doesn't use all SMMUs, we might be able to avoid flushing PT on some of them. That's why I've choose to use a callback with the domain in parameter.

I don't like the solution which return "unsigned long *" because we are assuming the driver will always a valid pointer (for instance with 2 unsigned long), even if he doesn't need it.

Quoted 8 lines
Quoted 3 lines

In that case simply make this a bitmap embedded in struct iommu_ops, which the driver has to populate suitably early. That way the individual drivers don't need to care about the eventually growing size.

That doesn't really help me. Because a same platform can have a mix of SMMU support coherent walk or not.

For optimization it would be better to have a per-domain feature.

Oh, right, I didn't pay attention to you passing a domain into the query.

Quoted 4 lines

What about creating a callback:
iommu_has_feature(struct domain *d, enum iommu_feature)

and let the driver handling the feature?

That sounds fine as long as you don't expect such to sit on any hot path (indirect calls are expensive not only on x86 I think).

Jan

#20 lore raw

Re: [PATCH v5 12/14] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk

Quoted 41 lines · Jan Beulich
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 14.05.14 at 14:45, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 3 lines
Quoted 3 lines

Review struct iommu_ops { · line 147

Quoted 3 lines · On 14.05.14 at 11:09, <[email protected]> wrote:
(quoted diff) +0 -0
@@ -139,6 +147,7 @@ struct iommu_ops {
      void (*iotlb_flush)(struct domain *d, unsigned long gfn, unsigned int 

page_count);

Quoted 23 lines
Quoted 22 lines
Quoted 11 lines

xen/include/xen/iommu.h struct iommu_ops { · line 150

Quoted 3 lines
xen/include/xen/iommu.h +1 -0
      void (*iotlb_flush_all)(struct domain *d);
      void (*dump_p2m_table)(struct domain *d);
+    uint32_t (*features)(struct domain *d);

I think I said this on an earlier round already - for future extensibility this should return "const unsigned long *", and get accessed by the wrapper function using test_bit(). Or even better without an accessor function at all, just directly having a "const unsigned long *" field here. Unless of course the backend implementation - which isn't part of this patch - would have difficulty setting up a suitable bitfield during (early) initialization.

The SMMU drivers handle multiple SMMUs. Each SMMU can have different specifications (e.g coherent walk support or not).

As each domain doesn't use all SMMUs, we might be able to avoid flushing PT on some of them. That's why I've choose to use a callback with the domain in parameter.

I don't like the solution which return "unsigned long *" because we are assuming the driver will always a valid pointer (for instance with 2 unsigned long), even if he doesn't need it.

Quoted 8 lines
Quoted 3 lines

In that case simply make this a bitmap embedded in struct iommu_ops, which the driver has to populate suitably early. That way the individual drivers don't need to care about the eventually growing size.

That doesn't really help me. Because a same platform can have a mix of SMMU support coherent walk or not.

For optimization it would be better to have a per-domain feature.

Oh, right, I didn't pay attention to you passing a domain into the query.

Quoted 7 lines
Quoted 4 lines

What about creating a callback:
iommu_has_feature(struct domain *d, enum iommu_feature)

and let the driver handling the feature?

That sounds fine as long as you don't expect such to sit on any hot path (indirect calls are expensive not only on x86 I think).

Actually, it's called during an hot patch (every time a page is mapped in the p2m).

I've already optimized a bit by only call the function one per batch of mapping (as iommu TLB flush).

Regards,

Signature · 1 line
Julien Grall
#21 lore raw

Re: [PATCH v5 12/14] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk

Quoted 46 lines
Quoted 1 line
Quoted 1 line · On 14.05.14 at 15:11, <[email protected]> wrote:
Quoted 44 lines · Jan Beulich
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 14.05.14 at 14:45, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 3 lines
Quoted 3 lines

Review struct iommu_ops { · line 147

Quoted 3 lines · On 14.05.14 at 11:09, <[email protected]> wrote:
(quoted diff) +0 -0
@@ -139,6 +147,7 @@ struct iommu_ops {
      void (*iotlb_flush)(struct domain *d, unsigned long gfn, unsigned int 

page_count);

Quoted 23 lines
Quoted 22 lines
Quoted 11 lines

Review struct iommu_ops { · line 150

Quoted 3 lines
(quoted diff) +1 -0
      void (*iotlb_flush_all)(struct domain *d);
      void (*dump_p2m_table)(struct domain *d);
+    uint32_t (*features)(struct domain *d);

I think I said this on an earlier round already - for future extensibility this should return "const unsigned long *", and get accessed by the wrapper function using test_bit(). Or even better without an accessor function at all, just directly having a "const unsigned long *" field here. Unless of course the backend implementation - which isn't part of this patch - would have difficulty setting up a suitable bitfield during (early) initialization.

The SMMU drivers handle multiple SMMUs. Each SMMU can have different specifications (e.g coherent walk support or not).

As each domain doesn't use all SMMUs, we might be able to avoid flushing PT on some of them. That's why I've choose to use a callback with the domain in parameter.

I don't like the solution which return "unsigned long *" because we are assuming the driver will always a valid pointer (for instance with 2 unsigned long), even if he doesn't need it.

Quoted 8 lines
Quoted 3 lines

In that case simply make this a bitmap embedded in struct iommu_ops, which the driver has to populate suitably early. That way the individual drivers don't need to care about the eventually growing size.

That doesn't really help me. Because a same platform can have a mix of SMMU support coherent walk or not.

For optimization it would be better to have a per-domain feature.

Oh, right, I didn't pay attention to you passing a domain into the query.

Quoted 3 lines

What about creating a callback:
iommu_has_feature(struct domain *d, enum iommu_feature)

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

and let the driver handling the feature?

That sounds fine as long as you don't expect such to sit on any hot path (indirect calls are expensive not only on x86 I think).

Actually, it's called during an hot patch (every time a page is mapped in the p2m).

In that case, why don't you put the feature flag(s) somewhere in struct domain or struct arch_domain (or some sub-structure thereof)?

Jan

#22 lore raw

Re: [PATCH v5 12/14] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk

Quoted 2 lines · Jan Beulich

In that case, why don't you put the feature flag(s) somewhere in struct domain or struct arch_domain (or some sub-structure thereof)?

I didn't think about this solution. I will give a try.

Regards,

Signature · 1 line
Julien Grall
#23 lore raw

PATCH v5 13/14 xen/arm: grant: Add another entry to map MFN 1:1 in dom0 p2m

In reply to Julien Grall

Grant mapping can be used for DMA request. The dev_bus_addr returned by the hypercall is the MFN (not the IPA). Currently Linux is using this address (via swiotlb) to program the DMA.
When the device is protected by IOMMU the request will fail. We have to add 1:1 mapping in the domain p2m to allow DMA request working.

This is valid because DOM0 has its memory mapped 1:1 and therefore we know that RAM and devices cannot clash.

---
Changes in v5:
- Update commit message

Changes in v4:
- Patch added

---
 xen/arch/arm/mm.c |   33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
xen/arch/arm/mm.c +28 -5
index eac228c..4ce3962 100644
@@ -1199,6 +1199,7 @@ int create_grant_host_mapping(unsigned long addr, unsigned long frame,
 {
     int rc;
     p2m_type_t t = p2m_grant_map_rw;
+    struct domain *d = current->domain;
 
     if ( cache_flags  || (flags & ~GNTMAP_readonly) != GNTMAP_host_map )
         return GNTST_general_error;
@@ -1206,13 +1207,32 @@ int create_grant_host_mapping(unsigned long addr, unsigned long frame,
     if ( flags & GNTMAP_readonly )
         t = p2m_grant_map_ro;
 
-    rc = guest_physmap_add_entry(current->domain, addr >> PAGE_SHIFT,
-                                 frame, 0, t);
+    rc = guest_physmap_add_entry(d, addr >> PAGE_SHIFT, frame, 0, t);
 
     if ( rc )
-        return GNTST_general_error;
-    else
-        return GNTST_okay;
+        goto gerror;
+
+    /* Grant mapping can be used for DMA request. The dev_bus_addr returned by
+     * the hypercall is the MFN (not the IPA). For device protected by
+     * an IOMMU, Xen needs to add a 1:1 mapping in the domain p2m to
+     * allow DMA request working.
+     * This is only valid when the domain is directed mapped
+     */
+    if ( is_domain_direct_mapped(d) && need_iommu(d) )
+    {
+        rc = guest_physmap_add_entry(d, frame, frame, 0, t);
+        if ( rc )
+            goto unmap;
+    }
+
+    return GNTST_okay;
+
+unmap:
+    guest_physmap_remove_page(d, addr >> PAGE_SHIFT, frame, 0);
+
+gerror:
+    return GNTST_general_error;
+
 }
 
 int replace_grant_host_mapping(unsigned long addr, unsigned long mfn,
@@ -1226,6 +1246,9 @@ int replace_grant_host_mapping(unsigned long addr, unsigned long mfn,
 
     guest_physmap_remove_page(d, gfn, mfn, 0);
 
+    if ( is_domain_direct_mapped(d) && need_iommu(d) )
+        guest_physmap_remove_page(d, mfn, mfn, 0);
+
     return GNTST_okay;
 }
 
Signature · 1 line
1.7.10.4
#24 lore raw

PATCH v5 14/14 drivers/passthrough: arm: Add support for SMMU drivers

In reply to Julien Grall

This patch add support for ARM architected SMMU driver. It's based on the linux drivers (drivers/iommu/arm-smmu) commit 89ac23cd.

The major differences with the Linux driver are:
- Fault by default if the SMMU is enabled to translate an address (Linux is bypassing the SMMU)
- Using P2M page table instead of creating new one
- Dropped stage-1 support
- Dropped chained SMMUs support for now
- Reworking device assignment and the different structures

Xen is programming each IOMMU by:
- Using stage-2 mode translation
- Sharing the page table with the processor
- Injecting a fault if the device has made a wrong translation

---
Changes in v5:
- Fix arm_smmu_domain_remove_master by using num_s2crs instead of num_streamids
- IOMMU_FEATURE_COHERENT_WALK is became a bit position
Changes in v4:
- Use the new IRQ API e.g function without _dt_ in the name
- Use IRQF_SHARED to notify that the IRQ can be shared (i.e handle multiple actions)
- Update comment in smmu_init
- Update comment for upgrade barrier in smmu_device_reset
- Update CB_TCR to reflect change in VTCR by commit 8200dae
- Drop gr0_base which is not unused in arm_smmu_init_context_bank
- Rebase on the latest Xen (hwdom series was pushed)
- On 32 bit IPA is encoded on 40-bits. Read CB_FAR_HI on all arch
- Add verbosity in CB fault handler
- Handle 40 bits address space on ARM{32,64}.
- Implement new callback features
- platform_get_irq now returns -1 if an error occured
Changes in v3:
- Missing some static
Changes in v2:
- Update commit message
- Update some comments in the code
- Add new callbacks to assign/reassign DT device
- Rework init_dom0 and domain_teardown. The assignment/deassignement is now made in the generic code
- Set protected field in dt_device_node when the device is under an IOMMU
- Use SZ_64K and SZ_4K by the global PAGE_SIZE_{64,4}K in xen/iommu.h. The first one was not defined.

---
 xen/drivers/passthrough/arm/Makefile |    1 +
 xen/drivers/passthrough/arm/smmu.c   | 1751 ++++++++++++++++++++++++++++++++++
 xen/include/xen/iommu.h              |    3 +
 3 files changed, 1755 insertions(+)
 create mode 100644 xen/drivers/passthrough/arm/smmu.c
xen/drivers/passthrough/arm/Makefile +1 -0
index 0484b79..f4cd26e 100644
@@ -1 +1,2 @@
 obj-y += iommu.o
+obj-y += smmu.o
xen/drivers/passthrough/arm/smmu.c new file +1751 -0

1,751 lines not on this page · raw message

xen/include/xen/iommu.h +3 -0
index 2a763ae..29dc0da 100644
@@ -40,6 +40,9 @@ extern bool_t amd_iommu_perdev_intremap;
 #define PAGE_MASK_4K        (((u64)-1) << PAGE_SHIFT_4K)
 #define PAGE_ALIGN_4K(addr) (((addr) + PAGE_SIZE_4K - 1) & PAGE_MASK_4K)
 
+#define PAGE_SHIFT_64K      (16)
+#define PAGE_SIZE_64K       (1UL << PAGE_SHIFT_64K)
+
 int iommu_setup(void);
 
 int iommu_add_device(struct pci_dev *pdev);
Signature · 1 line
1.7.10.4
Acked-by on v5 14/14
#25 lore raw

Re: [PATCH v5 14/14] drivers/passthrough: arm: Add support for SMMU drivers

xen/include/xen/iommu.h extern bool_t amd_iommu_perdev_intremap; · line 44

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 13.05.14 at 17:50, <[email protected]> wrote:
xen/include/xen/iommu.h +2 -0
@@ -40,6 +40,9 @@ extern bool_t amd_iommu_perdev_intremap;
 #define PAGE_MASK_4K        (((u64)-1) << PAGE_SHIFT_4K)
 #define PAGE_ALIGN_4K(addr) (((addr) + PAGE_SIZE_4K - 1) & PAGE_MASK_4K)
 
+#define PAGE_SHIFT_64K      (16)
+#define PAGE_SIZE_64K       (1UL << PAGE_SHIFT_64K)

I think for consistency you should also define PAGE_MASK_64K and PAGE_ALIGN_64K, perhaps via helper macros then also to be used to implement the 4k variants. That's not the least because you can't safely use PAGE_SIZE_64K to implement address masking on 32-bit ARM (which iirc supports physical addresses wider than 32 bits), due to the use of 1UL.

E.g.

#define IOMMU_PAGE_SIZE(sz) (1UL << PAGE_SHIFT_##sz)
#define IOMMU_PAGE_MASK(sz) (~(u64)0 << PAGE_SHIFT_##sz)
#define IOMMU_PAGE_ALIGN(sz, addr) (((addr) + ~PAGE_MASK_##sz) & PAGE_MASK_##sz)

#define PAGE_SIZE_4K IOMMU_PAGE_SIZE(4K)
etc.

Anyway,

for this small piece of non-ARM code, no matter whether you follow the advice.

Jan

#26 lore raw

Re: [PATCH v5 14/14] drivers/passthrough: arm: Add support for SMMU drivers

Quoted 17 lines · Jan Beulich

xen/include/xen/iommu.h extern bool_t amd_iommu_perdev_intremap; · line 44

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 13.05.14 at 17:50, <[email protected]> wrote:
xen/include/xen/iommu.h +2 -0
@@ -40,6 +40,9 @@ extern bool_t amd_iommu_perdev_intremap;
 #define PAGE_MASK_4K        (((u64)-1) << PAGE_SHIFT_4K)
 #define PAGE_ALIGN_4K(addr) (((addr) + PAGE_SIZE_4K - 1) & PAGE_MASK_4K)
 
+#define PAGE_SHIFT_64K      (16)
+#define PAGE_SIZE_64K       (1UL << PAGE_SHIFT_64K)

I think for consistency you should also define PAGE_MASK_64K and PAGE_ALIGN_64K, perhaps via helper macros then also to be used to implement the 4k variants. That's not the least because you can't safely use PAGE_SIZE_64K to implement address masking on 32-bit ARM (which iirc supports physical addresses wider than 32 bits), due to the use of 1UL.

Quoted 8 lines

E.g.

#define IOMMU_PAGE_SIZE(sz) (1UL << PAGE_SHIFT_##sz)
#define IOMMU_PAGE_MASK(sz) (~(u64)0 << PAGE_SHIFT_##sz)
#define IOMMU_PAGE_ALIGN(sz, addr) (((addr) + ~PAGE_MASK_##sz) & PAGE_MASK_##sz)

#define PAGE_SIZE_4K IOMMU_PAGE_SIZE(4K)
etc.

I will use this solution.

Quoted 4 lines

Anyway,

for this small piece of non-ARM code, no matter whether you follow the advice.

Thanks!

Signature · 1 line
Julien Grall
#27 lore raw
In reply to Julien Grall
Quoted 2 lines · Julien Grall

Julien Grall (14):
xen/arm: Introduce flush_tlb_domain

Acked + applied.

Quoted 7 lines

xen/passthrough: amd: Remove domain_id from hvm_iommu xen/passthrough: amd: rename iommu_has_feature into
amd_iommu_has_feature
xen/passthrough: vtd: iommu_set_hwdom_mapping is VTD specific xen/passthrough: rework hwdom_pvh_reqs to use it also on ARM xen/passthrough: iommu: Split generic IOMMU code xen/passthrough: iommu: Introduce arch specific code

Jan already applied these, although I see that the penultimate patch is s/IOMMU // in the applied version -- perhaps from a previous revision? You should check.

Quoted 4 lines

xen/passthrough: iommu: Basic support of device tree assignment xen/passthrough: Introduce IOMMU ARM architecture
MAINTAINERS: Add drivers/passthrough/arm
xen/arm: Don't give IOMMU devices to dom0 when iommu is disabled

Applied these

Quoted 4 lines

xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent
walk
xen/arm: grant: Add another entry to map MFN 1:1 in dom0 p2m drivers/passthrough: arm: Add support for SMMU drivers

Discussion seems to be ongoing on the first and third and I wasn't sure about taking the third by itself.

Ian.

#28 lore raw
Quoted 14 lines · Ian Campbell
Quoted 2 lines · Julien Grall

Julien Grall (14):
xen/arm: Introduce flush_tlb_domain

Acked + applied.

Quoted 7 lines

xen/passthrough: amd: Remove domain_id from hvm_iommu xen/passthrough: amd: rename iommu_has_feature into
amd_iommu_has_feature
xen/passthrough: vtd: iommu_set_hwdom_mapping is VTD specific xen/passthrough: rework hwdom_pvh_reqs to use it also on ARM xen/passthrough: iommu: Split generic IOMMU code xen/passthrough: iommu: Introduce arch specific code

Quoted 2 lines

Jan already applied these, although I see that the penultimate patch is s/IOMMU // in the applied version -- perhaps from a previous revision?

No, Jan has reworking my commit title to drop superfluous word. He already did it on most of my past commit in common code.

Quoted 8 lines

You should check.

Quoted 4 lines

xen/passthrough: iommu: Basic support of device tree assignment xen/passthrough: Introduce IOMMU ARM architecture
MAINTAINERS: Add drivers/passthrough/arm
xen/arm: Don't give IOMMU devices to dom0 when iommu is disabled

Applied these

Thanks!

Quoted 7 lines
Quoted 4 lines

xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent
walk
xen/arm: grant: Add another entry to map MFN 1:1 in dom0 p2m drivers/passthrough: arm: Add support for SMMU drivers

Discussion seems to be ongoing on the first and third and I wasn't sure about taking the third by itself.

I guess you meant the second here? It's completely independent and can be applied.

Regards,

Signature · 1 line
Julien Grall
#29 lore raw
In reply to Ian Campbell
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 14.05.14 at 16:05, <[email protected]> wrote:
Quoted 7 lines · Julien Grall

xen/passthrough: amd: Remove domain_id from hvm_iommu xen/passthrough: amd: rename iommu_has_feature into
amd_iommu_has_feature
xen/passthrough: vtd: iommu_set_hwdom_mapping is VTD specific xen/passthrough: rework hwdom_pvh_reqs to use it also on ARM xen/passthrough: iommu: Split generic IOMMU code xen/passthrough: iommu: Introduce arch specific code

Quoted 2 lines

Jan already applied these, although I see that the penultimate patch is s/IOMMU // in the applied version -- perhaps from a previous revision?

No, it was this iteration. I just zapped the mostly duplicate first prefix.

Jan