Merge branch 'linus' into sched/core, to pick up fixes
authorIngo Molnar <mingo@kernel.org>
Fri, 30 Sep 2016 08:44:27 +0000 (10:44 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 30 Sep 2016 08:44:27 +0000 (10:44 +0200)
Signed-off-by: Ingo Molnar <mingo@kernel.org>
1  2 
mm/huge_memory.c
mm/memory.c

diff --combined mm/huge_memory.c
@@@ -1138,9 -1138,6 +1138,6 @@@ int do_huge_pmd_numa_page(struct fault_
        bool was_writable;
        int flags = 0;
  
-       /* A PROT_NONE fault should not end up here */
-       BUG_ON(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)));
        fe->ptl = pmd_lock(vma->vm_mm, fe->pmd);
        if (unlikely(!pmd_same(pmd, *fe->pmd)))
                goto out_unlock;
        }
  
        /* See similar comment in do_numa_page for explanation */
 -      if (!(vma->vm_flags & VM_WRITE))
 +      if (!pmd_write(pmd))
                flags |= TNF_NO_GROUP;
  
        /*
diff --combined mm/memory.c
@@@ -3351,9 -3351,6 +3351,6 @@@ static int do_numa_page(struct fault_en
        bool was_writable = pte_write(pte);
        int flags = 0;
  
-       /* A PROT_NONE fault should not end up here */
-       BUG_ON(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)));
        /*
        * The "pte" at this point cannot be used safely without
        * validation through pte_unmap_same(). It's of NUMA type but
         * pte_dirty has unpredictable behaviour between PTE scan updates,
         * background writeback, dirty balancing and application behaviour.
         */
 -      if (!(vma->vm_flags & VM_WRITE))
 +      if (!pte_write(pte))
                flags |= TNF_NO_GROUP;
  
        /*
@@@ -3458,6 -3455,11 +3455,11 @@@ static int wp_huge_pmd(struct fault_en
        return VM_FAULT_FALLBACK;
  }
  
+ static inline bool vma_is_accessible(struct vm_area_struct *vma)
+ {
+       return vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE);
+ }
  /*
   * These routines also need to handle stuff like marking pages dirty
   * and/or accessed for architectures that don't do it in hardware (most
@@@ -3524,7 -3526,7 +3526,7 @@@ static int handle_pte_fault(struct faul
        if (!pte_present(entry))
                return do_swap_page(fe, entry);
  
-       if (pte_protnone(entry))
+       if (pte_protnone(entry) && vma_is_accessible(fe->vma))
                return do_numa_page(fe, entry);
  
        fe->ptl = pte_lockptr(fe->vma->vm_mm, fe->pmd);
@@@ -3590,7 -3592,7 +3592,7 @@@ static int __handle_mm_fault(struct vm_
  
                barrier();
                if (pmd_trans_huge(orig_pmd) || pmd_devmap(orig_pmd)) {
-                       if (pmd_protnone(orig_pmd))
+                       if (pmd_protnone(orig_pmd) && vma_is_accessible(vma))
                                return do_huge_pmd_numa_page(&fe, orig_pmd);
  
                        if ((fe.flags & FAULT_FLAG_WRITE) &&