[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[XEN][PATCH v7 10/19] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
- Date: Thu, 1 Jun 2023 17:48:15 -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=BBHXZIlMJGJe8+ipovZgPxAdAwa+jzzdQSk6DYH6FhU=; b=GUO4jqSsFNN/hMrXISeoCBViXMnlvRDzIBg54qDYOJbbWGY6jPwZpXX+g2ZWCf9wGg4zfzLok8jsvQe9ownirPa7yUS9Z95GzupKXz21UvSXYxXQA6q7wN9R2fuUHCFdyNMqtGZeooZ+0Jtf4aghHTww1/EkbUA6U33t/zq0I4JIQ153s2G64PJgUTMAggCa21ptExsOj88kRzbYLeXTMedH6mgbj86Qs9xuGAIfSTiKazFBzztO1QOSjqv9xZmI0VVW5z4x2e/Qnde/8KRp3/16rJ1wU6MaCmZqdakMAIaTR5X/7LHYLKDZ3vjQMBLfDs+8C5LuAPWO6Wsl+Fo6yw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A4cBnT6q+KCIPafdlLM5CP4yDXsWNCLlnwOUHQi838ItqG4KKEXYEfgUwxiQOg4ncgn+82spxRpBw1a52c0+815CHq6MzPswm541Ue5BY+tBhuHQwte0o/xWeGleIBxx/AAjsO0fKkJxE2ekt5Xugst+uuymCivEbsLOWhxKeI05lPBiZmujsWUkmN2LEkgQ4vOmupnPh1VsycMA7QZzYk9bArRqodbWtKpuHoJIUQvq5+4ahRAtor/wcA5kutsiBnD7y+scQpn1xwORAC2qYkrIFaVscx3aP8DZmpzLVzZm0gq7CrVAqghdDCfc38bx8IQXSjirxYs1KyUU05IUUQ==
- Cc: <michal.orzel@xxxxxxx>, <sstabellini@xxxxxxxxxx>, <vikram.garhwal@xxxxxxx>, <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>
- Delivery-date: Fri, 02 Jun 2023 00:49:02 +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 52e370db01..8cc413f867 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
|