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

[PATCH] VT-d: fix caching mode IOTLB flushing


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 19 Aug 2021 10:05:47 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dMci15fYzxhTs5f2mFFQLa4HsjEbVuo0tly+3SL4b+g=; b=nZTrJjkgS5UdGyEYYj+Va4yUl360uuCAJ5CGgbYs28PA34RtRvFK/eCwDLTqZj6EyYxdSgufda7/gBgFdzyQGJFmiE6lqO0k0iuAhBi5R4in6/sORqDRy6eFSBpFTDNLxNMln09QZe4Ip12hjZpbKCF9nP2+LZwzQdlGr+m2m21UvExCViVzaDNAY4FF9Qs/qAYLwKq/ovw6GFmeblim0C9sLKVcR7rdGbG5jQYSYi6avwYAAwO4D9ieiLoRtpAs4aHbx79audG6BKaEOMpfkAg7XDShiiCFTyR+MB/1E5vM80UxMVZo1T8R5eflSMYA7tOEdXv3hvAmah/U+r0/Ug==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iZX/Qg0Qj1NIGB1jl7/rAGcUukMg9UVdyemyUrLSkIqEeCaGjx/2zezdKwrqfxeUV41OBfDed69PJxZSPuCxgbpXeB0IUtMuiKXN8Dkr8f+MQvIh3emK4I8wQ1zFsgpIE5RT+n5cOG+iib3710ZmSKi3RxoSwgQX7uDu3vBnuEre07l6Rgn/lNH7uCADUrozEZkZox+B7oCoT79KzfgCOMWi8ckV9PedCknPn1CyTC2O478VPIFBtT5e+JEwTNPEgyzqoUFJlu7A2DVrkN+1paYbzddSU9I5CN9kGeDtzBVBQAkZ2pbBxnqJKc8JyxYlNf/RSiyvS3G9ECQJ3ZdayA==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com;
  • Cc: Kevin Tian <kevin.tian@xxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Thu, 19 Aug 2021 08:05:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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>
---
Luckily this is supposed to be an issue only when running on emulated
IOMMUs; hardware implementations are expected to have CAP.CM=0.

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -474,17 +474,10 @@ int vtd_flush_iotlb_reg(struct vtd_iommu
 
     /*
      * 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 )
--- 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(s
 
     /*
      * 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))




 


Rackspace

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