Skip to content

Commit 2d6ffc6

Browse files
LuBaoluwilldeacon
authored andcommitted
iommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev()
The VT-d hardware will ignore those Addr bits which have been masked by the AM field in the PASID-based-IOTLB invalidation descriptor. As the result, if the starting address in the descriptor is not aligned with the address mask, some IOTLB caches might not invalidate. Hence people will see below errors. [ 1093.704661] dmar_fault: 29 callbacks suppressed [ 1093.704664] DMAR: DRHD: handling fault status reg 3 [ 1093.712738] DMAR: [DMA Read] Request device [7a:02.0] PASID 2 fault addr 7f81c968d000 [fault reason 113] SM: Present bit in first-level paging entry is clear Fix this by using aligned address for PASID-based-IOTLB invalidation. Fixes: 1c4f88b ("iommu/vt-d: Shared virtual address in scalable mode") Reported-and-tested-by: Guo Kaijie <[email protected]> Signed-off-by: Lu Baolu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 7c29ada commit 2d6ffc6

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

drivers/iommu/intel/svm.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ void intel_svm_check(struct intel_iommu *iommu)
118118
iommu->flags |= VTD_FLAG_SVM_CAPABLE;
119119
}
120120

121-
static void intel_flush_svm_range_dev (struct intel_svm *svm, struct intel_svm_dev *sdev,
122-
unsigned long address, unsigned long pages, int ih)
121+
static void __flush_svm_range_dev(struct intel_svm *svm,
122+
struct intel_svm_dev *sdev,
123+
unsigned long address,
124+
unsigned long pages, int ih)
123125
{
124126
struct qi_desc desc;
125127

@@ -170,6 +172,22 @@ static void intel_flush_svm_range_dev (struct intel_svm *svm, struct intel_svm_d
170172
}
171173
}
172174

175+
static void intel_flush_svm_range_dev(struct intel_svm *svm,
176+
struct intel_svm_dev *sdev,
177+
unsigned long address,
178+
unsigned long pages, int ih)
179+
{
180+
unsigned long shift = ilog2(__roundup_pow_of_two(pages));
181+
unsigned long align = (1ULL << (VTD_PAGE_SHIFT + shift));
182+
unsigned long start = ALIGN_DOWN(address, align);
183+
unsigned long end = ALIGN(address + (pages << VTD_PAGE_SHIFT), align);
184+
185+
while (start < end) {
186+
__flush_svm_range_dev(svm, sdev, start, align >> VTD_PAGE_SHIFT, ih);
187+
start += align;
188+
}
189+
}
190+
173191
static void intel_flush_svm_range(struct intel_svm *svm, unsigned long address,
174192
unsigned long pages, int ih)
175193
{

0 commit comments

Comments
 (0)