diff options
author | Dave Hansen <dave.hansen@linux.intel.com> | 2016-07-07 20:19:12 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-07-13 03:43:25 -0400 |
commit | 97e3c602ccbdd7db54e92fe05675c664c052a466 (patch) | |
tree | 545003282185d14130c86c6e8ec2dbe4516cc2db | |
parent | 00839ee3b299303c6a5e26a0a2485427a3afcbbf (diff) |
x86/mm: Ignore A/D bits in pte/pmd/pud_none()
The erratum we are fixing here can lead to stray setting of the
A and D bits. That means that a pte that we cleared might
suddenly have A/D set. So, stop considering those bits when
determining if a pte is pte_none(). The same goes for the
other pmd_none() and pud_none(). pgd_none() can be skipped
because it is not affected; we do not use PGD entries for
anything other than pagetables on affected configurations.
This adds a tiny amount of overhead to all pte_none() checks.
I doubt we'll be able to measure it anywhere.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave@sr71.net>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: dave.hansen@intel.com
Cc: linux-mm@kvack.org
Cc: mhocko@suse.com
Link: http://lkml.kernel.org/r/20160708001912.5216F89C@viggo.jf.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/pgtable.h | 13 | ||||
-rw-r--r-- | arch/x86/include/asm/pgtable_types.h | 6 |
2 files changed, 16 insertions, 3 deletions
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 1a27396b6ea0..2815d268af8b 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
@@ -480,7 +480,7 @@ pte_t *populate_extra_pte(unsigned long vaddr); | |||
480 | 480 | ||
481 | static inline int pte_none(pte_t pte) | 481 | static inline int pte_none(pte_t pte) |
482 | { | 482 | { |
483 | return !pte.pte; | 483 | return !(pte.pte & ~(_PAGE_KNL_ERRATUM_MASK)); |
484 | } | 484 | } |
485 | 485 | ||
486 | #define __HAVE_ARCH_PTE_SAME | 486 | #define __HAVE_ARCH_PTE_SAME |
@@ -552,7 +552,8 @@ static inline int pmd_none(pmd_t pmd) | |||
552 | { | 552 | { |
553 | /* Only check low word on 32-bit platforms, since it might be | 553 | /* Only check low word on 32-bit platforms, since it might be |
554 | out of sync with upper half. */ | 554 | out of sync with upper half. */ |
555 | return (unsigned long)native_pmd_val(pmd) == 0; | 555 | unsigned long val = native_pmd_val(pmd); |
556 | return (val & ~_PAGE_KNL_ERRATUM_MASK) == 0; | ||
556 | } | 557 | } |
557 | 558 | ||
558 | static inline unsigned long pmd_page_vaddr(pmd_t pmd) | 559 | static inline unsigned long pmd_page_vaddr(pmd_t pmd) |
@@ -616,7 +617,7 @@ static inline unsigned long pages_to_mb(unsigned long npg) | |||
616 | #if CONFIG_PGTABLE_LEVELS > 2 | 617 | #if CONFIG_PGTABLE_LEVELS > 2 |
617 | static inline int pud_none(pud_t pud) | 618 | static inline int pud_none(pud_t pud) |
618 | { | 619 | { |
619 | return native_pud_val(pud) == 0; | 620 | return (native_pud_val(pud) & ~(_PAGE_KNL_ERRATUM_MASK)) == 0; |
620 | } | 621 | } |
621 | 622 | ||
622 | static inline int pud_present(pud_t pud) | 623 | static inline int pud_present(pud_t pud) |
@@ -694,6 +695,12 @@ static inline int pgd_bad(pgd_t pgd) | |||
694 | 695 | ||
695 | static inline int pgd_none(pgd_t pgd) | 696 | static inline int pgd_none(pgd_t pgd) |
696 | { | 697 | { |
698 | /* | ||
699 | * There is no need to do a workaround for the KNL stray | ||
700 | * A/D bit erratum here. PGDs only point to page tables | ||
701 | * except on 32-bit non-PAE which is not supported on | ||
702 | * KNL. | ||
703 | */ | ||
697 | return !native_pgd_val(pgd); | 704 | return !native_pgd_val(pgd); |
698 | } | 705 | } |
699 | #endif /* CONFIG_PGTABLE_LEVELS > 3 */ | 706 | #endif /* CONFIG_PGTABLE_LEVELS > 3 */ |
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index 7b5efe264eff..d14d0a55322a 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h | |||
@@ -70,6 +70,12 @@ | |||
70 | _PAGE_PKEY_BIT2 | \ | 70 | _PAGE_PKEY_BIT2 | \ |
71 | _PAGE_PKEY_BIT3) | 71 | _PAGE_PKEY_BIT3) |
72 | 72 | ||
73 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) | ||
74 | #define _PAGE_KNL_ERRATUM_MASK (_PAGE_DIRTY | _PAGE_ACCESSED) | ||
75 | #else | ||
76 | #define _PAGE_KNL_ERRATUM_MASK 0 | ||
77 | #endif | ||
78 | |||
73 | #ifdef CONFIG_KMEMCHECK | 79 | #ifdef CONFIG_KMEMCHECK |
74 | #define _PAGE_HIDDEN (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN) | 80 | #define _PAGE_HIDDEN (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN) |
75 | #else | 81 | #else |