From: Zhenzhong Duan <zhenzhong.duan@intel.com>
To: linux-kernel@vger.kernel.org, iommu@lists.linux.dev
Cc: dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org,
will@kernel.org, robin.murphy@arm.com, jgg@ziepe.ca,
kevin.tian@intel.com, Zhenzhong Duan <zhenzhong.duan@intel.com>
Subject: [PATCH 2/3] iommupt/vtd: Support dirty tracking on PASID
Date: Wed, 4 Feb 2026 21:34:03 -0500 [thread overview]
Message-ID: <20260205023405.41583-3-zhenzhong.duan@intel.com> (raw)
In-Reply-To: <20260205023405.41583-1-zhenzhong.duan@intel.com>
In order to support passthrough device with PASID capability in QEMU,
e.g., DSA device, kernel needs to support attaching PASID to a domain.
But attaching is not allowed if the domain is a second stage domain with
dirty tracking, this is the use case when guest configures 'iommu=pt'.
The reason is kernel lacking support for dirty tracking on such domain
attached to PASID. Same for nested domain even though there is no such
checking.
By adding dirty tracking on PASID, the check can be removed.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
drivers/iommu/intel/iommu.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index acaa6eaf7e2f..5a9ed91109a2 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -3621,9 +3621,6 @@ static int intel_iommu_set_dev_pasid(struct iommu_domain *domain,
if (!pasid_supported(iommu) || dev_is_real_dma_subdevice(dev))
return -EOPNOTSUPP;
- if (domain->dirty_ops)
- return -EINVAL;
-
if (context_copied(iommu, info->bus, info->devfn))
return -EBUSY;
@@ -3691,6 +3688,7 @@ static void *intel_iommu_hw_info(struct device *dev, u32 *length,
static int device_set_dirty_tracking(struct dmar_domain *domain, bool enable)
{
struct device_domain_info *info;
+ struct dev_pasid_info *dev_pasid;
int ret = 0;
lockdep_assert_held(&domain->lock);
@@ -3698,6 +3696,14 @@ static int device_set_dirty_tracking(struct dmar_domain *domain, bool enable)
list_for_each_entry(info, &domain->devices, link) {
ret = intel_pasid_setup_dirty_tracking(info->iommu, info->dev,
IOMMU_NO_PASID, enable);
+ if (ret)
+ return ret;
+ }
+
+ list_for_each_entry(dev_pasid, &domain->dev_pasids, link_domain) {
+ info = dev_iommu_priv_get(dev_pasid->dev);
+ ret = intel_pasid_setup_dirty_tracking(info->iommu, info->dev,
+ dev_pasid->pasid, enable);
if (ret)
break;
}
--
2.47.3
next prev parent reply other threads:[~2026-02-05 2:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 2:34 [PATCH 0/3] " Zhenzhong Duan
2026-02-05 2:34 ` [PATCH 1/3] iommupt/vtd: Pass dmar_domain pointer to device_set_dirty_tracking() Zhenzhong Duan
2026-02-05 2:34 ` Zhenzhong Duan [this message]
2026-03-27 7:51 ` [PATCH 2/3] iommupt/vtd: Support dirty tracking on PASID Tian, Kevin
2026-03-27 9:12 ` Duan, Zhenzhong
2026-02-05 2:34 ` [PATCH 3/3] iommufd/selftest: Test " Zhenzhong Duan
2026-02-06 0:43 ` [PATCH 0/3] iommupt/vtd: Support " Jason Gunthorpe
2026-02-06 3:44 ` Duan, Zhenzhong
2026-03-23 1:51 ` Duan, Zhenzhong
2026-03-23 2:54 ` Baolu Lu
2026-03-26 10:54 ` Yi Liu
2026-03-30 2:04 ` Duan, Zhenzhong
2026-03-30 7:57 ` Baolu Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260205023405.41583-3-zhenzhong.duan@intel.com \
--to=zhenzhong.duan@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®