Skip to content

Commit 10d83d7

Browse files
xzpeterakpm00
authored andcommitted
mm/pagewalk: check pfnmap for folio_walk_start()
Teach folio_walk_start() to recognize special pmd/pud mappings, and fail them properly as it means there's no folio backing them. [[email protected]: remove some stale comments, per David] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Peter Xu <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Gavin Shan <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Niklas Schnelle <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Will Deacon <[email protected]> Cc: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ae3c99e commit 10d83d7

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

mm/memory.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,10 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
672672
{
673673
unsigned long pfn = pmd_pfn(pmd);
674674

675-
/*
676-
* There is no pmd_special() but there may be special pmds, e.g.
677-
* in a direct-access (dax) mapping, so let's just replicate the
678-
* !CONFIG_ARCH_HAS_PTE_SPECIAL case from vm_normal_page() here.
679-
*/
675+
/* Currently it's only used for huge pfnmaps */
676+
if (unlikely(pmd_special(pmd)))
677+
return NULL;
678+
680679
if (unlikely(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))) {
681680
if (vma->vm_flags & VM_MIXEDMAP) {
682681
if (!pfn_valid(pfn))

mm/pagewalk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ struct folio *folio_walk_start(struct folio_walk *fw,
753753
fw->pudp = pudp;
754754
fw->pud = pud;
755755

756-
if (!pud_present(pud) || pud_devmap(pud)) {
756+
if (!pud_present(pud) || pud_devmap(pud) || pud_special(pud)) {
757757
spin_unlock(ptl);
758758
goto not_found;
759759
} else if (!pud_leaf(pud)) {

0 commit comments

Comments
 (0)