Skip to content

Commit

Permalink
Revert "x86, mm: Make spurious_fault check explicitly check explicitl…
Browse files Browse the repository at this point in the history
…y check the PRESENT bit"

I got a report for a minor regression introduced by commit
027ef6c ("mm: thp: fix pmd_present for split_huge_page and
PROT_NONE with THP").

So the problem is, pageattr creates kernel pagetables (pte and
pmds) that breaks pte_present/pmd_present and the patch above
exposed this invariant breakage for pmd_present.

The same problem already existed for the pte and pte_present and
it was fixed by commit 660a293 ("x86, mm: Make
spurious_fault check explicitly check the PRESENT bit") (if it
wasn't for that commit, it wouldn't even be a regression).  That
fix avoids the pagefault to use pte_present.  I could follow
through by stopping using pmd_present/pmd_huge too.

However I think it's more robust to fix pageattr and to clear
the PSE/GLOBAL bitflags too in addition to the present bitflag.
So the kernel page fault can keep using the regular
pte_present/pmd_present/pmd_huge.

The confusion arises because _PAGE_GLOBAL and _PAGE_PROTNONE are
sharing the same bit, and in the pmd case we pretend _PAGE_PSE
to be set only in present pmds (to facilitate split_huge_page
final tlb flush).

Signed-off-by: Andrea Arcangeli <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Shaohua Li <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
aagit authored and Ingo Molnar committed Feb 24, 2013
1 parent 942670d commit 954f857
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,14 +939,8 @@ spurious_fault(unsigned long error_code, unsigned long address)
if (pmd_large(*pmd))
return spurious_fault_check(error_code, (pte_t *) pmd);

/*
* Note: don't use pte_present() here, since it returns true
* if the _PAGE_PROTNONE bit is set. However, this aliases the
* _PAGE_GLOBAL bit, which for kernel pages give false positives
* when CONFIG_DEBUG_PAGEALLOC is used.
*/
pte = pte_offset_kernel(pmd, address);
if (!(pte_flags(*pte) & _PAGE_PRESENT))
if (!pte_present(*pte))
return 0;

ret = spurious_fault_check(error_code, pte);
Expand Down

0 comments on commit 954f857

Please sign in to comment.