• D
    x86/mm: Factor out pageattr _PAGE_GLOBAL setting · d1440b23
    Dave Hansen 提交于
    The pageattr code has a pattern repeated where it sets _PAGE_GLOBAL
    for present PTEs but clears it for non-present PTEs.  The intention
    is to keep _PAGE_GLOBAL from getting confused with _PAGE_PROTNONE
    since _PAGE_GLOBAL is for present PTEs and _PAGE_PROTNONE is for
    non-present
    
    But, this pattern makes no sense.  Effectively, it says, if you use
    the pageattr code, always set _PAGE_GLOBAL when _PAGE_PRESENT.
    canon_pgprot() will clear it if unsupported (because it masks the
    value with __supported_pte_mask) but we *always* set it. Even if
    canon_pgprot() did not filter _PAGE_GLOBAL, it would be OK.
    _PAGE_GLOBAL is ignored when CR4.PGE=0 by the hardware.
    
    This unconditional setting of _PAGE_GLOBAL is a problem when we have
    PTI and non-PTI and we want some areas to have _PAGE_GLOBAL and some
    not.
    
    This updated version of the code says:
    1. Clear _PAGE_GLOBAL when !_PAGE_PRESENT
    2. Never set _PAGE_GLOBAL implicitly
    3. Allow _PAGE_GLOBAL to be in cpa.set_mask
    4. Allow _PAGE_GLOBAL to be inherited from previous PTE
    Signed-off-by: NDave 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/20180406205502.86E199DA@viggo.jf.intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
    d1440b23
pageattr.c 49.7 KB