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

[PATCH 1/4] VT-d: defer "no DRHD" check when (un)mapping devices


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 15 Sep 2021 11:12:14 +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=V/tbiUwwg7Omg2atvKwkwb61QSkxuOMN4oMJkXQ5UrY=; b=J2mI4pjQqc7dMjKuSy1Zx4GijafkfEK4O5znFMStR3qZPS8KZQJK4TzTfbKPn062R9phTgSarJngcD5YULpa9KDeGvAFmLSmgwgC9qVwJvoxgPx+0eeXm/aS87HZc6HUpeKy2i9FTizKHaww0gXcDqArdwR2xl8NQopBCyPPVr71XnPptjlZkfmOfi/sDEaFMPe+Ph3kRyEvLHNnVZ5CdE8rAiZ6MBWtUe5WqykLoS0wc8fNtBMYAzKpia3+pfj1OlNWWXrP0h/ZLIS+7ulXsBIkIrqA0kTcyz6w5JFKzqT5kath97El/O8rgFCvMLufXvviVItD7Bu4pELZ5NLG4A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DoxJu4O3kBhUwA1+Al1FtezdmH+x/dkBK+PxRhrJbBcEite+YB5phhidKBdz+bfTtApAZnjMnIZMuFOVuKbKXr0b18Aa/DH5sNVzvIkRm7W2njqs77OobJeGnXi3756dsrIdbdObbEjWoMxLEdn8ypSEl0KKmJfz2uPSo/aNFvMyLN2cRUB9XPFI6rcxfNKktQUVTDnscqFneO8/6XhPOtXpq7IflxYFFIXPpTEA1+InsaCbXr1WCVYZnM7L1qFarVWvEJEX60FbZ+6Xdt7h2VRN0ulcicOxAiq3rm2vmUdKvGKX/b6LhbHr/2xXFGsXEitpUFsgBRE+OeSizLVTpg==
  • 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:12:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

If devices are to be skipped anyway (which is the case in particular for
host bridges), there's no point complaining about a missing DRHD (and
hence a missing association with an IOMMU).

While there convert assignments to initializers and constify "drhd"
local variables.

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

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1460,14 +1460,10 @@ static int domain_context_unmap(struct d
 static int domain_context_mapping(struct domain *domain, u8 devfn,
                                   struct pci_dev *pdev)
 {
-    struct acpi_drhd_unit *drhd;
+    const struct acpi_drhd_unit *drhd = acpi_find_matched_drhd_unit(pdev);
     int ret = 0;
     u8 seg = pdev->seg, bus = pdev->bus, secbus;
 
-    drhd = acpi_find_matched_drhd_unit(pdev);
-    if ( !drhd )
-        return -ENODEV;
-
     /*
      * Generally we assume only devices from one node to get assigned to a
      * given guest.  But even if not, by replacing the prior value here we
@@ -1476,7 +1472,7 @@ static int domain_context_mapping(struct
      * this or other devices may be penalized then, but some would also be
      * if we left other than NUMA_NO_NODE untouched here.
      */
-    if ( drhd->iommu->node != NUMA_NO_NODE )
+    if ( drhd && drhd->iommu->node != NUMA_NO_NODE )
         dom_iommu(domain)->node = drhd->iommu->node;
 
     ASSERT(pcidevs_locked());
@@ -1497,6 +1493,9 @@ static int domain_context_mapping(struct
         break;
 
     case DEV_TYPE_PCIe_ENDPOINT:
+        if ( !drhd )
+            return -ENODEV;
+
         if ( iommu_debug )
             printk(VTDPREFIX "%pd:PCIe: map %pp\n",
                    domain, &PCI_SBDF3(seg, bus, devfn));
@@ -1508,6 +1507,9 @@ static int domain_context_mapping(struct
         break;
 
     case DEV_TYPE_PCI:
+        if ( !drhd )
+            return -ENODEV;
+
         if ( iommu_debug )
             printk(VTDPREFIX "%pd:PCI: map %pp\n",
                    domain, &PCI_SBDF3(seg, bus, devfn));
@@ -1651,17 +1653,12 @@ int domain_context_unmap_one(
 static int domain_context_unmap(struct domain *domain, u8 devfn,
                                 struct pci_dev *pdev)
 {
-    struct acpi_drhd_unit *drhd;
-    struct vtd_iommu *iommu;
+    const struct acpi_drhd_unit *drhd = acpi_find_matched_drhd_unit(pdev);
+    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;
 
-    drhd = acpi_find_matched_drhd_unit(pdev);
-    if ( !drhd )
-        return -ENODEV;
-    iommu = drhd->iommu;
-
     switch ( pdev->type )
     {
     case DEV_TYPE_PCI_HOST_BRIDGE:
@@ -1676,6 +1673,9 @@ static int domain_context_unmap(struct d
         return 0;
 
     case DEV_TYPE_PCIe_ENDPOINT:
+        if ( !iommu )
+            return -ENODEV;
+
         if ( iommu_debug )
             printk(VTDPREFIX "%pd:PCIe: unmap %pp\n",
                    domain, &PCI_SBDF3(seg, bus, devfn));
@@ -1686,6 +1686,9 @@ static int domain_context_unmap(struct d
         break;
 
     case DEV_TYPE_PCI:
+        if ( !iommu )
+            return -ENODEV;
+
         if ( iommu_debug )
             printk(VTDPREFIX "%pd:PCI: unmap %pp\n",
                    domain, &PCI_SBDF3(seg, bus, devfn));




 


Rackspace

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