lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240628-jag-revisit_cache_tag_assign-v1-4-a0c19063c983@samsung.com>
Date: Fri, 28 Jun 2024 14:27:42 +0200
From: Joel Granados via B4 Relay <devnull+j.granados.samsung.com@...nel.org>
To: David Woodhouse <dwmw2@...radead.org>, 
 Lu Baolu <baolu.lu@...ux.intel.com>, Joerg Roedel <joro@...tes.org>, 
 Will Deacon <will@...nel.org>, Robin Murphy <robin.murphy@....com>
Cc: iommu@...ts.linux.dev, linux-kernel@...r.kernel.org, 
 Joel Granados <j.granados@...sung.com>
Subject: [PATCH RFC 4/5] iommu/vt-d: Use ats_enable as an argument

From: Joel Granados <j.granados@...sung.com>

Pass the ats_enabled flag as a function argument instead of calling
dev_iommu_priv_get.

Signed-off-by: Joel Granados <j.granados@...sung.com>
---
 drivers/iommu/intel/cache.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/iommu/intel/cache.c b/drivers/iommu/intel/cache.c
index eb409a296e43..c630f4485a06 100644
--- a/drivers/iommu/intel/cache.c
+++ b/drivers/iommu/intel/cache.c
@@ -96,13 +96,13 @@ static void cache_tag_unassign_type(struct dmar_domain *domain,
 }
 
 static int __cache_tag_assign_domain(struct dmar_domain *domain,
-				     struct cache_tag_id *new_tag_id)
+				     struct cache_tag_id *new_tag_id,
+				     const bool ats_enabled)
 {
-	struct device_domain_info *info = dev_iommu_priv_get(new_tag_id->dev);
 	int ret;
 
 	ret = cache_tag_assign_type(domain, new_tag_id, CACHE_TAG_IOTLB);
-	if (ret || !info->ats_enabled)
+	if (ret || !ats_enabled)
 		return ret;
 
 	ret = cache_tag_assign_type(domain, new_tag_id, CACHE_TAG_DEVTLB);
@@ -113,23 +113,22 @@ static int __cache_tag_assign_domain(struct dmar_domain *domain,
 }
 
 static void __cache_tag_unassign_domain(struct dmar_domain *domain,
-					struct cache_tag_id *tag_id)
+					struct cache_tag_id *tag_id,
+					const bool ats_enabled)
 {
-	struct device_domain_info *info = dev_iommu_priv_get(tag_id->dev);
-
 	cache_tag_unassign_type(domain, tag_id, CACHE_TAG_IOTLB);
-	if (info->ats_enabled)
+	if (ats_enabled)
 		cache_tag_unassign_type(domain, tag_id, CACHE_TAG_DEVTLB);
 }
 
 static int __cache_tag_assign_parent_domain(struct dmar_domain *domain,
-					    struct cache_tag_id *new_tag_id)
+					    struct cache_tag_id *new_tag_id,
+					    const bool ats_enabled)
 {
-	struct device_domain_info *info = dev_iommu_priv_get(new_tag_id->dev);
 	int ret;
 
 	ret = cache_tag_assign_type(domain, new_tag_id, CACHE_TAG_NESTING_IOTLB);
-	if (ret || !info->ats_enabled)
+	if (ret || !ats_enabled)
 		return ret;
 
 	ret = cache_tag_assign_type(domain, new_tag_id, CACHE_TAG_NESTING_DEVTLB);
@@ -140,12 +139,11 @@ static int __cache_tag_assign_parent_domain(struct dmar_domain *domain,
 }
 
 static void __cache_tag_unassign_parent_domain(struct dmar_domain *domain,
-					       struct cache_tag_id *tag_id)
+					       struct cache_tag_id *tag_id,
+					       const bool ats_enabled)
 {
-	struct device_domain_info *info = dev_iommu_priv_get(tag_id->dev);
-
 	cache_tag_unassign_type(domain, tag_id, CACHE_TAG_NESTING_IOTLB);
-	if (info->ats_enabled)
+	if (ats_enabled)
 		cache_tag_unassign_type(domain, tag_id, CACHE_TAG_NESTING_DEVTLB);
 }
 
@@ -184,13 +182,14 @@ int cache_tag_assign_domain(struct dmar_domain *domain,
 	};
 	int ret;
 
-	ret = __cache_tag_assign_domain(domain, &new_tag_id);
+	ret = __cache_tag_assign_domain(domain, &new_tag_id, info->ats_enabled);
 	if (ret || domain->domain.type != IOMMU_DOMAIN_NESTED)
 		return ret;
 
-	ret = __cache_tag_assign_parent_domain(domain->s2_domain, &new_tag_id);
+	ret = __cache_tag_assign_parent_domain(domain->s2_domain, &new_tag_id,
+					       info->ats_enabled);
 	if (ret)
-		__cache_tag_unassign_domain(domain, &new_tag_id);
+		__cache_tag_unassign_domain(domain, &new_tag_id, info->ats_enabled);
 
 	return ret;
 }
@@ -213,9 +212,10 @@ void cache_tag_unassign_domain(struct dmar_domain *domain,
 		.domain_id = domain_get_id_for_dev(domain, dev)
 	};
 
-	__cache_tag_unassign_domain(domain, &tag_id);
+	__cache_tag_unassign_domain(domain, &tag_id, info->ats_enabled);
 	if (domain->domain.type == IOMMU_DOMAIN_NESTED)
-		__cache_tag_unassign_parent_domain(domain->s2_domain, &tag_id);
+		__cache_tag_unassign_parent_domain(domain->s2_domain, &tag_id,
+						   info->ats_enabled);
 }
 
 static unsigned long calculate_psi_aligned_address(unsigned long start,

-- 
2.43.0



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ