iommu improvements
PATCH 1/2 amd-iommu: add flush iommu_ops
In reply to Paul DurrantThe iommu_ops structure contains two methods for flushing: 'iotlb_flush' and 'iotlb_flush_all'. This patch adds implementations of these for AMD IOMMUs.
The iotlb_flush method takes a base DFN and a (4k) page count, but the flush needs to be done by page order (i.e. 0, 9 or 18). Because a flush operation is fairly expensive to perform, the code calculates the minimum order single flush that will cover the specified page range rather than performing multiple flushes.
---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
--- xen/drivers/passthrough/amd/iommu_map.c | 48 +++++++++++++++++++++++++++ xen/drivers/passthrough/amd/pci_amd_iommu.c | 2 ++ xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 3 ++ xen/include/xen/iommu.h | 5 +++ 4 files changed, 58 insertions(+)
xen/drivers/passthrough/amd/iommu_map.c +48 -0
@@ -631,6 +631,54 @@ int amd_iommu_unmap_page(struct domain *d, dfn_t dfn)spin_unlock (&hd->arch.mapping_lock);amd_iommu_flush_pages (d,dfn_x (dfn),0 ); +return 0 ; +} + +static unsigned long flush_count (dfn_t dfn,unsigned int page_count, +unsigned int order) +{ +unsigned long start =dfn_x (dfn) / (1u << order); +unsigned long end =DIV_ROUND_UP (dfn_x (dfn) + page_count, + (1u << order)); + +ASSERT (end > start); +return end - start; +} + +int amd_iommu_flush_iotlb_pages (struct domain *d,dfn_t dfn, +unsigned int page_count) +{ +/* Match VT-d semantics */ +if ( !page_count ||dfn_eq (dfn,INVALID_DFN ) || +dfn_lt (dfn_add (dfn, page_count), dfn)/* overflow */ ) + { +amd_iommu_flush_all_pages (d); +return 0 ; + } + +/* +* Flushes are expensive so find the minimal single flush that will +* cover the page range. +* +* NOTE: It is unnecessary to round down the DFN value to align with +* the flush order here. This is done by the internals of the +* flush code. +*/ +if ( page_count ==1 )/* order 0 flush count */ +amd_iommu_flush_pages (d,dfn_x (dfn),0 ); +else if (flush_count (dfn, page_count,9 ) ==1 ) +amd_iommu_flush_pages (d,dfn_x (dfn),9 ); +else if (flush_count (dfn, page_count,18 ) ==1 ) +amd_iommu_flush_pages (d,dfn_x (dfn),18 ); +else +amd_iommu_flush_all_pages (d); + +return 0 ; +} + +int amd_iommu_flush_iotlb_all (struct domain *d) +{ +amd_iommu_flush_all_pages (d);return 0 ; }
xen/drivers/passthrough/amd/pci_amd_iommu.c +2 -0
@@ -579,6 +579,8 @@ static const struct iommu_ops __initconstrel amd_iommu_ops = { .teardown = amd_iommu_domain_destroy, .map_page = amd_iommu_map_page, .unmap_page = amd_iommu_unmap_page, + .iotlb_flush = amd_iommu_flush_iotlb_pages, + .iotlb_flush_all = amd_iommu_flush_iotlb_all, .free_page_table = deallocate_page_table, .reassign_device = reassign_device, .get_device_group_id = amd_iommu_group_id,
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +3 -0
@@ -60,6 +60,9 @@ int __must_check amd_iommu_alloc_root(struct domain_iommu *hd);int amd_iommu_reserve_domain_unity_map (struct domain *domain,paddr_t phys_addr,unsigned long size,int iw,int ir); +int __must_check amd_iommu_flush_iotlb_pages (struct domain *d,dfn_t dfn, +unsigned int page_count); +int __must_check amd_iommu_flush_iotlb_all (struct domain *d);/* Share p2m table with iommu */ void amd_iommu_share_p2m (struct domain *d);
xen/include/xen/iommu.h +5 -0
@@ -52,6 +52,11 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)return dfn_x (x) ==dfn_x (y); } +static inline bool_t dfn_lt (dfn_t x,dfn_t y) +{ +return dfn_x (x) <dfn_x (y); +} +extern bool_t iommu_enable, iommu_enabled;extern bool_t force_iommu, iommu_verbose;extern bool_t iommu_workaround_bios_bug, iommu_igfx;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
cover iommu improvements
Paul Durrant (2):
amd-iommu: add flush iommu_ops
iommu: elide flushing for higher order map/unmap operations
xen/drivers/passthrough/amd/iommu_map.c | 114 ++++++++++++++++++++------ xen/drivers/passthrough/amd/pci_amd_iommu.c | 2 + xen/drivers/passthrough/arm/smmu.c | 13 ++- xen/drivers/passthrough/iommu.c | 31 ++++++- xen/drivers/passthrough/vtd/iommu.c | 26 +++--- xen/drivers/passthrough/x86/iommu.c | 15 +++- xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 7 +- xen/include/xen/iommu.h | 18 +++- 8 files changed, 175 insertions(+), 51 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/2 iommu: elide flushing for higher order map/unmap operations
This patch removes any implicit flushing that occurs in the implementation of map and unmap operations and, instead, adds explicit flushing at the end of the loops in the iommu_map/unmap() wrapper functions.
Because VT-d currently performs two different types of flush dependent upon whether a PTE is being modified versus merely added (i.e. replacing a non- present PTE) a 'iommu_flush_type' enumeration is defined by this patch and the iommu_ops map method is modified to pass back the type of flush necessary for the PTE that has been populated. When a higher order mapping operation is done, the wrapper code performs the 'highest' level of flush required by the individual iommu_ops method calls, where a 'modified PTE' flush is deemed to be higher than a 'added PTE' flush. The ARM SMMU implementation currently performs no implicit flushing and therefore the modified map method always passes back a flush type of 'none'.
NOTE: The per-cpu 'iommu_dont_flush_iotlb' is respected by the iommu_map()
wrapper function and therefore this now applies to all IOMMU implementations rather than just VT-d. Use of the flag has been added to arch_iommu_hwdom_init() so that flushing is now fully elided for the hardware domain's initial table population.
---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Kevin Tian <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
This code has only been compile tested for ARM.
--- xen/drivers/passthrough/amd/iommu_map.c | 70 ++++++++++++++++----------- xen/drivers/passthrough/arm/smmu.c | 13 +++-- xen/drivers/passthrough/iommu.c | 31 ++++++++++-- xen/drivers/passthrough/vtd/iommu.c | 26 +++++----- xen/drivers/passthrough/x86/iommu.c | 15 ++++-- xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 8 +-- xen/include/xen/iommu.h | 13 ++++- 7 files changed, 121 insertions(+), 55 deletions(-)
xen/drivers/passthrough/amd/iommu_map.c +43 -27
@@ -45,13 +45,14 @@ static void clear_iommu_pte_present(unsigned long l1_mfn, unsigned long dfn)unmap_domain_page (table); } -static bool set_iommu_pde_present (uint32_t *pde,unsigned long next_mfn, -unsigned int next_level, -bool iw,bool ir) +static enum iommu_flush_type set_iommu_pde_present ( +uint32_t *pde,unsigned long next_mfn,unsigned int next_level,bool iw, +bool ir) {uint64_t maddr_next;uint32_t addr_lo, addr_hi, entry; -bool need_flush = false, old_present; +bool old_present; +enum iommu_flush_type flush_type = IOMMU_FLUSH_none; maddr_next =__pfn_to_paddr (next_mfn);
@@ -84,7 +85,7 @@ static bool set_iommu_pde_present(uint32_t *pde, unsigned long next_mfn,if ( maddr_old != maddr_next || iw != old_w || ir != old_r || old_level != next_level ) - need_flush = true; + flush_type = IOMMU_FLUSH_modified; } addr_lo = maddr_next &DMA_32BIT_MASK ;
@@ -121,24 +122,24 @@ static bool set_iommu_pde_present(uint32_t *pde, unsigned long next_mfn, IOMMU_PDE_PRESENT_SHIFT, &entry); pde[0 ] = entry; -return need_flush; +return flush_type; } -static bool set_iommu_pte_present (unsigned long pt_mfn,unsigned long dfn, -unsigned long next_mfn,int pde_level, -bool iw,bool ir) +static enum iommu_flush_type set_iommu_pte_present ( +unsigned long pt_mfn,unsigned long dfn,unsigned long next_mfn, +int pde_level,bool iw,bool ir) {uint64_t *table;uint32_t *pde; -bool need_flush; +enum iommu_flush_type flush_type; table =map_domain_page (_mfn (pt_mfn)); pde = (uint32_t *)(table +pfn_to_pde_idx (dfn, pde_level)); - need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir); + flush_type =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);unmap_domain_page (table); -return need_flush; +return flush_type; } void amd_iommu_set_root_page_table(uint32_t *dte, uint64_t root_ptr,
@@ -522,13 +523,15 @@ static int update_paging_mode(struct domain *d, unsigned long dfn) }int amd_iommu_map_page (struct domain *d,dfn_t dfn,mfn_t mfn, -unsigned int flags) +unsigned int flags, +enum iommu_flush_type *flush_type) { -bool need_flush;struct domain_iommu *hd =dom_iommu (d);int rc;unsigned long pt_mfn[7 ]; + *flush_type = IOMMU_FLUSH_none; +if (iommu_use_hap_pt (d) )return 0 ;
@@ -570,12 +573,9 @@ int amd_iommu_map_page(struct domain *d, dfn_t dfn, mfn_t mfn, }/* Install 4k mapping */ - need_flush =set_iommu_pte_present (pt_mfn[1 ],dfn_x (dfn),mfn_x (mfn),1 , - !!(flags & IOMMUF_writable), - !!(flags & IOMMUF_readable)); - -if ( need_flush ) -amd_iommu_flush_pages (d,dfn_x (dfn),0 ); + *flush_type =set_iommu_pte_present (pt_mfn[1 ],dfn_x (dfn),mfn_x (mfn), +1 , !!(flags & IOMMUF_writable), + !!(flags & IOMMUF_readable));spin_unlock (&hd->arch.mapping_lock);return 0 ;
@@ -629,8 +629,6 @@ int amd_iommu_unmap_page(struct domain *d, dfn_t dfn)clear_iommu_pte_present (pt_mfn[1 ],dfn_x (dfn));spin_unlock (&hd->arch.mapping_lock); - -amd_iommu_flush_pages (d,dfn_x (dfn),0 );return 0 ; }
@@ -646,8 +644,14 @@ static unsigned long flush_count(dfn_t dfn, unsigned int page_count, }int amd_iommu_flush_iotlb_pages (struct domain *d,dfn_t dfn, -unsigned int page_count) +unsigned int page_count, +enum iommu_flush_type flush_type) { +if ( flush_type == IOMMU_FLUSH_none) +return 0 ; + +ASSERT (flush_type == IOMMU_FLUSH_modified); +/* Match VT-d semantics */ if ( !page_count ||dfn_eq (dfn,INVALID_DFN ) ||dfn_lt (dfn_add (dfn, page_count), dfn)/* overflow */ )
@@ -687,10 +691,11 @@ int amd_iommu_reserve_domain_unity_map(struct domain *domain,paddr_t phys_addr, unsigned long size, int iw, int ir) { + enum iommu_flush_type flush_type = IOMMU_FLUSH_none;unsigned long npages, i;unsigned long gfn;unsigned int flags = !!ir; -int rt =0 ; +int ignored, rt =0 ;if ( iw ) flags |= IOMMUF_writable;
@@ -700,12 +705,23 @@ int amd_iommu_reserve_domain_unity_map(struct domain *domain,for ( i =0 ; i < npages; i++ ) {unsigned long frame = gfn + i; +enum iommu_flush_type this_flush_type; - rt =amd_iommu_map_page (domain,_dfn (frame),_mfn (frame), flags); + rt =amd_iommu_map_page (domain,_dfn (frame),_mfn (frame), flags, + &this_flush_type);if ( rt !=0 ) -return rt; +break ; + + flush_type =MAX (flush_type, this_flush_type); } -return 0 ; + +/* +* The underlying implementation is void so the return value is +* meaningless and can hence be ignored. +*/ + ignored =amd_iommu_flush_iotlb_pages (domain,_dfn (gfn), npages, + flush_type); +return rt; }/* Share p2m table with iommu. */
xen/drivers/passthrough/arm/smmu.c +9 -4
@@ -2534,8 +2534,9 @@ static int __must_check arm_smmu_iotlb_flush_all(struct domain *d)return 0 ; } -static int __must_check arm_smmu_iotlb_flush (struct domain *d,dfn_t dfn, -unsigned int page_count) +static int __must_check arm_smmu_iotlb_flush ( +struct domain *d,dfn_t dfn,unsigned int page_count, +enum iommu_flush_type flush_type) {/* ARM SMMU v1 doesn't have flush by VMA and VMID */ return arm_smmu_iotlb_flush_all (d);
@@ -2731,8 +2732,9 @@ static void arm_smmu_iommu_domain_teardown(struct domain *d)xfree (xen_domain); } -static int __must_check arm_smmu_map_page (struct domain *d,dfn_t dfn, -mfn_t mfn,unsigned int flags) +static int __must_check arm_smmu_map_page ( +struct domain *d,dfn_t dfn,mfn_t mfn,unsigned int flags, +enum iommu_flush_type *flush_type) {p2m_type_t t;
@@ -2753,6 +2755,9 @@ static int __must_check arm_smmu_map_page(struct domain *d, dfn_t dfn, t = (flags & IOMMUF_writable) ? p2m_iommu_map_rw : p2m_iommu_map_ro; +/* Flushing is always done explicitly by th P2M code */ + *flush_type = IOMMU_FLUSH_none; +/* * The function guest_physmap_add_entry replaces the current mapping * if there is already one...
xen/drivers/passthrough/iommu.c +28 -3
@@ -219,6 +219,7 @@ void __hwdom_init iommu_hwdom_init(struct domain *d)unsigned long mfn =mfn_x (page_to_mfn (page));unsigned long dfn =mfn_to_gmfn (d, mfn);unsigned int mapping = IOMMUF_readable; +enum iommu_flush_type flush_type;int ret; if ( ((page->u.inuse.type_info & PGT_count_mask) == 0) ||
@@ -227,7 +228,7 @@ void __hwdom_init iommu_hwdom_init(struct domain *d) mapping |= IOMMUF_writable; ret = hd->platform_ops->map_page (d,_dfn (dfn),_mfn (mfn), - mapping); + mapping, &flush_type);if ( !rc ) rc = ret;
@@ -235,6 +236,9 @@ void __hwdom_init iommu_hwdom_init(struct domain *d)process_pending_softirqs (); } +if ( !rc && hd->platform_ops->iotlb_flush_all ) + rc = hd->platform_ops->iotlb_flush_all (d); +if ( rc )printk (XENLOG_WARNING "d%d: IOMMU mapping failed: %d\n" , d->domain_id, rc);
@@ -308,6 +312,7 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn, unsigned int page_order, unsigned int flags) {const struct domain_iommu *hd =dom_iommu (d); +enum iommu_flush_type flush_type = IOMMU_FLUSH_none;unsigned long i;int rc =0 ;
@@ -319,11 +324,18 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,for ( i =0 ; i < (1ul << page_order); i++ ) { +enum iommu_flush_type this_flush_type; +int ignore; + rc = hd->platform_ops->map_page (d,dfn_add (dfn, i), -mfn_add (mfn, i), flags); +mfn_add (mfn, i), flags, + &this_flush_type);if (likely (!rc) ) + { + flush_type =MAX (flush_type, this_flush_type);continue ; + }if ( !d->is_shutting_down &&printk_ratelimit () ) printk(XENLOG_ERR
@@ -336,12 +348,19 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,if ( hd->platform_ops->unmap_page (d,dfn_add (dfn, i)) )continue ; +/* Something went wrong so attempt a full flush */ + ignore = hd->platform_ops->iotlb_flush_all (d); +if ( !is_hardware_domain (d) )domain_crash (d);break ; } +if ( hd->platform_ops->iotlb_flush && !this_cpu (iommu_dont_flush_iotlb) ) + rc = hd->platform_ops->iotlb_flush (d, dfn, (1ul << page_order), + flush_type); +return rc; }
@@ -378,6 +397,10 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned int page_order) } } +if ( hd->platform_ops->iotlb_flush ) + rc = hd->platform_ops->iotlb_flush (d, dfn, (1ul << page_order), + IOMMU_FLUSH_modified); +return rc; }
@@ -417,7 +440,9 @@ int iommu_iotlb_flush(struct domain *d, dfn_t dfn, unsigned int page_count)if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush )return 0 ; - rc = hd->platform_ops->iotlb_flush (d, dfn, page_count); +/* Assume a 'modified' flush is required */ + rc = hd->platform_ops->iotlb_flush (d, dfn, page_count, + IOMMU_FLUSH_modified);if (unlikely (rc) ) {if ( !d->is_shutting_down &&printk_ratelimit () )
xen/drivers/passthrough/vtd/iommu.c +14 -12
@@ -631,11 +631,14 @@ static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn,return rc; } -static int __must_check iommu_flush_iotlb_pages (struct domain *d, -dfn_t dfn, -unsigned int page_count) +static int __must_check iommu_flush_iotlb_pages ( +struct domain *d,dfn_t dfn,unsigned int page_count, +enum iommu_flush_type flush_type) { -return iommu_flush_iotlb (d, dfn,1 , page_count); +return (flush_type == IOMMU_FLUSH_none) ? +0 : +iommu_flush_iotlb (d, dfn, (flush_type == IOMMU_FLUSH_modified), + page_count); }static int __must_check iommu_flush_iotlb_all (struct domain *d)
@@ -674,9 +677,6 @@ static int __must_check dma_pte_clear_one(struct domain *domain, u64 addr)spin_unlock (&hd->arch.mapping_lock);iommu_flush_cache_entry (pte,sizeof (struct dma_pte )); -if ( !this_cpu (iommu_dont_flush_iotlb) ) - rc =iommu_flush_iotlb_pages (domain,daddr_to_dfn (addr),1 ); -unmap_vtd_domain_page (page);return rc;
@@ -1771,15 +1771,17 @@ static void iommu_domain_teardown(struct domain *d)spin_unlock (&hd->arch.mapping_lock); } -static int __must_check intel_iommu_map_page (struct domain *d, -dfn_t dfn,mfn_t mfn, -unsigned int flags) +static int __must_check intel_iommu_map_page ( +struct domain *d,dfn_t dfn,mfn_t mfn,unsigned int flags, +enum iommu_flush_type *flush_type) {struct domain_iommu *hd =dom_iommu (d);struct dma_pte *page, *pte, old, new = {};u64 pg_maddr;int rc =0 ; + *flush_type = IOMMU_FLUSH_none; +/* Do nothing if VT-d shares EPT page table */ if (iommu_use_hap_pt (d) )return 0 ;
@@ -1823,8 +1825,8 @@ static int __must_check intel_iommu_map_page(struct domain *d,spin_unlock (&hd->arch.mapping_lock);unmap_vtd_domain_page (page); -if ( !this_cpu (iommu_dont_flush_iotlb) ) - rc =iommu_flush_iotlb (d, dfn,dma_pte_present (old),1 ); + *flush_type =dma_pte_present (old) ? + IOMMU_FLUSH_modified : IOMMU_FLUSH_added;return rc; }
xen/drivers/passthrough/x86/iommu.c +11 -4
@@ -50,7 +50,6 @@ int arch_iommu_populate_page_table(struct domain *d)struct page_info *page;int rc =0 , n =0 ; -this_cpu (iommu_dont_flush_iotlb) =1 ;spin_lock (&d->page_alloc_lock);if (unlikely (d->is_dying) )
@@ -63,6 +62,7 @@ int arch_iommu_populate_page_table(struct domain *d) {unsigned long mfn =mfn_x (page_to_mfn (page));unsigned long gfn =mfn_to_gmfn (d, mfn); +enum iommu_flush_type flush_type;if ( gfn !=gfn_x (INVALID_GFN ) ) {
@@ -70,7 +70,8 @@ int arch_iommu_populate_page_table(struct domain *d)BUG_ON (SHARED_M2P (gfn)); rc = hd->platform_ops->map_page (d,_dfn (gfn),_mfn (mfn), IOMMUF_readable | - IOMMUF_writable); + IOMMUF_writable, + &flush_type); }if ( rc ) {
@@ -104,7 +105,6 @@ int arch_iommu_populate_page_table(struct domain *d) }spin_unlock (&d->page_alloc_lock); -this_cpu (iommu_dont_flush_iotlb) =0 ;if ( !rc ) rc =iommu_iotlb_flush_all (d);
@@ -207,6 +207,7 @@ static bool __hwdom_init hwdom_iommu_map(const struct domain *d, void __hwdom_init arch_iommu_hwdom_init(struct domain *d) {unsigned long i, top, max_pfn; +int rc;BUG_ON (!is_hardware_domain (d));
@@ -230,10 +231,10 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d) max_pfn = (GB (4 ) >>PAGE_SHIFT ) -1 ; top =max (max_pdx,pfn_to_pdx (max_pfn) +1 ); +this_cpu (iommu_dont_flush_iotlb) =1 ;for ( i =0 ; i < top; i++ ) {unsigned long pfn =pdx_to_pfn (i); -int rc;if ( !hwdom_iommu_map (d, pfn, max_pfn) )continue ;
@@ -250,6 +251,12 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)if (!(i &0xfffff ))process_pending_softirqs (); } +this_cpu (iommu_dont_flush_iotlb) =0 ; + + rc =iommu_iotlb_flush_all (d); +if ( rc ) +printk (XENLOG_WARNING " d%d: IOMMU flush failed: %d\n" , + d->domain_id, rc); }/*
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +5 -3
@@ -53,15 +53,17 @@ int amd_iommu_update_ivrs_mapping_acpi(void);/* mapping functions */ int __must_check amd_iommu_map_page (struct domain *d,dfn_t dfn, -mfn_t mfn,unsigned int flags); +mfn_t mfn,unsigned int flags, +enum iommu_flush_type *flush_type);int __must_check amd_iommu_unmap_page (struct domain *d,dfn_t dfn);uint64_t amd_iommu_get_address_from_pte (void *entry);int __must_check amd_iommu_alloc_root (struct domain_iommu *hd);int amd_iommu_reserve_domain_unity_map (struct domain *domain,paddr_t phys_addr,unsigned long size,int iw,int ir); -int __must_check amd_iommu_flush_iotlb_pages (struct domain *d,dfn_t dfn, -unsigned int page_count); +int __must_check amd_iommu_flush_iotlb_pages ( +struct domain *d,dfn_t dfn,unsigned int page_count, +enum iommu_flush_type flush_type);int __must_check amd_iommu_flush_iotlb_all (struct domain *d);/* Share p2m table with iommu */
xen/include/xen/iommu.h +11 -2
@@ -155,6 +155,13 @@ struct page_info;*/ typedef int iommu_grdm_t (xen_pfn_t start,xen_ulong_t nr,u32 id,void *ctxt); +enum iommu_flush_type +{ + IOMMU_FLUSH_none,/* no flush required */ + IOMMU_FLUSH_added,/* no modified entries, just additional entries */ + IOMMU_FLUSH_modified,/* modified entries */ +}; +struct iommu_ops {int (*init)(struct domain *d);void (*hwdom_init)(struct domain *d);
@@ -177,7 +184,8 @@ struct iommu_ops {* other by the caller in order to have meaningful results. */ int __must_check (*map_page)(struct domain *d,dfn_t dfn,mfn_t mfn, -unsigned int flags); +unsigned int flags, +enum iommu_flush_type *flush_type);int __must_check (*unmap_page)(struct domain *d,dfn_t dfn);int __must_check (*lookup_page)(struct domain *d,dfn_t dfn,mfn_t *mfn,unsigned int *flags);
@@ -193,7 +201,8 @@ struct iommu_ops {void (*share_p2m)(struct domain *d);void (*crash_shutdown)(void );int __must_check (*iotlb_flush)(struct domain *d,dfn_t dfn, -unsigned int page_count); +unsigned int page_count, +enum iommu_flush_type flush_type);int __must_check (*iotlb_flush_all)(struct domain *d);int (*get_reserved_device_memory)(iommu_grdm_t *,void *);void (*dump_p2m_table)(struct domain *d);
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operations
Quoted 15 lines · Paul Durrant
This patch removes any implicit flushing that occurs in the implementation of map and unmap operations and, instead, adds explicit flushing at the end of the loops in the iommu_map/unmap() wrapper functions.
Because VT-d currently performs two different types of flush dependent upon whether a PTE is being modified versus merely added (i.e. replacing a non- present PTE) a '
iommu_flush_type' enumeration is defined by this patch and theiommu_opsmap method is modified to pass back the type of flush necessary for the PTE that has been populated. When a higher order mapping operation is done, the wrapper code performs the 'highest' level of flush required by the individualiommu_opsmethod calls, where a 'modified PTE' flush is deemed to be higher than a 'added PTE' flush. The ARM SMMU implementation currently performs no implicit flushing and therefore the modified map method always passes back a flush type of 'none'.
Quoted 5 lines
NOTE: The per-cpu '
iommu_dont_flush_iotlb' is respected by theiommu_map()
wrapper function and therefore this now applies to all IOMMU implementations rather than just VT-d. Use of the flag has been added toarch_iommu_hwdom_init()so that flushing is now fully elided for the hardware domain's initial table population.
iommu_dont_flush_iotlb is a misfeature. While it still exists, the flushing API is fundamentally broken.
Do you have a plan to remove it? I ask, because the only feasible option I see is for iommu_{map,unmap}() to pass the flush accumulation out to the caller, and have the caller use the appropriate flush interfaces.
[Edit - lunch happened around about this point, and there was a long discussion]
One idea with be to start with a prep patch renaming iommu_{,un}map() to _legacy(), nothing beside them that they have implicit flushing characteristics. Then, the nonflushing versions of iommu_{,un}map() can be introduced, which return the accumulated flush flag, and the callers can DTRT.
This way, we can avoid introducing a further user of iommu_dont_flush_iotlb in arch_iommu_hwdom_init(), and clean up the remaining legacy callsites at a later point when more infrastructure is in place.
In particular, the P2M code cannot be fixed to behave in this way at the moment because the point at which the IOMMU changes are hooked in lacks an order parameter.
xen/include/xen/iommu.h struct page_info; · line 157
Quoted 8 lines
xen/include/xen/iommu.h +0
-0@@ -155,6 +155,13 @@ struct page_info;*/ typedef int iommu_grdm_t (xen_pfn_t start,xen_ulong_t nr,u32 id,void *ctxt);
This wants at least a comment stating that some IOMMUs require that we issue a flush when modifying a not-present/otherwise invalid entry.
xen/include/xen/iommu.h struct page_info; · line 161
Quoted 4 lines
xen/include/xen/iommu.h +4
-0+enum iommu_flush_type +{ + IOMMU_FLUSH_none,/* no flush required */ + IOMMU_FLUSH_added,/* no modified entries, just additional entries */
IOMMU_FLUSH_invalid ? I think it is more descriptive of the scenario in which it is used.
xen/include/xen/iommu.h struct iommu_ops { · line 188
Quoted 13 lines
xen/include/xen/iommu.h +5
-1+ IOMMU_FLUSH_modified, /* modified entries */ +}; +struct iommu_ops {int (*init)(struct domain *d);void (*hwdom_init)(struct domain *d);@@ -177,7 +184,8 @@ struct iommu_ops {* other by the caller in order to have meaningful results. */ int __must_check (*map_page)(struct domain *d,dfn_t dfn,mfn_t mfn, -unsigned int flags); +unsigned int flags, +enum iommu_flush_type *flush_type);
Maintaining the flush type by pointer is quite awkward.
How about folding a positive flush type in with negative errors? i.e. map_page() becomes < 0 on error, 0 for success/no flush and >0 for success/w flush.
I think the result would be rather cleaner to read.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/2] amd-iommu: add flush iommu_ops
In reply to Paul DurrantQuoted 14 lines · Paul Durrant
xen/drivers/passthrough/amd/iommu_map.c +6
-0@@ -631,6 +631,54 @@ int amd_iommu_unmap_page(struct domain *d, dfn_t dfn)spin_unlock (&hd->arch.mapping_lock);amd_iommu_flush_pages (d,dfn_x (dfn),0 ); +return 0 ; +} + +static unsigned long flush_count (dfn_t dfn,unsigned int page_count, +unsigned int order) +{
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_unmap_page(struct domain *d, dfn_t dfn) · line 649
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_map.c +10
-0+unsigned long start =dfn_x (dfn) / (1u << order); +unsigned long end =DIV_ROUND_UP (dfn_x (dfn) + page_count, + (1u << order)); + +ASSERT (end > start); +return end - start; +} + +int amd_iommu_flush_iotlb_pages (struct domain *d,dfn_t dfn, +unsigned int page_count)
What are the semantics here? Why page_count rather than order? Are we guaranteed to be actually flushing consecutive dfn's ?
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_unmap_page(struct domain *d, dfn_t dfn) · line 652
Quoted 3 lines
xen/drivers/passthrough/amd/iommu_map.c +3
-0+{ +/* Match VT-d semantics */ + if ( !page_count || dfn_eq(dfn, INVALID_DFN) ||
Do we really have callers passing these? I'd argue that these should be invalid to pass (accepting that we might need to tolerate them until other cleanup can occur).
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_unmap_page(struct domain *d, dfn_t dfn) · line 653
Quoted 1 line
xen/drivers/passthrough/amd/iommu_map.c +1
-0+ dfn_lt(dfn_add(dfn, page_count), dfn) /* overflow */ )
Given that all users of dfn here want it in unsigned long form, I'd make a local dfn_l and use that. I'm not sure that we want to start accumulating a sporadic set of binary operator functions for the typesafe variables.
xen/include/xen/iommu.h static inline bool_t dfn_eq(dfn_t x, dfn_t y) · line 55
Quoted 9 lines
xen/include/xen/iommu.h +1
-0@@ -52,6 +52,11 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)return dfn_x (x) ==dfn_x (y); } +static inline bool_t dfn_lt (dfn_t x,dfn_t y)
No new introductions of bool_t please. dfn_eq() shouldn't have been bool_t either.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/2] amd-iommu: add flush iommu_ops
Quoted 30 lines
-----Original Message-----
From: Andrew Cooper
Sent: 30 November 2018 13:04
To: Paul Durrant <[email protected]>; [email protected]
Cc: Suravee Suthikulpanit <[email protected]>; Brian Woods <[email protected]>; Jan Beulich <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [PATCH 1/2] amd-iommu: add flushiommu_opsReview
Quoted 1 line · Paul Durrant
(quoted diff) +0
-0
b/xen/drivers/passthrough/amd/iommu_map.cxen/drivers/passthrough/amd/iommu_map.c int amd_iommu_unmap_page(struct domain *d, dfn_t
Quoted 4 lines
index
04cb7b3182..c05b042821100644xen/drivers/passthrough/amd/iommu_map.c +0
-0@@ -631,6 +631,54 @@ int amd_iommu_unmap_page(struct domain *d, dfn_tdfn)
Quoted 13 lines
xen/drivers/passthrough/amd/iommu_map.c +10
-0spin_unlock (&hd->arch.mapping_lock);amd_iommu_flush_pages (d,dfn_x (dfn),0 ); +return 0 ; +} + +static unsigned long flush_count (dfn_t dfn,unsigned int page_count, +unsigned int order) +{ +unsigned long start =dfn_x (dfn) / (1u << order); +unsigned long end =DIV_ROUND_UP (dfn_x (dfn) + page_count, + (1u << order)); +
Quoted 8 lines
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_unmap_page(struct domain *d, dfn_t dfn) · line 649
Quoted 6 lines
xen/drivers/passthrough/amd/iommu_map.c +6
-0+ASSERT (end > start); +return end - start; +} + +int amd_iommu_flush_iotlb_pages (struct domain *d,dfn_t dfn, +unsigned int page_count)What are the semantics here? Why
page_countrather than order?
Because that's the way the iommu_ops method is declared in the header?
Quoted 2 lines
Are we
guaranteed to be actually flushing consecutive dfn's ?
I believe so. Looking at the wrapper code and its callers, that seems to be the assumption.
Quoted 8 lines
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_unmap_page(struct domain *d, dfn_t dfn) · line 652
Quoted 4 lines
xen/drivers/passthrough/amd/iommu_map.c +3
-0+{ +/* Match VT-d semantics */ + if ( !page_count || dfn_eq(dfn, INVALID_DFN) ||Do we really have callers passing these? I'd argue that these should be invalid to pass (accepting that we might need to tolerate them until other cleanup can occur).
I could look at cleaning that up. There aren't many callers.
Quoted 8 lines
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_unmap_page(struct domain *d, dfn_t dfn) · line 653
Quoted 2 lines
xen/drivers/passthrough/amd/iommu_map.c +1
-0+ dfn_lt(dfn_add(dfn, page_count), dfn) /* overflow */ )Given that all users of dfn here want it in unsigned long form, I'd make a local
dfn_land use that. I'm not sure that we want to start accumulating a sporadic set of binary operator functions for the typesafe variables.
Ok, I don't really mind. I thought it was neater this way though.
Quoted 8 lines
Quoted 8 lines
xen/include/xen/iommu.h +0
-0@@ -52,6 +52,11 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)return dfn_x (x) ==dfn_x (y); }
Quoted 4 lines
xen/include/xen/iommu.h static inline bool_t dfn_eq(dfn_t x, dfn_t y) · line 55
Quoted 1 line
xen/include/xen/iommu.h +1
-0+static inline bool_t dfn_lt (dfn_t x,dfn_t y)No new introductions of
bool_tplease.dfn_eq()shouldn't have beenbool_teither.
Oops, yes. Cut'n'pasted the wrong thing.
Paul
Quoted 2 lines
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operations
In reply to Andrew CooperQuoted 52 lines
-----Original Message-----
From: Andrew Cooper
Sent: 30 November 2018 12:49
To: Paul Durrant <[email protected]>; [email protected]
Cc: Stefano Stabellini <[email protected]>; Julien Grall <[email protected]>; Suravee Suthikulpanit <[email protected]>; Brian Woods <[email protected]>; Jan Beulich <[email protected]>; Kevin Tian <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operationsQuoted 1 line · Paul Durrant
This patch removes any implicit flushing that occurs in the
implementation
Quoted 4 lines
of map and unmap operations and, instead, adds explicit flushing at the end of the loops in the iommu_map/unmap() wrapper functions.
Because VT-d currently performs two different types of flush dependent
upon
Quoted 1 line
whether a PTE is being modified versus merely added (i.e. replacing a
non-
Quoted 1 line
present PTE) a '
iommu_flush_type' enumeration is defined by this patchand
Quoted 2 lines
the
iommu_opsmap method is modified to pass back the type of flush necessary for the PTE that has been populated. When a higher ordermapping
Quoted 1 line
operation is done, the wrapper code performs the 'highest' level of
flush
Quoted 1 line
required by the individual
iommu_opsmethod calls, where a 'modifiedPTE'
Quoted 5 lines
flush is deemed to be higher than a 'added PTE' flush. The ARM SMMU implementation currently performs no implicit flushing and therefore the modified map method always passes back a flush type of 'none'.
NOTE: The per-cpu '
iommu_dont_flush_iotlb' is respected by the
iommu_map()Quoted 2 lines
wrapper function and therefore this now applies to all IOMMU implementations rather than just VT-d. Use of the flag has been
added
Quoted 1 line
to
arch_iommu_hwdom_init()so that flushing is now fully elidedfor
Quoted 1 line
the hardware domain's initial table population.
iommu_dont_flush_iotlbis a misfeature. While it still exists, the flushing API is fundamentally broken.Do you have a plan to remove it? I ask, because the only feasible option I see is for iommu_{map,unmap}() to pass the flush accumulation out to the caller, and have the caller use the appropriate flush interfaces.
Quoted 8 lines
[Edit - lunch happened around about this point, and there was a long discussion]
One idea with be to start with a prep patch renaming iommu_{,un}map() to
_legacy(), nothing beside them that they have implicit flushing characteristics. Then, the nonflushing versions of iommu_{,un}map() can be introduced, which return the accumulated flush flag, and the callers can DTRT.
Ok. I'll plan to do a new patch #2 that does the rename, and the move this code into a patch #3.
Quoted 9 lines
This way, we can avoid introducing a further user of
iommu_dont_flush_iotlbinarch_iommu_hwdom_init(), and clean up the remaining legacy callsites at a later point when more infrastructure is in place.In particular, the P2M code cannot be fixed to behave in this way at the moment because the point at which the IOMMU changes are hooked in lacks an order parameter.
The P2M code is also a mess and calls directly into VT-d and AMD IOMMU functions without going through the wrapper code in some cases. There is much cleanup to do... these patches are just a start.
Paul
Quoted 40 lines
xen/include/xen/iommu.h struct page_info; · line 156
Quoted 8 lines
xen/include/xen/iommu.h +0
-0@@ -155,6 +155,13 @@ struct page_info;*/ typedef int iommu_grdm_t(xen_pfn_t start, xen_ulong_t nr, u32 id, void*ctxt);
Quoted 1 line
This wants at least a comment stating that some IOMMUs require that we issue a flush when modifying a not-present/otherwise invalid entry.
xen/include/xen/iommu.h struct page_info;
Quoted 4 lines
xen/include/xen/iommu.h +4
-0+enum iommu_flush_type +{ + IOMMU_FLUSH_none,/* no flush required */ + IOMMU_FLUSH_added,/* no modified entries, just additional entries */
IOMMU_FLUSH_invalid? I think it is more descriptive of the scenario in which it is used.xen/include/xen/iommu.h struct iommu_ops { · line 186
Quoted 10 lines
xen/include/xen/iommu.h +3
-0+ IOMMU_FLUSH_modified, /* modified entries */ +}; +struct iommu_ops {int (*init)(struct domain *d);void (*hwdom_init)(struct domain *d);@@ -177,7 +184,8 @@ struct iommu_ops {* other by the caller in order to have meaningful results. */ int __must_check (*map_page)(struct domain *d, dfn_t dfn, mfn_tmfn,
xen/include/xen/iommu.h struct iommu_ops { · line 188
Quoted 3 lines
xen/include/xen/iommu.h +2
-1- unsigned int flags); +unsigned int flags, + enum iommu_flush_type *flush_type);Maintaining the flush type by pointer is quite awkward.
Quoted 7 lines
How about folding a positive flush type in with negative errors? i.e.
map_page()becomes < 0 on error, 0 for success/no flush and >0 for success/w flush.I think the result would be rather cleaner to read.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operations
In reply to Andrew CooperQuoted 9 lines
Quoted 1 line
Quoted 1 line · On 30.11.18 at 13:49, <[email protected]> wrote:
xen/include/xen/iommu.h struct page_info; · line 161
Quoted 4 lines · Paul Durrant
xen/include/xen/iommu.h +4
-0+enum iommu_flush_type +{ + IOMMU_FLUSH_none,/* no flush required */ + IOMMU_FLUSH_added,/* no modified entries, just additional entries */
IOMMU_FLUSH_invalid? I think it is more descriptive of the scenario in which it is used.
This reads in a pretty misleading way to me. IOMMU_FLUSH_new or IOMMU_FLUSH_new_ents perhaps? Otoh I was quite okay with the name Paul had chosen.
Quoted 10 lines
xen/include/xen/iommu.h struct iommu_ops { · line 188
Quoted 7 lines
xen/include/xen/iommu.h +2
-1@@ -177,7 +184,8 @@ struct iommu_ops {* other by the caller in order to have meaningful results. */ int __must_check (*map_page)(struct domain *d,dfn_t dfn,mfn_t mfn, -unsigned int flags); +unsigned int flags, +enum iommu_flush_type *flush_type);Maintaining the flush type by pointer is quite awkward.
Quoted 5 lines
How about folding a positive flush type in with negative errors? i.e.
map_page()becomes < 0 on error, 0 for success/no flush and >0 for success/w flush.I think the result would be rather cleaner to read.
It would, but mapping operations with higher orders may fail _and_ require flushing.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operations
Quoted 21 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 03 December 2018 10:21
To: Andrew Cooper <[email protected]>; Paul Durrant <[email protected]>
Cc: Brian Woods <[email protected]>; Suravee Suthikulpanit <[email protected]>; Julien Grall <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <[email protected]>
Subject: Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operationsQuoted 6 lines
Quoted 1 line
Quoted 1 line · On 30.11.18 at 13:49, <[email protected]> wrote:
xen/include/xen/iommu.h struct page_info;
Quoted 4 lines · Paul Durrant
xen/include/xen/iommu.h +4
-0+enum iommu_flush_type +{ + IOMMU_FLUSH_none,/* no flush required */ + IOMMU_FLUSH_added,/* no modified entries, just additional entries */
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
IOMMU_FLUSH_invalid? I think it is more descriptive of the scenario in which it is used.This reads in a pretty misleading way to me.
IOMMU_FLUSH_neworIOMMU_FLUSH_new_entsperhaps? Otoh I was quite okay with the name Paul had chosen.
I'll stick with those then :-)
Quoted 12 lines
Quoted 5 lines
xen/include/xen/iommu.h struct iommu_ops { · line 186
Quoted 5 lines
xen/include/xen/iommu.h +0
-0@@ -177,7 +184,8 @@ struct iommu_ops {* other by the caller in order to have meaningful results. */ int __must_check (*map_page)(struct domain *d, dfn_t dfn, mfn_tmfn,
Quoted 6 lines
xen/include/xen/iommu.h struct iommu_ops { · line 188
Quoted 3 lines
xen/include/xen/iommu.h +2
-1- unsigned int flags); +unsigned int flags, + enum iommu_flush_type *flush_type);Maintaining the flush type by pointer is quite awkward.
Quoted 9 lines
Quoted 5 lines
How about folding a positive flush type in with negative errors? i.e.
map_page()becomes < 0 on error, 0 for success/no flush and >0 for success/w flush.I think the result would be rather cleaner to read.
It would, but mapping operations with higher orders may fail _and_ require flushing.
Agreed. I did not want to confuse the error semantics with the flush semantics. There is no order at this level as yet but, when one is added, this separation - as you say - will become important.
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operations
In reply to Paul DurrantQuoted 5 lines
Quoted 1 line
Quoted 1 line · On 30.11.18 at 11:45, <[email protected]> wrote:
This patch removes any implicit flushing that occurs in the implementation of map and unmap operations and, instead, adds explicit flushing at the end of the loops in the iommu_map/unmap() wrapper functions.
Quoted 8 lines
Because VT-d currently performs two different types of flush dependent upon whether a PTE is being modified versus merely added (i.e. replacing a non- present PTE) a '
iommu_flush_type' enumeration is defined by this patch and theiommu_opsmap method is modified to pass back the type of flush necessary for the PTE that has been populated. When a higher order mapping operation is done, the wrapper code performs the 'highest' level of flush required by the individualiommu_opsmethod calls, where a 'modified PTE' flush is deemed to be higher than a 'added PTE' flush.
I'm afraid such ordering properties may not generally exist. That is, what you pass the flush handlers needs to be an OR of "added new entries" and "modified existing entries". That's because at least in the abstract case it may be that distinct flushes need to be issued for both cases (i.e. potentially two of them).
Quoted 12 lines
xen/drivers/passthrough/amd/iommu_map.c +4
-4-static bool set_iommu_pte_present (unsigned long pt_mfn,unsigned long dfn, -unsigned long next_mfn,int pde_level, -bool iw,bool ir) +static enum iommu_flush_type set_iommu_pte_present ( +unsigned long pt_mfn,unsigned long dfn,unsigned long next_mfn, +int pde_level,bool iw,bool ir) {uint64_t *table;uint32_t *pde; -bool need_flush; +enum iommu_flush_type flush_type;
xen/drivers/passthrough/amd/iommu_map.c static bool set_iommu_pde_present(uint32_t *pde, unsigned long next_mfn, · line 143
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_map.c +2
-2table =map_domain_page (_mfn (pt_mfn)); pde = (uint32_t *)(table +pfn_to_pde_idx (dfn, pde_level)); - need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir); + flush_type =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);unmap_domain_page (table); -return need_flush; +return flush_type; }
Please take the opportunity and add the missing blank line.
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_unmap_page(struct domain *d, dfn_t dfn) · line 633
Quoted 8 lines
xen/drivers/passthrough/amd/iommu_map.c +0
-2@@ -629,8 +629,6 @@ int amd_iommu_unmap_page(struct domain *d, dfn_t dfn)clear_iommu_pte_present (pt_mfn[1 ],dfn_x (dfn));spin_unlock (&hd->arch.mapping_lock); - -amd_iommu_flush_pages (d,dfn_x (dfn),0 );return 0 ; }
Please retain the blank line.
Quoted 13 lines
xen/drivers/passthrough/amd/iommu_map.c +5
-2@@ -700,12 +705,23 @@ int amd_iommu_reserve_domain_unity_map(struct domain *domain,for ( i =0 ; i < npages; i++ ) {unsigned long frame = gfn + i; +enum iommu_flush_type this_flush_type; - rt =amd_iommu_map_page (domain,_dfn (frame),_mfn (frame), flags); + rt =amd_iommu_map_page (domain,_dfn (frame),_mfn (frame), flags, + &this_flush_type);if ( rt !=0 ) -return rt; +break ; +
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_reserve_domain_unity_map(struct domain *domain, · line 723
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_map.c +8
-1+ flush_type =MAX (flush_type, this_flush_type); } -return 0 ; + +/* +* The underlying implementation is void so the return value is +* meaningless and can hence be ignored. +*/ + ignored =amd_iommu_flush_iotlb_pages (domain,_dfn (gfn), npages, + flush_type);
I'm afraid such an assignment without subsequent use can be (legitimately) warned about by compilers. Hence the approach I had asked you to restore in one of your earlier patches. The exact same one won't fit here, but while ( ... ) break; should. Same then elsewhere.
Quoted 5 lines
xen/drivers/passthrough/iommu.c +1
-0@@ -319,11 +324,18 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,for ( i =0 ; i < (1ul << page_order); i++ ) { +enum iommu_flush_type this_flush_type;
xen/drivers/passthrough/iommu.c int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn, · line 336
Quoted 10 lines
xen/drivers/passthrough/iommu.c +6
-1+int ignore; + rc = hd->platform_ops->map_page (d,dfn_add (dfn, i), -mfn_add (mfn, i), flags); +mfn_add (mfn, i), flags, + &this_flush_type);if (likely (!rc) ) + { + flush_type =MAX (flush_type, this_flush_type);
With the comment above this is unlikely to stay anyway, but if it does please use max() instead. At least I can't see why you couldn't use the typesafe variant here.
Quoted 5 lines
xen/drivers/passthrough/iommu.c +1
-0@@ -336,12 +348,19 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,if ( hd->platform_ops->unmap_page (d,dfn_add (dfn, i)) )continue ; +/* Something went wrong so attempt a full flush */
xen/drivers/passthrough/iommu.c int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn, · line 361
Quoted 10 lines
xen/drivers/passthrough/iommu.c +4
-0+ ignore = hd->platform_ops->iotlb_flush_all (d); +if ( !is_hardware_domain (d) )domain_crash (d);break ; } +if ( hd->platform_ops->iotlb_flush && !this_cpu (iommu_dont_flush_iotlb) ) + rc = hd->platform_ops->iotlb_flush(d, dfn, (1ul << page_order),
1u only please, since the function parameter is unsigned int.
xen/drivers/passthrough/iommu.c int iommu_unmap(struct domain *d, dfn_t dfn, unsigned int page_order) · line 401
Quoted 6 lines
xen/drivers/passthrough/iommu.c +2
-0@@ -378,6 +397,10 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned int page_order) } } +if ( hd->platform_ops->iotlb_flush ) + rc = hd->platform_ops->iotlb_flush(d, dfn, (1ul << page_order),
Same here.
xen/drivers/passthrough/iommu.c int iommu_iotlb_flush(struct domain *d, dfn_t dfn, unsigned int page_count) · line 446
Quoted 9 lines
xen/drivers/passthrough/iommu.c +3
-1@@ -417,7 +440,9 @@ int iommu_iotlb_flush(struct domain *d, dfn_t dfn, unsigned int page_count)if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush )return 0 ; - rc = hd->platform_ops->iotlb_flush (d, dfn, page_count); +/* Assume a 'modified' flush is required */ + rc = hd->platform_ops->iotlb_flush (d, dfn, page_count, + IOMMU_FLUSH_modified);
As per above this would then become the OR of both flush modes.
xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn, · line 636
Quoted 12 lines
xen/drivers/passthrough/vtd/iommu.c +3
-3@@ -631,11 +631,14 @@ static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn,return rc; } -static int __must_check iommu_flush_iotlb_pages (struct domain *d, -dfn_t dfn, -unsigned int page_count) +static int __must_check iommu_flush_iotlb_pages ( +struct domain *d,dfn_t dfn,unsigned int page_count, +enum iommu_flush_type flush_type)
Is the re-flowing really needed?
xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn, · line 640
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +3
-1{ -return iommu_flush_iotlb (d, dfn,1 , page_count); +return (flush_type == IOMMU_FLUSH_none) ? +0 : + iommu_flush_iotlb(d, dfn, (flush_type == IOMMU_FLUSH_modified),
Unnecessary parentheses.
xen/drivers/passthrough/vtd/iommu.c static int __must_check dma_pte_clear_one(struct domain *domain, u64 addr) · line 678
Quoted 6 lines
xen/drivers/passthrough/vtd/iommu.c +0
-2@@ -674,9 +677,6 @@ static int __must_check dma_pte_clear_one(struct domain *domain, u64 addr)spin_unlock (&hd->arch.mapping_lock);iommu_flush_cache_entry (pte,sizeof (struct dma_pte )); -if ( !this_cpu (iommu_dont_flush_iotlb) ) - rc =iommu_flush_iotlb_pages (domain,daddr_to_dfn (addr),1 );
This code not getting replaced by another addition right in this source file, and this function's only caller being intel_iommu_unmap_page() makes me wonder why you don't have the unmap functions similarly hand back a flush indicator.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operations
Quoted 32 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: 03 December 2018 15:03
To: Paul Durrant <[email protected]>
Cc: Kevin Tian <[email protected]>; Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>; Julien Grall <[email protected]>; Suravee Suthikulpanit <[email protected]>; xen-devel <xen- [email protected]>; Brian Woods <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [Xen-devel] [PATCH 2/2] iommu: elide flushing for higher order map/unmap operationsQuoted 2 lines
Quoted 1 line
Quoted 1 line · On 30.11.18 at 11:45, <[email protected]> wrote:
This patch removes any implicit flushing that occurs in the
implementation
Quoted 4 lines
of map and unmap operations and, instead, adds explicit flushing at the end of the loops in the iommu_map/unmap() wrapper functions.
Because VT-d currently performs two different types of flush dependent
upon
Quoted 1 line
whether a PTE is being modified versus merely added (i.e. replacing a
non-
Quoted 1 line
present PTE) a '
iommu_flush_type' enumeration is defined by this patchand
Quoted 2 lines
the
iommu_opsmap method is modified to pass back the type of flush necessary for the PTE that has been populated. When a higher ordermapping
Quoted 1 line
operation is done, the wrapper code performs the 'highest' level of
flush
Quoted 1 line
required by the individual
iommu_opsmethod calls, where a 'modified
Quoted 8 lines
PTE'
Quoted 1 line
flush is deemed to be higher than a 'added PTE' flush.
I'm afraid such ordering properties may not generally exist. That is, what you pass the flush handlers needs to be an OR of "added new entries" and "modified existing entries". That's because at least in the abstract case it may be that distinct flushes need to be issued for both cases (i.e. potentially two of them).
Ok, I can set things up that way instead.
Quoted 19 lines
Quoted 2 lines
-static bool set_iommu_pte_present(unsigned long
pt_mfn, unsigned longdfn,
Quoted 1 line
- unsigned long
next_mfn, int
pde_level,Quoted 14 lines
xen/drivers/passthrough/amd/iommu_map.c +4
-2- bool iw, bool ir) +static enum iommu_flush_type set_iommu_pte_present ( +unsigned long pt_mfn,unsigned long dfn,unsigned long next_mfn, +int pde_level,bool iw,bool ir) {uint64_t *table;uint32_t *pde; -bool need_flush; +enum iommu_flush_type flush_type; table =map_domain_page (_mfn (pt_mfn)); pde = (uint32_t *)(table +pfn_to_pde_idx (dfn, pde_level));
Quoted 9 lines
xen/drivers/passthrough/amd/iommu_map.c static bool set_iommu_pde_present(uint32_t *pde, unsigned long next_mfn, · line 143
Quoted 6 lines
xen/drivers/passthrough/amd/iommu_map.c +2
-2- need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir); + flush_type =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);unmap_domain_page (table); -return need_flush; +return flush_type; }Please take the opportunity and add the missing blank line.
Ok.
Quoted 11 lines
Review int amd_iommu_unmap_page(struct domain *d, dfn_t
Quoted 1 line
(quoted diff) +0
-0@@ -629,8 +629,6 @@ int amd_iommu_unmap_page(struct domain *d, dfn_tdfn)
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_unmap_page(struct domain *d, dfn_t dfn) · line 633
Quoted 7 lines
xen/drivers/passthrough/amd/iommu_map.c +0
-2clear_iommu_pte_present (pt_mfn[1 ],dfn_x (dfn));spin_unlock (&hd->arch.mapping_lock); - -amd_iommu_flush_pages (d,dfn_x (dfn),0 );return 0 ; }Please retain the blank line.
Ok.
Quoted 25 lines
Review int amd_iommu_reserve_domain_unity_map(struct
Quoted 2 lines
(quoted diff) +0
-0@@ -700,12 +705,23 @@ int amd_iommu_reserve_domain_unity_map(structdomain *domain,
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_reserve_domain_unity_map(struct domain *domain,
Quoted 6 lines
xen/drivers/passthrough/amd/iommu_map.c +1
-1for ( i =0 ; i < npages; i++ ) {unsigned long frame = gfn + i; +enum iommu_flush_type this_flush_type; - rt = amd_iommu_map_page(domain, _dfn(frame), _mfn(frame),flags);
Review int amd_iommu_reserve_domain_unity_map(struct · line 710
Quoted 1 line
(quoted diff) +1
-0+ rt = amd_iommu_map_page(domain, _dfn(frame), _mfn(frame),flags,
Quoted 13 lines
xen/drivers/passthrough/amd/iommu_map.c +9
-2+ &this_flush_type);if ( rt !=0 ) -return rt; +break ; + + flush_type =MAX (flush_type, this_flush_type); } -return 0 ; + +/* +* The underlying implementation is void so the return value is +* meaningless and can hence be ignored. +*/
Quoted 9 lines
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_reserve_domain_unity_map(struct domain *domain, · line 723
Quoted 2 lines
xen/drivers/passthrough/amd/iommu_map.c +2
-0+ ignored =amd_iommu_flush_iotlb_pages (domain,_dfn (gfn), npages, + flush_type);I'm afraid such an assignment without subsequent use can be (legitimately) warned about by compilers. Hence the approach I had asked you to restore in one of your earlier patches. The exact same one won't fit here, but while ( ... ) break; should. Same then elsewhere.
Ok.
Quoted 13 lines
Review int iommu_map(struct domain *d, dfn_t dfn, mfn_t
Quoted 1 line
(quoted diff) +0
-0@@ -319,11 +324,18 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_tmfn,
Quoted 11 lines
xen/drivers/passthrough/iommu.c +5
-1for ( i =0 ; i < (1ul << page_order); i++ ) { +enum iommu_flush_type this_flush_type; +int ignore; + rc = hd->platform_ops->map_page (d,dfn_add (dfn, i), -mfn_add (mfn, i), flags); +mfn_add (mfn, i), flags, + &this_flush_type);
Quoted 8 lines
xen/drivers/passthrough/iommu.c int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn, · line 336
Quoted 3 lines
xen/drivers/passthrough/iommu.c +2
-0if (likely (!rc) ) + { + flush_type =MAX (flush_type, this_flush_type);With the comment above this is unlikely to stay anyway, but if it does please use
max()instead. At least I can't see why you couldn't use the typesafe variant here.
As you say, it will go away.
Quoted 11 lines
Review int iommu_map(struct domain *d, dfn_t dfn, mfn_t
Quoted 1 line
(quoted diff) +0
-0@@ -336,12 +348,19 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_tmfn,
Quoted 9 lines
xen/drivers/passthrough/iommu.c +3
-0if ( hd->platform_ops->unmap_page (d,dfn_add (dfn, i)) )continue ; +/* Something went wrong so attempt a full flush */ + ignore = hd->platform_ops->iotlb_flush_all (d); +if ( !is_hardware_domain (d) )domain_crash (d);
Quoted 9 lines
Review int iommu_map(struct domain *d, dfn_t dfn, mfn_t · line 360
Quoted 4 lines
(quoted diff) +1
-0break; } + if ( hd->platform_ops->iotlb_flush &&!this_cpu(iommu_dont_flush_iotlb) )
Review int iommu_map(struct domain *d, dfn_t dfn, mfn_t · line 361
Quoted 1 line
(quoted diff) +1
-0+ rc = hd->platform_ops->iotlb_flush(d, dfn, (1ul << page_order),1u only please, since the function parameter is unsigned int.
Ok.
Quoted 10 lines
Review int iommu_unmap(struct domain *d, dfn_t dfn,
Quoted 1 line
(quoted diff) +0
-0@@ -378,6 +397,10 @@ int iommu_unmap(struct domain *d, dfn_t dfn,unsigned int
page_order)xen/drivers/passthrough/iommu.c int iommu_unmap(struct domain *d, dfn_t dfn, unsigned int page_order) · line 401
Quoted 5 lines
xen/drivers/passthrough/iommu.c +2
-0} } +if ( hd->platform_ops->iotlb_flush ) + rc = hd->platform_ops->iotlb_flush(d, dfn, (1ul << page_order),Same here.
Ok.
Quoted 7 lines
Review int iommu_iotlb_flush(struct domain *d, dfn_t dfn,
Quoted 1 line
(quoted diff) +0
-0@@ -417,7 +440,9 @@ int iommu_iotlb_flush(struct domain *d, dfn_t dfn,unsigned int
page_count)Quoted 5 lines
(quoted diff) +0
-0if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops-
iotlb_flush
)return 0;
Quoted 6 lines
xen/drivers/passthrough/iommu.c int iommu_iotlb_flush(struct domain *d, dfn_t dfn, unsigned int page_count) · line 445
Quoted 4 lines
xen/drivers/passthrough/iommu.c +3
-1- rc = hd->platform_ops->iotlb_flush (d, dfn, page_count); +/* Assume a 'modified' flush is required */ + rc = hd->platform_ops->iotlb_flush (d, dfn, page_count, + IOMMU_FLUSH_modified);As per above this would then become the OR of both flush modes.
Yes.
Quoted 11 lines
xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct
Quoted 4 lines
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -631,11 +631,14 @@ static int __must_check iommu_flush_iotlb(structdomain *d,
dfn_tdfn,xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn,
Quoted 6 lines
xen/drivers/passthrough/vtd/iommu.c +0
-3return rc; } -static int __must_check iommu_flush_iotlb_pages (struct domain *d, -dfn_t dfn, - unsigned int
Quoted 7 lines
page_count)xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn, · line 636
Quoted 3 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+static int __must_check iommu_flush_iotlb_pages ( +struct domain *d,dfn_t dfn,unsigned int page_count, +enum iommu_flush_type flush_type)Is the re-flowing really needed?
Yes. The enum is long and won't fit within 80 chars otherwise.
Quoted 8 lines
xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn,
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +3
-1{ -return iommu_flush_iotlb (d, dfn,1 , page_count); +return (flush_type == IOMMU_FLUSH_none) ? +0 : + iommu_flush_iotlb(d, dfn, (flush_type ==
IOMMU_FLUSH_modified),Unnecessary parentheses.
Ok.
Quoted 6 lines
xen/drivers/passthrough/vtd/iommu.c static int __must_check dma_pte_clear_one(struct
Quoted 2 lines
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -674,9 +677,6 @@ static int __must_check dma_pte_clear_one(structdomain *domain, u64 addr)
Quoted 3 lines
xen/drivers/passthrough/vtd/iommu.c +0
-0spin_unlock (&hd->arch.mapping_lock);iommu_flush_cache_entry (pte,sizeof (struct dma_pte ));
Quoted 8 lines
xen/drivers/passthrough/vtd/iommu.c static int __must_check dma_pte_clear_one(struct domain *domain, u64 addr) · line 678
Quoted 2 lines
xen/drivers/passthrough/vtd/iommu.c +0
-2-if ( !this_cpu (iommu_dont_flush_iotlb) ) - rc =iommu_flush_iotlb_pages (domain,daddr_to_dfn (addr),1 );This code not getting replaced by another addition right in this source file, and this function's only caller being
intel_iommu_unmap_page()makes me wonder why you don't have the unmap functions similarly hand back a flush indicator.
Well, the assumption is that unmap is always modifying an existing entry. Is that assumption wrong?
Paul
Quoted 7 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operations
Quoted 17 lines
Quoted 17 lines
Quoted 1 line · On 03.12.18 at 16:18, <[email protected]> wrote:
From: Xen-devel [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: 03 December 2018 15:03xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 30.11.18 at 11:45, <[email protected]> wrote:
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -631,11 +631,14 @@ static int __must_check iommu_flush_iotlb(structdomain *d,
dfn_tdfn,xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn,
Quoted 6 lines
xen/drivers/passthrough/vtd/iommu.c +0
-3return rc; } -static int __must_check iommu_flush_iotlb_pages (struct domain *d, -dfn_t dfn, - unsigned int
page_count)
Quoted 8 lines
Quoted 6 lines
xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn, · line 636
Quoted 3 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+static int __must_check iommu_flush_iotlb_pages ( +struct domain *d,dfn_t dfn,unsigned int page_count, +enum iommu_flush_type flush_type)Is the re-flowing really needed?
Yes. The enum is long and won't fit within 80 chars otherwise.
How about calling the parameter by a shorter name, e.g. ft?
Quoted 8 lines
Quoted 8 lines
xen/drivers/passthrough/vtd/iommu.c static int __must_check dma_pte_clear_one(struct
Quoted 1 line
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -674,9 +677,6 @@ static int __must_check dma_pte_clear_one(structdomain *domain, u64 addr)
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +0
-2spin_unlock (&hd->arch.mapping_lock);iommu_flush_cache_entry (pte,sizeof (struct dma_pte )); -if ( !this_cpu (iommu_dont_flush_iotlb) ) - rc =iommu_flush_iotlb_pages (domain,daddr_to_dfn (addr),1 );
Quoted 7 lines
Quoted 4 lines
This code not getting replaced by another addition right in this source file, and this function's only caller being
intel_iommu_unmap_page()makes me wonder why you don't have the unmap functions similarly hand back a flush indicator.Well, the assumption is that unmap is always modifying an existing entry. Is that assumption wrong?
I could certainly see an unmap happening for an already unmapped area.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] iommu: elide flushing for higher order map/unmap operations
Quoted 36 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 03 December 2018 15:29
To: Paul Durrant <[email protected]>
Cc: Brian Woods <[email protected]>; Suravee Suthikulpanit <[email protected]>; Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: RE: [Xen-devel] [PATCH 2/2] iommu: elide flushing for higher order map/unmap operationsQuoted 2 lines
Quoted 2 lines
Quoted 1 line · On 03.12.18 at 16:18, <[email protected]> wrote:
From: Xen-devel [mailto:[email protected]] On
Behalf
Quoted 7 lines
Quoted 7 lines
Of Jan Beulich
Sent: 03 December 2018 15:03xen/drivers/passthrough/vtd/iommu.c static int __must_check
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 30.11.18 at 11:45, <[email protected]> wrote:
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -631,11 +631,14 @@ static int __must_checkiommu_flush_iotlb(struct
Quoted 12 lines
Quoted 12 lines
domain *d,
dfn_tdfn,xen/drivers/passthrough/vtd/iommu.c static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn,
Quoted 6 lines
xen/drivers/passthrough/vtd/iommu.c +0
-3return rc; } -static int __must_check iommu_flush_iotlb_pages (struct domain *d, -dfn_t dfn, - unsigned int
page_count)Quoted 3 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+static int __must_check iommu_flush_iotlb_pages ( +struct domain *d,dfn_t dfn,unsigned int page_count, +enum iommu_flush_type flush_type)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Is the re-flowing really needed?
Yes. The enum is long and won't fit within 80 chars otherwise.
How about calling the parameter by a shorter name, e.g. ft?
Well I'm going to passing flags around now, so I may as well use an unsigned int.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
xen/drivers/passthrough/vtd/iommu.c static int __must_check dma_pte_clear_one(struct
Quoted 1 line
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -674,9 +677,6 @@ static int __must_check dma_pte_clear_one(structdomain *domain, u64 addr)
xen/drivers/passthrough/vtd/iommu.c static int __must_check dma_pte_clear_one(struct domain *domain, u64 addr) · line 678
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +0
-2spin_unlock (&hd->arch.mapping_lock);iommu_flush_cache_entry (pte,sizeof (struct dma_pte )); -if ( !this_cpu (iommu_dont_flush_iotlb) ) - rc =iommu_flush_iotlb_pages (domain,daddr_to_dfn (addr),1 );This code not getting replaced by another addition right in this source file, and this function's only caller being
intel_iommu_unmap_page()makes me wonder why you don't have the unmap functions similarly hand back a flush indicator.
Quoted 6 lines
Quoted 1 line
Well, the assumption is that unmap is always modifying an existing
entry. Is
Quoted 1 line
that assumption wrong?
I could certainly see an unmap happening for an already unmapped area.
Ok, I'll generalise it then.
Paul
Quoted 3 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel