[PATCH] iommu/vt-d: Fix misplaced domain_attached assignment

Ban ZuoXiang posted 1 patch 2 months, 2 weeks ago
drivers/iommu/intel/iommu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] iommu/vt-d: Fix misplaced domain_attached assignment
Posted by Ban ZuoXiang 2 months, 2 weeks ago
Commit fb5873b779dd ("iommu/vt-d: Restore context entry setup order
for aliased devices") was incorrectly backported: the domain_attached
assignment was mistakenly placed in device_set_dirty_tracking()
instead of original identity_domain_attach_dev().

Fix this by moving the assignment to the correct function as in the
original commit.

Fixes: fb5873b779dd ("iommu/vt-d: Restore context entry setup order for aliased devices")
Closes: https://lore.kernel.org/linux-iommu/721D44AF820A4FEB+722679cb-2226-4287-8835-9251ad69a1ac@bbaa.fun/
Cc: stable@vger.kernel.org
Reported-by: Ban ZuoXiang <bbaa@bbaa.fun>
Signed-off-by: Ban ZuoXiang <bbaa@bbaa.fun>
---
 drivers/iommu/intel/iommu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 56e9f125cda9..af4e6c1e55db 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4414,9 +4414,6 @@ static int device_set_dirty_tracking(struct list_head *devices, bool enable)
 			break;
 	}
 
-	if (!ret)
-		info->domain_attached = true;
-
 	return ret;
 }
 
@@ -4600,6 +4597,9 @@ static int identity_domain_attach_dev(struct iommu_domain *domain, struct device
 		ret = device_setup_pass_through(dev);
 	}
 
+	if (!ret)
+		info->domain_attached = true;
+
 	return ret;
 }
 
-- 
2.50.1
Re: [PATCH] iommu/vt-d: Fix misplaced domain_attached assignment
Posted by Greg KH 2 months, 2 weeks ago
On Wed, Jul 23, 2025 at 08:04:23PM +0800, Ban ZuoXiang wrote:
> Commit fb5873b779dd ("iommu/vt-d: Restore context entry setup order
> for aliased devices") was incorrectly backported: the domain_attached
> assignment was mistakenly placed in device_set_dirty_tracking()
> instead of original identity_domain_attach_dev().
> 
> Fix this by moving the assignment to the correct function as in the
> original commit.
> 
> Fixes: fb5873b779dd ("iommu/vt-d: Restore context entry setup order for aliased devices")
> Closes: https://lore.kernel.org/linux-iommu/721D44AF820A4FEB+722679cb-2226-4287-8835-9251ad69a1ac@bbaa.fun/
> Cc: stable@vger.kernel.org
> Reported-by: Ban ZuoXiang <bbaa@bbaa.fun>
> Signed-off-by: Ban ZuoXiang <bbaa@bbaa.fun>
> ---
>  drivers/iommu/intel/iommu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Now queued up, thanks!

greg k-h