x86: pte_protnone() and pmd_protnone() must check entry is not present
[firefly-linux-kernel-4.4.55.git] / arch / x86 / include / asm / pgtable.h
index 67fc3d2b0aabe6e7b5a5af631b80bf9e8c25a46b..a0c35bf6cb92cf95abe8fc9ffe9f75c4f34b1fca 100644 (file)
@@ -476,12 +476,14 @@ static inline int pmd_present(pmd_t pmd)
  */
 static inline int pte_protnone(pte_t pte)
 {
-       return pte_flags(pte) & _PAGE_PROTNONE;
+       return (pte_flags(pte) & (_PAGE_PROTNONE | _PAGE_PRESENT))
+               == _PAGE_PROTNONE;
 }
 
 static inline int pmd_protnone(pmd_t pmd)
 {
-       return pmd_flags(pmd) & _PAGE_PROTNONE;
+       return (pmd_flags(pmd) & (_PAGE_PROTNONE | _PAGE_PRESENT))
+               == _PAGE_PROTNONE;
 }
 #endif /* CONFIG_NUMA_BALANCING */