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

[PATCH 2/4] VT-d: consider hidden devices when unmapping


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 15 Sep 2021 11:12:54 +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; bh=/83ivPXoMWZK0DfJ0iAElyITmi87CEwTYL/CkVUUj8s=; b=BcSHQKEWuqj/X9b6xvanuDEmFQkUsmYBodHk4Hh8yr3AFlFD13Cg71CGZetPVibgIPtRXCGiROsa8m7TAVG2unwu+18c/NFEc2rm3BeDwxAjMWALtfnNfyTjNKstHk/ko9kwaVLCSycyPQGGbxtR9lCNYZs+sH1r/Uo26wvgh4wsGAEinfZcrJQoKa9uBxP+GLN3gYCi1xzxDFdcE51G3JQjXwb/lhEr/UjGKu8WERPI82EFz0p4KzDdTrSiHtREZa5Da7KgrK4r7BfzzohZFGWJA7HvDHFQUVE9GO9BRWwEX3hg8sjObs4c+yV6dZyVA0xrbQ4Os9/Lzr6imWu1Vw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fmo4aJFhHb5z7pPEqc2GAtj+S1xtd9BW2LEyOEttEoofkxpSIIKuXUmDTYdjKM6DlCt+ewJjitwqyxIBX0AZQ+kaQHWXPA3Y+bsQzg4Rk5sFfUrIESGwG8pWM1ZLgGSJy8jgsr9ho00oaApM49u1YVHVCGNMc1X8jvZPBjT0KMnUwdiU5jO60nkM/wTBqyBFGlrrvlLje4m2N5h/jUxhOYOiJ+GF54jqY9bdzn5+4uXkFVOI292bFvXazUnBGQlm6VOHkYOLzi6cBLee/Yxs9GKXIV4pa1ulVQH+HFzkE3L7pj8noWUQX6pk8GgsbxHCTfEOFISA0W6CLXxqhuyc3g==
  • Authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=suse.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Wed, 15 Sep 2021 09:13:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Whether to clear an IOMMU's bit in the domain's bitmap should depend on
all devices the domain can control. For the hardware domain this
includes hidden devices, which are associated with DomXEN.

While touching related logic, convert "found" to "bool".

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1657,7 +1657,7 @@ static int domain_context_unmap(struct d
     struct vtd_iommu *iommu = drhd ? drhd->iommu : NULL;
     int ret;
     u8 seg = pdev->seg, bus = pdev->bus, tmp_bus, tmp_devfn, secbus;
-    int found = 0;
+    bool found;
 
     switch ( pdev->type )
     {
@@ -1737,23 +1737,33 @@ static int domain_context_unmap(struct d
         return ret;
 
     /*
-     * if no other devices under the same iommu owned by this domain,
-     * clear iommu in iommu_bitmap and clear domain_id in domid_bitmp
+     * If no other devices under the same iommu owned by this domain,
+     * clear iommu in iommu_bitmap and clear domain_id in domid_bitmap.
      */
-    for_each_pdev ( domain, pdev )
+    for ( found = false; ; domain = dom_xen )
     {
-        if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn )
-            continue;
-
-        drhd = acpi_find_matched_drhd_unit(pdev);
-        if ( drhd && drhd->iommu == iommu )
+        for_each_pdev ( domain, pdev )
         {
-            found = 1;
-            break;
+            if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn )
+                continue;
+
+            drhd = acpi_find_matched_drhd_unit(pdev);
+            if ( drhd && drhd->iommu == iommu )
+            {
+                found = true;
+                break;
+            }
         }
+
+        /*
+         * Hidden devices are associated with DomXEN but usable by the
+         * hardware domain. Hence they need considering here as well.
+         */
+        if ( found || !is_hardware_domain(domain) )
+            break;
     }
 
-    if ( found == 0 )
+    if ( !found )
     {
         clear_bit(iommu->index, &dom_iommu(domain)->arch.vtd.iommu_bitmap);
         cleanup_domid_map(domain, iommu);




 


Rackspace

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