WIP: update tizen_qemu_defconfig
[platform/kernel/linux-starfive.git] / mm / gup.c
index fe195d4..f4911dd 100644 (file)
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1065,6 +1065,9 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
                if (!(vm_flags & VM_WRITE)) {
                        if (!(gup_flags & FOLL_FORCE))
                                return -EFAULT;
+                       /* hugetlb does not support FOLL_FORCE|FOLL_WRITE. */
+                       if (is_vm_hugetlb_page(vma))
+                               return -EFAULT;
                        /*
                         * We used to let the write,force case do COW in a
                         * VM_MAYWRITE VM_SHARED !VM_WRITE vma, so ptrace could
@@ -1179,7 +1182,7 @@ static long __get_user_pages(struct mm_struct *mm,
 
                /* first iteration or cross vma bound */
                if (!vma || start >= vma->vm_end) {
-                       vma = find_extend_vma(mm, start);
+                       vma = vma_lookup(mm, start);
                        if (!vma && in_gate_area(mm, start)) {
                                ret = get_gate_page(mm, start & PAGE_MASK,
                                                gup_flags, &vma,
@@ -1348,8 +1351,8 @@ int fixup_user_fault(struct mm_struct *mm,
                fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
 
 retry:
-       vma = find_extend_vma(mm, address);
-       if (!vma || address < vma->vm_start)
+       vma = vma_lookup(mm, address);
+       if (!vma)
                return -EFAULT;
 
        if (!vma_permits_fault(vma, fault_flags))
@@ -1975,7 +1978,7 @@ static unsigned long collect_longterm_unpinnable_pages(
                        drain_allow = false;
                }
 
-               if (!folio_isolate_lru(folio))
+               if (folio_isolate_lru(folio))
                        continue;
 
                list_add_tail(&folio->lru, movable_page_list);
@@ -2852,7 +2855,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo
                next = pud_addr_end(addr, end);
                if (unlikely(!pud_present(pud)))
                        return 0;
-               if (unlikely(pud_huge(pud))) {
+               if (unlikely(pud_huge(pud) || pud_devmap(pud))) {
                        if (!gup_huge_pud(pud, pudp, addr, next, flags,
                                          pages, nr))
                                return 0;