diff options
author | Dave Hansen <dave.hansen@linux.intel.com> | 2018-04-06 16:55:04 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-04-09 12:27:32 -0400 |
commit | 606c7193d5fbf8ea3dafc8a9468f719fbf1d7160 (patch) | |
tree | f07bf8b86b0b6039ded4ffb77cc55c1e654e7ac3 | |
parent | d1440b23c922d845ff039f64694a32ff356e89fa (diff) |
x86/mm: Undo double _PAGE_PSE clearing
When clearing _PAGE_PRESENT on a huge page, we need to be careful
to also clear _PAGE_PSE, otherwise it might still get confused
for a valid large page table entry.
We do that near the spot where we *set* _PAGE_PSE. That's fine,
but it's unnecessary. pgprot_large_2_4k() already did it.
BTW, I also noticed that pgprot_large_2_4k() and
pgprot_4k_2_large() are not symmetric. pgprot_large_2_4k() clears
_PAGE_PSE (because it is aliased to _PAGE_PAT) but
pgprot_4k_2_large() does not put _PAGE_PSE back. Bummer.
Also, add some comments and change "promote" to "move". "Promote"
seems an odd word to move when we are logically moving a bit to a
lower bit position. Also add an extra line return to make it clear
to which line the comment applies.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Kees Cook <keescook@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nadav Amit <namit@vmware.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/20180406205504.9B0F44A9@viggo.jf.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/mm/pageattr.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 4d369d5c04c5..d3442dfdfced 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c | |||
@@ -583,6 +583,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address, | |||
583 | * up accordingly. | 583 | * up accordingly. |
584 | */ | 584 | */ |
585 | old_pte = *kpte; | 585 | old_pte = *kpte; |
586 | /* Clear PSE (aka _PAGE_PAT) and move PAT bit to correct position */ | ||
586 | req_prot = pgprot_large_2_4k(old_prot); | 587 | req_prot = pgprot_large_2_4k(old_prot); |
587 | 588 | ||
588 | pgprot_val(req_prot) &= ~pgprot_val(cpa->mask_clr); | 589 | pgprot_val(req_prot) &= ~pgprot_val(cpa->mask_clr); |
@@ -597,8 +598,6 @@ try_preserve_large_page(pte_t *kpte, unsigned long address, | |||
597 | req_prot = pgprot_clear_protnone_bits(req_prot); | 598 | req_prot = pgprot_clear_protnone_bits(req_prot); |
598 | if (pgprot_val(req_prot) & _PAGE_PRESENT) | 599 | if (pgprot_val(req_prot) & _PAGE_PRESENT) |
599 | pgprot_val(req_prot) |= _PAGE_PSE; | 600 | pgprot_val(req_prot) |= _PAGE_PSE; |
600 | else | ||
601 | pgprot_val(req_prot) &= ~_PAGE_PSE; | ||
602 | req_prot = canon_pgprot(req_prot); | 601 | req_prot = canon_pgprot(req_prot); |
603 | 602 | ||
604 | /* | 603 | /* |
@@ -684,8 +683,12 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address, | |||
684 | switch (level) { | 683 | switch (level) { |
685 | case PG_LEVEL_2M: | 684 | case PG_LEVEL_2M: |
686 | ref_prot = pmd_pgprot(*(pmd_t *)kpte); | 685 | ref_prot = pmd_pgprot(*(pmd_t *)kpte); |
687 | /* clear PSE and promote PAT bit to correct position */ | 686 | /* |
687 | * Clear PSE (aka _PAGE_PAT) and move | ||
688 | * PAT bit to correct position. | ||
689 | */ | ||
688 | ref_prot = pgprot_large_2_4k(ref_prot); | 690 | ref_prot = pgprot_large_2_4k(ref_prot); |
691 | |||
689 | ref_pfn = pmd_pfn(*(pmd_t *)kpte); | 692 | ref_pfn = pmd_pfn(*(pmd_t *)kpte); |
690 | break; | 693 | break; |
691 | 694 | ||