From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: Lu Baolu <baolu.lu@linux.intel.com>,
David Woodhouse <dwmw2@infradead.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
Joerg Roedel <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>,
Will Deacon <will@kernel.org>,
"patches@lists.linux.dev" <patches@lists.linux.dev>,
Tina Zhang <tina.zhang@intel.com>,
"Wang, Wei W" <wei.w.wang@intel.com>
Subject: Re: [PATCH 8/9] iommu/vt-d: Use the generic iommu page table
Date: Fri, 22 Aug 2025 17:43:06 -0300 [thread overview]
Message-ID: <20250822204306.GC1405994@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB527649224AE0E30ECD18DF318C3DA@BN9PR11MB5276.namprd11.prod.outlook.com>
On Fri, Aug 22, 2025 at 09:35:27AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > Sent: Thursday, July 17, 2025 3:58 AM
> >
> > Replace the VT-D iommu_domain implementation of the VTD second stage
> > and
> > first stage page tables with the iommupt VTDSS and x86_64
> > pagetables. x86_64 is shared with the AMD driver.
> >
> > There are a couple notable things in VT-D:
> > - Like AMD the second stage format is not sign extended, unlike AMD it
> > cannot decode a full 64 bits. The first stage format is a normal sign
> > extended x86 page table
> > - The HW caps can indicate how many levels, how many address bits and
> > what
> > leaf page sizes are supported in HW. As before the highest number of
> > levels that can translate the entire supported address width is used.
> > The supported page sizes are adjusted directly from the dedicated
> > first/second stage cap bits.
> > - VTD requires flushing 'write buffers'. This logic is left unchanged,
> > the write buffer flushes on any gather flush or through iotlb_sync_map.
> > - Like ARM, VTD has an optional non-coherent page table walker that
>
> 'optional' sounds like a software choice. but here is actually a hardware
> limitation on certain platforms.
I wrote it like this because from a spec perspective there is a PWSNP
field in the PASID table entry that SW can choose to use.
Yes, some HW requires it to be set to 0..
> > requires cache flushing. This is supported through
> > PT_FEAT_DMA_INCOHERENT
> > the same as ARM, however x86 can't use the DMA API for flush, it must
> > call the arch function clflush_cache_range()
> > - The PT_FEAT_DYNAMIC_TOP can probably be supported on VTD someday
> > for the
> > second stage when it uses 128 bit atomic stores for the HW context
> > structures.
> > - PT_FEAT_VTDSS_FORCE_WRITEABLE is used to work around
> > ERRATA_772415_SPR17
> > - A kernel command line parameter "sp_off" disables all page sizes except 4k
>
> No related code in this patch. Is it from the common logic in the AMD
> series?
It is this:
static struct iommu_domain *
intel_iommu_domain_alloc_first_stage(struct device *dev,
struct intel_iommu *iommu, u32 flags)
{
if (!intel_iommu_superpage)
dmar_domain->domain.pgsize_bitmap = SZ_4K;
intel_iommu_superpage is driven by sp_off:
} else if (!strncmp(str, "sp_off", 6)) {
pr_info("Disable supported super page\n");
intel_iommu_superpage = 0;
> > @@ -3442,6 +2990,16 @@ static int
> > paging_domain_compatible_first_stage(struct dmar_domain *dmar_domain,
> > if (!sm_supported(iommu) || !ecap_flts(iommu->ecap))
> > return -EINVAL;
> >
> > + if (!ecap_smpwc(iommu->ecap) &&
> > + !(dmar_domain->fspt.x86_64_pt.common.features &
> > + BIT(PT_FEAT_DMA_INCOHERENT)))
> > + return -EINVAL;
>
> this change leads to a slightly different behavior from the old one.
>
> the old logic is that iommu/domain must have the same attribute:
>
> - if (dmar_domain->iommu_coherency !=
> - iommu_paging_structure_coherency(iommu))
> - return -EINVAL;
>
> but with this change a coherent walker can be attached to a
> incoherent domain.
Yes, and it should set PWSNP in the PASID entry too, not wire it like
this:
pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap));
So like:
pasid_set_page_snoop(pte, !(s2_domain->sspt.vtdss_pt.common.features &
BIT(PT_FEAT_DMA_INCOHERENT)));
And so on..
> Conceptually it's correct, as the only side effect
> is unnecessary cost of cache flush. But it does lead to user-visible
> impact i.e. a previously failed attach may succeed now.
Yes and yes
> In reality it might be fine as I'm not aware of a platform with IOMMUs
> having mixed coherent/incoherent walkers. But since this series is
> more for refactoring, better leave the uAPI semantics change to future.
But sure it can be split..
So like this:
if (!!ecap_smpwc(iommu->ecap) !=
!(dmar_domain->fspt.x86_64_pt.common.features &
BIT(PT_FEAT_DMA_INCOHERENT)))
return -EINVAL;
if (iommu_paging_structure_coherency(iommu) !=
!(dmar_domain->sspt.vtdss_pt.common.features &
BIT(PT_FEAT_DMA_INCOHERENT)))
return -EINVAL;
And I added a patch to put it back with the above set_page_snoop
related changes.
Thanks,
Jason
next prev parent reply other threads:[~2025-08-22 20:43 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 19:57 [PATCH 0/9] Convert Intel VT-D to use the generic iommu page table Jason Gunthorpe
2025-07-16 19:57 ` [PATCH 1/9] iommu/pages: Add support for a incoherent IOMMU page walker Jason Gunthorpe
2025-07-21 8:41 ` Baolu Lu
2025-07-29 22:32 ` Jason Gunthorpe
2025-07-30 1:49 ` Baolu Lu
2025-08-11 21:21 ` Jason Gunthorpe
2025-08-15 11:28 ` Tian, Kevin
2025-08-22 21:13 ` Jason Gunthorpe
2025-07-16 19:57 ` [PATCH 2/9] iommupt: Add basic support for SW bits in the page table Jason Gunthorpe
2025-08-15 11:29 ` Tian, Kevin
2025-08-18 23:35 ` Jason Gunthorpe
2025-07-16 19:57 ` [PATCH 3/9] iommupt: Use the incoherent start/stop functions for PT_FEAT_DMA_INCOHERENT Jason Gunthorpe
2025-08-15 11:35 ` Tian, Kevin
2025-08-22 20:45 ` Jason Gunthorpe
2025-07-16 19:57 ` [PATCH 4/9] iommupt: Flush the CPU cache after any writes to the page table Jason Gunthorpe
2025-07-16 19:57 ` [PATCH 5/9] iommupt: Add the Intel VT-D second stage page table format Jason Gunthorpe
2025-07-22 3:11 ` Baolu Lu
2025-07-29 23:05 ` Jason Gunthorpe
2025-07-30 2:00 ` Baolu Lu
2025-08-22 9:14 ` Tian, Kevin
2025-08-22 14:53 ` Jason Gunthorpe
2025-07-16 19:57 ` [PATCH 6/9] iommupt/x86: Set the dirty bit only for writable PTEs Jason Gunthorpe
2025-07-21 10:02 ` Baolu Lu
2025-07-16 19:57 ` [PATCH 7/9] iommupt/x86: Support SW bits and permit PT_FEAT_DMA_INCOHERENT Jason Gunthorpe
2025-07-22 5:17 ` Baolu Lu
2025-07-29 23:13 ` Jason Gunthorpe
2025-07-30 2:35 ` Baolu Lu
2025-08-22 9:17 ` Tian, Kevin
2025-08-22 14:55 ` Jason Gunthorpe
2025-07-16 19:57 ` [PATCH 8/9] iommu/vt-d: Use the generic iommu page table Jason Gunthorpe
2025-07-22 6:44 ` Baolu Lu
2025-07-29 23:39 ` Jason Gunthorpe
2025-08-22 9:35 ` Tian, Kevin
2025-08-22 20:43 ` Jason Gunthorpe [this message]
2025-07-16 19:57 ` [PATCH 9/9] iommupt: Add a kunit test for the SW bits Jason Gunthorpe
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=20250822204306.GC1405994@nvidia.com \
--to=jgg@nvidia.com \
--cc=baolu.lu@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=patches@lists.linux.dev \
--cc=robin.murphy@arm.com \
--cc=tina.zhang@intel.com \
--cc=wei.w.wang@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.