Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d: Present Access bit for IOVA in FL non-leaf paging entries
@ 2022-11-13  1:03 Tina Zhang
  2022-11-14  2:26 ` Baolu Lu
  2022-11-16  5:20 ` Baolu Lu
  0 siblings, 2 replies; 3+ messages in thread
From: Tina Zhang @ 2022-11-13  1:03 UTC (permalink / raw)
  To: iommu; +Cc: Lu Baolu, Tina Zhang

The A/D bits are presented for IOVA over first level(FL) usage for both
kernel DMA (i.e, domain typs is IOMMU_DOMAIN_DMA) and user space DMA
usage (i.e., domain type is IOMMU_DOMAIN_UNMANAGED).

Preseting A bit in FL requires to present the bit in very related paging
entries, including the non-leaf ones. Otherwise, DMA fault may come out.
For example, in a case of ECAP_REG.SMPWC==0, the DMA fault would be
"SM: A/D bit update needed in first-level entry when set up in no
snoop".

Signed-off-by: Tina Zhang <tina.zhang@intel.com>
---
 drivers/iommu/intel/iommu.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 48cdcd0a5cf3..996a8b5ee5ee 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -959,11 +959,9 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
 
 			domain_flush_cache(domain, tmp_page, VTD_PAGE_SIZE);
 			pteval = ((uint64_t)virt_to_dma_pfn(tmp_page) << VTD_PAGE_SHIFT) | DMA_PTE_READ | DMA_PTE_WRITE;
-			if (domain_use_first_level(domain)) {
-				pteval |= DMA_FL_PTE_XD | DMA_FL_PTE_US;
-				if (iommu_is_dma_domain(&domain->domain))
-					pteval |= DMA_FL_PTE_ACCESS;
-			}
+			if (domain_use_first_level(domain))
+				pteval |= DMA_FL_PTE_XD | DMA_FL_PTE_US | DMA_FL_PTE_ACCESS;
+
 			if (cmpxchg64(&pte->val, 0ULL, pteval))
 				/* Someone else set it while we were thinking; use theirs. */
 				free_pgtable_page(tmp_page);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-16  5:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-13  1:03 [PATCH] iommu/vt-d: Present Access bit for IOVA in FL non-leaf paging entries Tina Zhang
2022-11-14  2:26 ` Baolu Lu
2022-11-16  5:20 ` Baolu Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox