Messages in this thread Patch in this message | | | From | Mircea CIRJALIU - MELIU <> | Subject | [RFC PATCH v1 3/4] thp: fix huge page zapping for special PMDs | Date | Wed, 11 Dec 2019 09:29:20 +0000 |
| |
When calling zap_vma_ptes() on VM_PFNMAP VMAs involving huge mappings, pmd_page() will return an invalid page, causing trouble. Use instead vm_normal_page_pmd() and test for returned page like zap_pte_range().
Signed-off-by: Mircea Cirjaliu <mcirjaliu@bitdefender.com> --- mm/huge_memory.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 41a0fbd..92ce487 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1804,7 +1804,11 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, int flush_needed = 1; if (pmd_present(orig_pmd)) { - page = pmd_page(orig_pmd); + page = vm_normal_page_pmd(vma, addr, orig_pmd); + if (unlikely(!page)) { + spin_unlock(ptl); + return 1; + } page_remove_rmap(page, true); VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); VM_BUG_ON_PAGE(!PageHead(page), page);
| |