diff options
| -rw-r--r-- | arch/x86/mm/gup.c | 2 | ||||
| -rw-r--r-- | arch/x86/mm/hugetlbpage.c | 8 | ||||
| -rw-r--r-- | mm/hugetlb.c | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c index d7547824e763..224b14235e96 100644 --- a/arch/x86/mm/gup.c +++ b/arch/x86/mm/gup.c | |||
| @@ -172,7 +172,7 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end, | |||
| 172 | */ | 172 | */ |
| 173 | if (pmd_none(pmd) || pmd_trans_splitting(pmd)) | 173 | if (pmd_none(pmd) || pmd_trans_splitting(pmd)) |
| 174 | return 0; | 174 | return 0; |
| 175 | if (unlikely(pmd_large(pmd))) { | 175 | if (unlikely(pmd_large(pmd) || !pmd_present(pmd))) { |
| 176 | /* | 176 | /* |
| 177 | * NUMA hinting faults need to be handled in the GUP | 177 | * NUMA hinting faults need to be handled in the GUP |
| 178 | * slowpath for accounting purposes and so that they | 178 | * slowpath for accounting purposes and so that they |
diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c index f48423f10141..42982b26e32b 100644 --- a/arch/x86/mm/hugetlbpage.c +++ b/arch/x86/mm/hugetlbpage.c | |||
| @@ -54,9 +54,15 @@ int pud_huge(pud_t pud) | |||
| 54 | 54 | ||
| 55 | #else | 55 | #else |
| 56 | 56 | ||
| 57 | /* | ||
| 58 | * pmd_huge() returns 1 if @pmd is hugetlb related entry, that is normal | ||
| 59 | * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry. | ||
| 60 | * Otherwise, returns 0. | ||
| 61 | */ | ||
| 57 | int pmd_huge(pmd_t pmd) | 62 | int pmd_huge(pmd_t pmd) |
| 58 | { | 63 | { |
| 59 | return !!(pmd_val(pmd) & _PAGE_PSE); | 64 | return !pmd_none(pmd) && |
| 65 | (pmd_val(pmd) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT; | ||
| 60 | } | 66 | } |
| 61 | 67 | ||
| 62 | int pud_huge(pud_t pud) | 68 | int pud_huge(pud_t pud) |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index f533d336e569..d96b8bfa748f 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
| @@ -3679,6 +3679,8 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address, | |||
| 3679 | { | 3679 | { |
| 3680 | struct page *page; | 3680 | struct page *page; |
| 3681 | 3681 | ||
| 3682 | if (!pmd_present(*pmd)) | ||
| 3683 | return NULL; | ||
| 3682 | page = pte_page(*(pte_t *)pmd); | 3684 | page = pte_page(*(pte_t *)pmd); |
| 3683 | if (page) | 3685 | if (page) |
| 3684 | page += ((address & ~PMD_MASK) >> PAGE_SHIFT); | 3686 | page += ((address & ~PMD_MASK) >> PAGE_SHIFT); |
