[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] VT-d: fix caching mode IOTLB flushing



commit c5c84e97669dd5c92b59b04b2ab4233605da09dd
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Aug 27 10:52:15 2021 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Aug 27 10:52:15 2021 +0200

    VT-d: fix caching mode IOTLB flushing
    
    While for context cache entry flushing use of did 0 is indeed correct
    (after all upon reading the context entry the IOMMU wouldn't know any
    domain ID if the entry is not present, and hence a surrogate one needs
    to be used), for IOTLB entries the normal domain ID (from the [present]
    context entry) gets used. See sub-section "IOTLB" of section "Address
    Translation Caches" in the VT-d spec.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Paul Durrant <paul@xxxxxxx>
    Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
---
 xen/drivers/passthrough/vtd/iommu.c  | 13 +++----------
 xen/drivers/passthrough/vtd/qinval.c | 13 +++----------
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c 
b/xen/drivers/passthrough/vtd/iommu.c
index 23921dfb7b..2034a95a87 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -468,17 +468,10 @@ int vtd_flush_iotlb_reg(struct vtd_iommu *iommu, uint16_t 
did, uint64_t addr,
 
     /*
      * In the non-present entry flush case, if hardware doesn't cache
-     * non-present entry we do nothing and if hardware cache non-present
-     * entry, we flush entries of domain 0 (the domain id is used to cache
-     * any non-present entries)
+     * non-present entries we do nothing.
      */
-    if ( flush_non_present_entry )
-    {
-        if ( !cap_caching_mode(iommu->cap) )
-            return 1;
-        else
-            did = 0;
-    }
+    if ( flush_non_present_entry && !cap_caching_mode(iommu->cap) )
+        return 1;
 
     /* use register invalidation */
     switch ( type )
diff --git a/xen/drivers/passthrough/vtd/qinval.c 
b/xen/drivers/passthrough/vtd/qinval.c
index b0e3672231..b16153e298 100644
--- a/xen/drivers/passthrough/vtd/qinval.c
+++ b/xen/drivers/passthrough/vtd/qinval.c
@@ -362,17 +362,10 @@ static int __must_check flush_iotlb_qi(struct vtd_iommu 
*iommu, u16 did,
 
     /*
      * In the non-present entry flush case, if hardware doesn't cache
-     * non-present entry we do nothing and if hardware cache non-present
-     * entry, we flush entries of domain 0 (the domain id is used to cache
-     * any non-present entries)
+     * non-present entries we do nothing.
      */
-    if ( flush_non_present_entry )
-    {
-        if ( !cap_caching_mode(iommu->cap) )
-            return 1;
-        else
-            did = 0;
-    }
+    if ( flush_non_present_entry && !cap_caching_mode(iommu->cap) )
+        return 1;
 
     /* use queued invalidation */
     if (cap_write_drain(iommu->cap))
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.