[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[XEN][PATCH v6 10/19] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
- Date: Tue, 2 May 2023 16:36:41 -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=45fuJEPfdOT3ElxOeWsri05r41QvJhpC/khBsBhOc+k=; b=ltr4GcawQtiBZOSzhjSlRlnkHepmTmdlewD6rX+IyOnI3Qa0LfkDFdAJL+YFn1zSkzgBVKIl0ZYra/377eGVtKJkDB/QS1G9Gx7cQ7W0OjEhLrtQVq05w0nrfPRtqcJKkocQAfU+tHtORxkrmo0ywS9hFQuhc05Ibiys4Kecv0D3QXRYBmMfDpNhqyZ1A+aNUwrMfA+hpyfeCtQpHSL0iqhcofaTixr4F5QliDttmXUExnqhYAnKj6S77jlubO6+MY3Tp00N1CFECr7kYBf3FrPJQVFXbMwR8saRecwD+Xe3vtR3s7sq4HF3eW9tfZdMPrwGcGMirvRqTe4uD/27SA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fVNgEAorIrinAzAbFAp1oO37hZXxBb7ekDWjwhWkcemEPGnxRKqcW+m3UToKpPlfVd5OCRi1xKCFrZ5/wejFBIqH3b1Sg/PB2Gch6emWZvgQ8egmSLDJ33AbTJIrCRcn6yeNRSi5YjHKGgW0RvmZYOfrcEVXpXtwKkSabinpq7IdVcbt2VjGlEWFGoNlfIPP7T1S6jkb8Vo0Mo9X6mkX+eE+gQA5ntIefbtpOGhR9OAYBiD/6w84OY6lZSXdK3bZ4TBHKtP4l3CasBIvAKuwRFk9xrXybm5I2RfUkP1tfYo2E051mpKe4JBWuDr6UIg6bxyNST9AcCBfRsgz3JlGXg==
- Cc: <sstabellini@xxxxxxxxxx>, <vikram.garhwal@xxxxxxx>, <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>
- Delivery-date: Tue, 02 May 2023 23:37:56 +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>
Reviewed-by: Michal Orzel <michal.orzel@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 c386fda3e4..f3867ef1a6 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
|