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

[XEN][RFC PATCH v3 08/14] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <fnu.vikram@xxxxxxxxxx>
  • Date: Tue, 8 Mar 2022 11:46:58 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.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=3IWMUDk1B29LOn60YW7dkrnq4Tu3150fXZJyXETxs0g=; b=QET60cJxqjQyKmYqU66ZH7Tya0UYonhuDYyuvLRv4Krkuc2D7vqMcOBftloMXqbF1Baw4YD8sijq7ZOE8OeArC8HWeKifB5AM4/ACub/TeJkhrvw8uU9K0yhpzMbHhlflAWg1jY+GMvNjM70ClzsFCpeX2L07e85shu8pQ/5P+5j/420tskQBQ1L6jc3OnUMkyfKPZ/cOz+KenZwW5LD20yFtPSNKAhvtzvBVFnDUEIZJn+nbyVaRkx4vlW8EdUenpmCeq2X7kWZI3fZfpFZtbAsyac5PFfAHFeRh1Fsi9EYsjmDIzMYm369BbWS2FXTaC8+XnJyYwjncwluKPwQKg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ETL0EnEm8zZvceHCk9Sc4USiDH9/QC18lc6pSqjuz/35oSSQjpuMi533y+I/hXd8+9KituXkPncfRdmBUh02HNuOxP3DC0ClJnuCkjo1+rzOkI4QXsqYjGDpkydGeP26AQ2d7bwIHxHWBuuTxNbFWdBBM0LTyvfOL7tIKFnOCvk/ix6YZwARL9T+1q3hkIkSP48DNXtwzfjZYpgti8bOzntiU42RmC2C/ceBbPjY6PRnljA04Cqy/uznAgkD3izPri/9fSOh30L7g47EqrOFJEwkcIvMQYkERQlC0VRWHawqeaFwiDWvDrB5EhYaSHPf6XFDtLQ1nXAvYAr0oZt2eQ==
  • Cc: <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>, <bertrand.marquis@xxxxxxx>, <volodymyr_babchuk@xxxxxxxx>, Vikram Garhwal <fnu.vikram@xxxxxxxxxx>
  • Delivery-date: Tue, 08 Mar 2022 19:47:32 +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 <fnu.vikram@xxxxxxxxxx>
---
 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 b3b04f8e03..776809a8f2 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -145,6 +145,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.
@@ -157,7 +159,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;
@@ -188,6 +193,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®.