Skip to content
Commit 6491d4d0 authored by Woodhouse, David's avatar Woodhouse, David Committed by Linus Torvalds
Browse files

intel-iommu: Free old page tables before creating superpage



The dma_pte_free_pagetable() function will only free a page table page
if it is asked to free the *entire* 2MiB range that it covers. So if a
page table page was used for one or more small mappings, it's likely to
end up still present in the page tables... but with no valid PTEs.

This was fine when we'd only be repopulating it with 4KiB PTEs anyway
but the same virtual address range can end up being reused for a
*large-page* mapping. And in that case were were trying to insert the
large page into the second-level page table, and getting a complaint
from the sanity check in __domain_mapping() because there was already a
corresponding entry. This was *relatively* harmless; it led to a memory
leak of the old page table page, but no other ill-effects.

Fix it by calling dma_pte_clear_range (hopefully redundant) and
dma_pte_free_pagetable() before setting up the new large page.

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
Tested-by: default avatarRavi Murty <Ravi.Murty@intel.com>
Tested-by: default avatarSudeep Dutt <sudeep.dutt@intel.com>
Cc: stable@kernel.org [3.0+]
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 18000985
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment