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

[XEN][PATCH v5 09/17] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Tue, 11 Apr 2023 12:16:28 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qd0QFdZvzHUGWrw0BfIrEu3cWkp8jWSV4vPT9FURuHE=; b=GVHkLjWTfBaR1e9+F+dbVMwK2uPs8b88ZM46uVIzIjudv3ZNg96WWLSa45UoP0/uNAJuubbd04wbbqWC6cwzCsQOBwsVxaMBD51h4I2wWjJAca+nC56si7I1vHpQCn2CLfRof8p9kzafAbAKIl2fh6trQu5fSolcjQmEgVIIVwVK8CfDMLkLaRDZE9ooGA/Nziwh5MSwBbJes2JFzfHHstxsIuTrLDLAh99xsCijJiRte6+1KsyBLwCx3tTzppZz7Ki7Q+PzcUF7dmzdCnBAWBXsO4FfKq+pdP2F2FoZh/KFFM7eemF3P6yTRltC+HwNwejPVGZSSpkdSRy0XDiYIQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F51bULKW9b+g2uxlrVXvYKaoRY/BibCkb2SPb5ObheoJoI53wTk2aDI9+YohJii69KmGma19PCO3tW4tMnTXwVRBluuokfqiZBvHbDix5pAxbJkCPdGIZks3izhxcCg/FRDhnDNJ3UXX/IOp/0QeQ3BXuKu/SZr5c/FTmVDulC6JFE3uw6eUf7SOgl7lQpI/HoxiwWGC6RHH2eBjYOLKf1bYGiBhb3Fh6EJvskGhjE56TCzyHpQFn6ti2rK4E/vW7JD/RPalmCsxNhe8kw6+k7G/itVKHq8vFCxCqUMXg8eOk7jPmHah208vRKPqp4AoWBNBSnT/oWo9SYFr8TIcJw==
  • Cc: <sstabellini@xxxxxxxxxx>, Vikram Garhwal <vikram.garhwal@xxxxxxx>, "Julien Grall" <julien@xxxxxxx>
  • Delivery-date: Tue, 11 Apr 2023 19:19:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Protect iommu_add_dt_device() with dtdevs_lock to prevent concurrent access add.

Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
 xen/drivers/passthrough/device_tree.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/device_tree.c 
b/xen/drivers/passthrough/device_tree.c
index bb4cf7784d..457df333a0 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -146,6 +146,8 @@ int iommu_add_dt_device(struct dt_device_node *np)
     if ( dev_iommu_fwspec_get(dev) )
         return 0;
 
+    spin_lock(&dtdevs_lock);
+
     /*
      * According to the Documentation/devicetree/bindings/iommu/iommu.txt
      * from Linux.
@@ -158,7 +160,10 @@ int iommu_add_dt_device(struct dt_device_node *np)
          * these callback implemented.
          */
         if ( !ops->add_device || !ops->dt_xlate )
-            return -EINVAL;
+        {
+            rc = -EINVAL;
+            goto fail;
+        }
 
         if ( !dt_device_is_available(iommu_spec.np) )
             break;
@@ -189,6 +194,8 @@ int iommu_add_dt_device(struct dt_device_node *np)
     if ( rc < 0 )
         iommu_fwspec_free(dev);
 
+fail:
+    spin_unlock(&dtdevs_lock);
     return rc;
 }
 
-- 
2.17.1




 


Rackspace

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