Skip to content

Commit f164567

Browse files
duanzhenzhongjoergroedel
authored andcommitted
iommu/vt-d: Fix checks and print in pgtable_walk()
There are some issues in pgtable_walk(): 1. Super page is dumped as non-present page 2. dma_pte_superpage() should not check against leaf page table entries 3. Pointer pte is never NULL so checking it is meaningless 4. When an entry is not present, it still makes sense to dump the entry content. Fix 1,2 by checking dma_pte_superpage()'s returned value after level check. Fix 3 by removing pte check. Fix 4 by checking present bit after printing. By this chance, change to print "page table not present" instead of "PTE not present" to be clearer. Fixes: 914ff77 ("iommu/vt-d: Dump DMAR translation structure when DMA fault occurs") Signed-off-by: Zhenzhong Duan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 6ceb93f commit f164567

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,14 +596,15 @@ static void pgtable_walk(struct intel_iommu *iommu, unsigned long pfn,
596596
while (1) {
597597
offset = pfn_level_offset(pfn, level);
598598
pte = &parent[offset];
599-
if (!pte || (dma_pte_superpage(pte) || !dma_pte_present(pte))) {
600-
pr_info("PTE not present at level %d\n", level);
601-
break;
602-
}
603599

604600
pr_info("pte level: %d, pte value: 0x%016llx\n", level, pte->val);
605601

606-
if (level == 1)
602+
if (!dma_pte_present(pte)) {
603+
pr_info("page table not present at level %d\n", level - 1);
604+
break;
605+
}
606+
607+
if (level == 1 || dma_pte_superpage(pte))
607608
break;
608609

609610
parent = phys_to_virt(dma_pte_addr(pte));

0 commit comments

Comments
 (0)