[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:10 -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=BLJ69mgmDOC4R6oelAOdYmiz7bsaXr3tCsp/n9jVQSfNwQkvbwB8mNzPAXedghQGVKl73r9eHZiXnJDEgi6/5PIi785YsAGhLn/NjQVkncwcrUtvIO3Ub6EdFenIHqnvqeDVN+21UtIh+Agwu3sYvQtHLFYcsiEX8fDmQ8SxvaMsHl2nIL8WKgr0dF1fefO9Zd3hLLl1qRtq0ONlThpsSekvWPCjEdCdGe18ABWfwzYnKYzMpFoX/bFTV5a9F1lWAvL7nMGpRo/DHrjB9bZ+Wq0GxePVPj7o0sU+FM9Jnt0wqPJ5dJ0WJKD0FQVylkqF6rg4pG5aaacy8nY5HFtxPQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lDNOOUoUQrDMzJfKXlJfbBxfcLNE2ExFDTv865MP0/28SIEbvp9JnZjJDr5LiG2XgsPaddpgjmGypo4MdsgnlyvwAvcH5/tAVyON4tcV29yB5Ax5/rzMW6ngkXaB1UBKGYvq2j+aZVZmhrNwjVcuwB0KKYXqfz/ptE6F65s+mJEjq8G2VLHNZg4X4aI+pQhT+GVYB2esbpZP5Le+4vQaIRdvSESALv92/hOY2ohpeVzIb8GKRKbpFZlCAH/NKZEy8kHh6QD5+Iy7xS7PSL5SGScUzX7Q3pYlRuIDFqeQ8QY0Umpam1vCOps3ut4ieAid0xpteHShUAq767fEik0JzQ==
- Cc: <sstabellini@xxxxxxxxxx>, Vikram Garhwal <vikram.garhwal@xxxxxxx>, "Julien Grall" <julien@xxxxxxx>
- Delivery-date: Tue, 11 Apr 2023 19:17:12 +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
|