x86/mm: Ignore A/D bits in pte/pmd/pud_none()
[cascardo/linux.git] / arch / x86 / include / asm / pgtable.h
index 1a27396..2815d26 100644 (file)
@@ -480,7 +480,7 @@ pte_t *populate_extra_pte(unsigned long vaddr);
 
 static inline int pte_none(pte_t pte)
 {
-       return !pte.pte;
+       return !(pte.pte & ~(_PAGE_KNL_ERRATUM_MASK));
 }
 
 #define __HAVE_ARCH_PTE_SAME
@@ -552,7 +552,8 @@ static inline int pmd_none(pmd_t pmd)
 {
        /* Only check low word on 32-bit platforms, since it might be
           out of sync with upper half. */
-       return (unsigned long)native_pmd_val(pmd) == 0;
+       unsigned long val = native_pmd_val(pmd);
+       return (val & ~_PAGE_KNL_ERRATUM_MASK) == 0;
 }
 
 static inline unsigned long pmd_page_vaddr(pmd_t pmd)
@@ -616,7 +617,7 @@ static inline unsigned long pages_to_mb(unsigned long npg)
 #if CONFIG_PGTABLE_LEVELS > 2
 static inline int pud_none(pud_t pud)
 {
-       return native_pud_val(pud) == 0;
+       return (native_pud_val(pud) & ~(_PAGE_KNL_ERRATUM_MASK)) == 0;
 }
 
 static inline int pud_present(pud_t pud)
@@ -694,6 +695,12 @@ static inline int pgd_bad(pgd_t pgd)
 
 static inline int pgd_none(pgd_t pgd)
 {
+       /*
+        * There is no need to do a workaround for the KNL stray
+        * A/D bit erratum here.  PGDs only point to page tables
+        * except on 32-bit non-PAE which is not supported on
+        * KNL.
+        */
        return !native_pgd_val(pgd);
 }
 #endif /* CONFIG_PGTABLE_LEVELS > 3 */