diff options
Diffstat (limited to 'mm/memory.c')
| -rw-r--r-- | mm/memory.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mm/memory.c b/mm/memory.c index 93897f23cc11..305537fc8640 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
| @@ -789,6 +789,46 @@ out: | |||
| 789 | return pfn_to_page(pfn); | 789 | return pfn_to_page(pfn); |
| 790 | } | 790 | } |
| 791 | 791 | ||
| 792 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
| 793 | struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, | ||
| 794 | pmd_t pmd) | ||
| 795 | { | ||
| 796 | unsigned long pfn = pmd_pfn(pmd); | ||
| 797 | |||
| 798 | /* | ||
| 799 | * There is no pmd_special() but there may be special pmds, e.g. | ||
| 800 | * in a direct-access (dax) mapping, so let's just replicate the | ||
| 801 | * !HAVE_PTE_SPECIAL case from vm_normal_page() here. | ||
| 802 | */ | ||
| 803 | if (unlikely(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))) { | ||
| 804 | if (vma->vm_flags & VM_MIXEDMAP) { | ||
| 805 | if (!pfn_valid(pfn)) | ||
| 806 | return NULL; | ||
| 807 | goto out; | ||
| 808 | } else { | ||
| 809 | unsigned long off; | ||
| 810 | off = (addr - vma->vm_start) >> PAGE_SHIFT; | ||
| 811 | if (pfn == vma->vm_pgoff + off) | ||
| 812 | return NULL; | ||
| 813 | if (!is_cow_mapping(vma->vm_flags)) | ||
| 814 | return NULL; | ||
| 815 | } | ||
| 816 | } | ||
| 817 | |||
| 818 | if (is_zero_pfn(pfn)) | ||
| 819 | return NULL; | ||
| 820 | if (unlikely(pfn > highest_memmap_pfn)) | ||
| 821 | return NULL; | ||
| 822 | |||
| 823 | /* | ||
| 824 | * NOTE! We still have PageReserved() pages in the page tables. | ||
| 825 | * eg. VDSO mappings can cause them to exist. | ||
| 826 | */ | ||
| 827 | out: | ||
| 828 | return pfn_to_page(pfn); | ||
| 829 | } | ||
| 830 | #endif | ||
| 831 | |||
| 792 | /* | 832 | /* |
| 793 | * copy one vm_area from one task to the other. Assumes the page tables | 833 | * copy one vm_area from one task to the other. Assumes the page tables |
| 794 | * already present in the new task to be cleared in the whole range | 834 | * already present in the new task to be cleared in the whole range |
