* [PATCH 0/2] iommu/vt-d: Two fixes for v5.8
@ 2020-06-01 0:42 Lu Baolu
2020-06-01 0:42 ` [PATCH 1/2] iommu/vt-d: Make Intel SVM code 64-bit only Lu Baolu
2020-06-01 0:42 ` [PATCH 2/2] iommu/vt-d: Set U/S bit in first level page table by default Lu Baolu
0 siblings, 2 replies; 3+ messages in thread
From: Lu Baolu @ 2020-06-01 0:42 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, Lu Baolu
Hi Joerg,
This encloses two fixes for v5.8.
- Make Intel SVM code 64-bit only
- Set U/S bit to make IOVA over first level compatible with 2nd level
translations.
Best regards,
baolu
Lu Baolu (2):
iommu/vt-d: Make Intel SVM code 64-bit only
iommu/vt-d: Set U/S bit in first level page table by default
drivers/iommu/Kconfig | 2 +-
drivers/iommu/intel-iommu.c | 5 ++---
include/linux/intel-iommu.h | 1 +
3 files changed, 4 insertions(+), 4 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] iommu/vt-d: Make Intel SVM code 64-bit only
2020-06-01 0:42 [PATCH 0/2] iommu/vt-d: Two fixes for v5.8 Lu Baolu
@ 2020-06-01 0:42 ` Lu Baolu
2020-06-01 0:42 ` [PATCH 2/2] iommu/vt-d: Set U/S bit in first level page table by default Lu Baolu
1 sibling, 0 replies; 3+ messages in thread
From: Lu Baolu @ 2020-06-01 0:42 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, Lu Baolu
Current Intel SVM is designed by setting the pgd_t of the processor page
table to FLPTR field of the PASID entry. The first level translation only
supports 4 and 5 level paging structures, hence it's infeasible for the
IOMMU to share a processor's page table when it's running in 32-bit mode.
Let's disable 32bit support for now and claim support only when all the
missing pieces are ready in the future.
Fixes: 1c4f88b7f1f92 ("iommu/vt-d: Shared virtual address in scalable mode")
Suggested-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/iommu/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index aca76383f201..e6e0259c0a1c 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -211,7 +211,7 @@ config INTEL_IOMMU_DEBUGFS
config INTEL_IOMMU_SVM
bool "Support for Shared Virtual Memory with Intel IOMMU"
- depends on INTEL_IOMMU && X86
+ depends on INTEL_IOMMU && X86_64
select PCI_PASID
select PCI_PRI
select MMU_NOTIFIER
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] iommu/vt-d: Set U/S bit in first level page table by default
2020-06-01 0:42 [PATCH 0/2] iommu/vt-d: Two fixes for v5.8 Lu Baolu
2020-06-01 0:42 ` [PATCH 1/2] iommu/vt-d: Make Intel SVM code 64-bit only Lu Baolu
@ 2020-06-01 0:42 ` Lu Baolu
1 sibling, 0 replies; 3+ messages in thread
From: Lu Baolu @ 2020-06-01 0:42 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, Lu Baolu
When using first-level translation for IOVA, currently the U/S bit in the
page table is cleared which implies DMA requests with user privilege are
blocked. As the result, following error messages might be observed when
passing through a device to user level:
DMAR: DRHD: handling fault status reg 3
DMAR: [DMA Read] Request device [41:00.0] PASID 1 fault addr 7ecdcd000
[fault reason 129] SM: U/S set 0 for first-level translation
with user privilege
This fixes it by setting U/S bit in the first level page table and makes
IOVA over first level compatible with previous second-level translation.
Fixes: b802d070a52a1 ("iommu/vt-d: Use iova over first level")
Reported-by: Xin Zeng <xin.zeng@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/iommu/intel-iommu.c | 5 ++---
include/linux/intel-iommu.h | 1 +
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 648a785e078a..d148712466b4 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -921,7 +921,7 @@ 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;
+ pteval |= DMA_FL_PTE_XD | DMA_FL_PTE_US;
if (cmpxchg64(&pte->val, 0ULL, pteval))
/* Someone else set it while we were thinking; use theirs. */
free_pgtable_page(tmp_page);
@@ -1951,7 +1951,6 @@ static inline void
context_set_sm_rid2pasid(struct context_entry *context, unsigned long pasid)
{
context->hi |= pasid & ((1 << 20) - 1);
- context->hi |= (1 << 20);
}
/*
@@ -2243,7 +2242,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
attr = prot & (DMA_PTE_READ | DMA_PTE_WRITE | DMA_PTE_SNP);
if (domain_use_first_level(domain))
- attr |= DMA_FL_PTE_PRESENT | DMA_FL_PTE_XD;
+ attr |= DMA_FL_PTE_PRESENT | DMA_FL_PTE_XD | DMA_FL_PTE_US;
if (!sg) {
sg_res = nr_pages;
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 4100bd224f5c..3e8fa1c7a1e6 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -41,6 +41,7 @@
#define DMA_PTE_SNP BIT_ULL(11)
#define DMA_FL_PTE_PRESENT BIT_ULL(0)
+#define DMA_FL_PTE_US BIT_ULL(2)
#define DMA_FL_PTE_XD BIT_ULL(63)
#define ADDR_WIDTH_5LEVEL (57)
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-01 0:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01 0:42 [PATCH 0/2] iommu/vt-d: Two fixes for v5.8 Lu Baolu
2020-06-01 0:42 ` [PATCH 1/2] iommu/vt-d: Make Intel SVM code 64-bit only Lu Baolu
2020-06-01 0:42 ` [PATCH 2/2] iommu/vt-d: Set U/S bit in first level page table by default Lu Baolu
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).