Skip to content

Commit 289b3b0

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Preset A/D bits for user space DMA usage
We preset the access and dirty bits for IOVA over first level usage only for the kernel DMA (i.e., when domain type is IOMMU_DOMAIN_DMA). We should also preset the FL A/D for user space DMA usage. The idea is that even the user space A/D bit memory write is unnecessary. We should avoid it to minimize the overhead. Suggested-by: Sanjay Kumar <[email protected]> Signed-off-by: Lu Baolu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 792fb43 commit 289b3b0

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,13 +2334,9 @@ __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
23342334
attr = prot & (DMA_PTE_READ | DMA_PTE_WRITE | DMA_PTE_SNP);
23352335
attr |= DMA_FL_PTE_PRESENT;
23362336
if (domain_use_first_level(domain)) {
2337-
attr |= DMA_FL_PTE_XD | DMA_FL_PTE_US;
2338-
2339-
if (iommu_is_dma_domain(&domain->domain)) {
2340-
attr |= DMA_FL_PTE_ACCESS;
2341-
if (prot & DMA_PTE_WRITE)
2342-
attr |= DMA_FL_PTE_DIRTY;
2343-
}
2337+
attr |= DMA_FL_PTE_XD | DMA_FL_PTE_US | DMA_FL_PTE_ACCESS;
2338+
if (prot & DMA_PTE_WRITE)
2339+
attr |= DMA_FL_PTE_DIRTY;
23442340
}
23452341

23462342
pteval = ((phys_addr_t)phys_pfn << VTD_PAGE_SHIFT) | attr;

0 commit comments

Comments
 (0)