Skip to content

Commit ae2fafc

Browse files
duanzhenzhongjoergroedel
authored andcommitted
iommu/vt-d: Support dirty tracking on PASID
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 or nested domain with dirty tracking. The reason is kernel lacking support for dirty tracking on such domain attached to PASID. By adding dirty tracking on PASID, the check can be removed. Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Yi Liu <yi.l.liu@intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Link: https://lore.kernel.org/r/20260330101108.12594-4-zhenzhong.duan@intel.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent 922e259 commit ae2fafc

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

drivers/iommu/intel/iommu.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3618,9 +3618,6 @@ static int intel_iommu_set_dev_pasid(struct iommu_domain *domain,
36183618
if (!pasid_supported(iommu) || dev_is_real_dma_subdevice(dev))
36193619
return -EOPNOTSUPP;
36203620

3621-
if (domain->dirty_ops)
3622-
return -EINVAL;
3623-
36243621
if (context_copied(iommu, info->bus, info->devfn))
36253622
return -EBUSY;
36263623

@@ -3688,13 +3685,22 @@ static void *intel_iommu_hw_info(struct device *dev, u32 *length,
36883685
static int domain_set_dirty_tracking(struct dmar_domain *domain, bool enable)
36893686
{
36903687
struct device_domain_info *info;
3688+
struct dev_pasid_info *dev_pasid;
36913689
int ret = 0;
36923690

36933691
lockdep_assert_held(&domain->lock);
36943692

36953693
list_for_each_entry(info, &domain->devices, link) {
36963694
ret = intel_pasid_setup_dirty_tracking(info->iommu, info->dev,
36973695
IOMMU_NO_PASID, enable);
3696+
if (ret)
3697+
return ret;
3698+
}
3699+
3700+
list_for_each_entry(dev_pasid, &domain->dev_pasids, link_domain) {
3701+
info = dev_iommu_priv_get(dev_pasid->dev);
3702+
ret = intel_pasid_setup_dirty_tracking(info->iommu, info->dev,
3703+
dev_pasid->pasid, enable);
36983704
if (ret)
36993705
break;
37003706
}

drivers/iommu/intel/nested.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,17 @@ static int intel_nested_set_dev_pasid(struct iommu_domain *domain,
148148
{
149149
struct device_domain_info *info = dev_iommu_priv_get(dev);
150150
struct dmar_domain *dmar_domain = to_dmar_domain(domain);
151-
struct iommu_domain *s2_domain = &dmar_domain->s2_domain->domain;
152151
struct intel_iommu *iommu = info->iommu;
153152
struct dev_pasid_info *dev_pasid;
154153
int ret;
155154

156155
if (!pasid_supported(iommu) || dev_is_real_dma_subdevice(dev))
157156
return -EOPNOTSUPP;
158157

159-
if (s2_domain->dirty_ops)
160-
return -EINVAL;
161-
162158
if (context_copied(iommu, info->bus, info->devfn))
163159
return -EBUSY;
164160

165-
ret = paging_domain_compatible(s2_domain, dev);
161+
ret = paging_domain_compatible(&dmar_domain->s2_domain->domain, dev);
166162
if (ret)
167163
return ret;
168164

0 commit comments

Comments
 (0)