From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
David Woodhouse <dwmw2@infradead.org>,
iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>,
Will Deacon <will@kernel.org>
Cc: baolu.lu@linux.intel.com, Kevin Tian <kevin.tian@intel.com>,
patches@lists.linux.dev, Tina Zhang <tina.zhang@intel.com>,
Wei Wang <wei.w.wang@intel.com>
Subject: Re: [PATCH v2 08/10] iommu/vt-d: Use the generic iommu page table
Date: Mon, 22 Sep 2025 19:17:02 +0800 [thread overview]
Message-ID: <6a42747d-1115-4667-bd01-78f6629332b3@linux.intel.com> (raw)
In-Reply-To: <8-v2-44d4d9e727e7+18ad8-iommu_pt_vtd_jgg@nvidia.com>
On 8/27/2025 1:26 AM, Jason Gunthorpe wrote:
> 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
> 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
>
> Remove all the unused iommu_domain page table code. The debugfs paths have
> their own independent page table walker that is left alone for now.
>
> This corrects a race with the non-coherent walker that the ARM
> implementations have fixed:
>
> CPU 0 CPU 1
> pfn_to_dma_pte() pfn_to_dma_pte()
> pte = &parent[offset];
> if (!dma_pte_present(pte)) {
> try_cmpxchg64(&pte->val)
> pte = &parent[offset];
> .. dma_pte_present(pte) ..
> [...]
> // iommu_map() completes
> // Device does DMA
> domain_flush_cache(pte)
>
> The CPU 1 mapping operation shares a page table level with the CPU 0
> mapping operation. CPU 0 installed a new page table level but has not
> flushed it yet. CPU1 returns from iommu_map() and the device does DMA. The
> non coherent walker fails to see the new table level installed by CPU 0
> and fails the DMA with non-present.
>
> The iommupt PT_FEAT_DMA_INCOHERENT implementation uses the ARM design of
> storing a flag when CPU 0 completes the flush. If the flag is not set CPU
> 1 will also flush to ensure the HW can fully walk to the PTE being
> installed.
>
> Cc: Tina Zhang<tina.zhang@intel.com>
> Signed-off-by: Jason Gunthorpe<jgg@nvidia.com>
> ---
> drivers/iommu/intel/Kconfig | 4 +
> drivers/iommu/intel/iommu.c | 896 ++++++-----------------------------
> drivers/iommu/intel/iommu.h | 99 +---
> drivers/iommu/intel/nested.c | 5 -
> drivers/iommu/intel/pasid.c | 29 +-
> 5 files changed, 175 insertions(+), 858 deletions(-)
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
next prev parent reply other threads:[~2025-09-22 11:17 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 17:26 [PATCH v2 00/10] Convert Intel VT-D to use the generic iommu page table Jason Gunthorpe
2025-08-26 17:26 ` [PATCH v2 01/10] iommu/pages: Add support for a incoherent IOMMU page walker Jason Gunthorpe
2025-09-21 9:54 ` Baolu Lu
2025-09-22 16:32 ` Jason Gunthorpe
2025-10-14 7:41 ` Tian, Kevin
2025-08-26 17:26 ` [PATCH v2 02/10] iommupt: Add basic support for SW bits in the page table Jason Gunthorpe
2025-09-21 10:21 ` Baolu Lu
2025-10-14 7:45 ` Tian, Kevin
2025-10-21 13:18 ` Jason Gunthorpe
2025-08-26 17:26 ` [PATCH v2 03/10] iommupt: Use the incoherent start/stop functions for PT_FEAT_DMA_INCOHERENT Jason Gunthorpe
2025-09-21 13:29 ` Baolu Lu
2025-10-14 7:51 ` Tian, Kevin
2025-10-21 13:20 ` Jason Gunthorpe
2025-08-26 17:26 ` [PATCH v2 04/10] iommupt: Flush the CPU cache after any writes to the page table Jason Gunthorpe
2025-09-22 2:12 ` Baolu Lu
2025-09-22 14:42 ` Jason Gunthorpe
2025-09-23 2:17 ` Baolu Lu
2025-09-23 14:10 ` Jason Gunthorpe
2025-09-24 2:30 ` Baolu Lu
2025-09-22 2:31 ` Baolu Lu
2025-09-22 14:44 ` Jason Gunthorpe
2025-09-23 2:29 ` Baolu Lu
2025-09-23 14:13 ` Jason Gunthorpe
2025-09-24 3:05 ` Baolu Lu
2025-10-14 7:53 ` Tian, Kevin
2025-10-21 13:50 ` Jason Gunthorpe
2025-08-26 17:26 ` [PATCH v2 05/10] iommupt: Add the Intel VT-D second stage page table format Jason Gunthorpe
2025-09-22 3:06 ` Baolu Lu
2025-10-14 7:54 ` Tian, Kevin
2025-10-21 13:58 ` Jason Gunthorpe
2025-08-26 17:26 ` [PATCH v2 06/10] iommupt/x86: Set the dirty bit only for writable PTEs Jason Gunthorpe
2025-10-14 7:55 ` Tian, Kevin
2025-08-26 17:26 ` [PATCH v2 07/10] iommupt/x86: Support SW bits and permit PT_FEAT_DMA_INCOHERENT Jason Gunthorpe
2025-10-14 7:55 ` Tian, Kevin
2025-08-26 17:26 ` [PATCH v2 08/10] iommu/vt-d: Use the generic iommu page table Jason Gunthorpe
2025-09-22 11:17 ` Baolu Lu [this message]
2025-10-14 7:55 ` Tian, Kevin
2025-08-26 17:26 ` [PATCH v2 09/10] iommu/vt-d: Follow PT_FEAT_DMA_INCOHERENT into the PASID entry Jason Gunthorpe
2025-09-22 13:00 ` Baolu Lu
2025-10-14 7:58 ` Tian, Kevin
2025-08-26 17:26 ` [PATCH v2 10/10] iommupt: Add a kunit test for the SW bits Jason Gunthorpe
2025-10-14 7:58 ` Tian, Kevin
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=6a42747d-1115-4667-bd01-78f6629332b3@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).