lkml.org 
[lkml]   [2017]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 26/43] x86/mm/kaiser: Allow NX poison to be set in p4d/pgd
    Date
    From: Dave Hansen <dave.hansen@linux.intel.com>

    The user portion of the kernel page tables use the NX bit to
    poison them for userspace. But, that trips the p4d/pgd_bad()
    checks. Make sure it does not do that.

    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: daniel.gruss@iaik.tugraz.at
    Cc: hughd@google.com
    Cc: keescook@google.com
    Cc: linux-mm@kvack.org
    Cc: luto@kernel.org
    Cc: michael.schwarz@iaik.tugraz.at
    Cc: moritz.lipp@iaik.tugraz.at
    Cc: richard.fellner@student.tugraz.at
    Link: https://lkml.kernel.org/r/20171123003448.C6AB3575@viggo.jf.intel.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    ---
    arch/x86/include/asm/pgtable.h | 14 ++++++++++++--
    1 file changed, 12 insertions(+), 2 deletions(-)

    diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
    index d3901124143f..9cceaf6c0405 100644
    --- a/arch/x86/include/asm/pgtable.h
    +++ b/arch/x86/include/asm/pgtable.h
    @@ -846,7 +846,12 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)

    static inline int p4d_bad(p4d_t p4d)
    {
    - return (p4d_flags(p4d) & ~(_KERNPG_TABLE | _PAGE_USER)) != 0;
    + unsigned long ignore_flags = _KERNPG_TABLE | _PAGE_USER;
    +
    + if (IS_ENABLED(CONFIG_KAISER))
    + ignore_flags |= _PAGE_NX;
    +
    + return (p4d_flags(p4d) & ~ignore_flags) != 0;
    }
    #endif /* CONFIG_PGTABLE_LEVELS > 3 */

    @@ -880,7 +885,12 @@ static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)

    static inline int pgd_bad(pgd_t pgd)
    {
    - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
    + unsigned long ignore_flags = _PAGE_USER;
    +
    + if (IS_ENABLED(CONFIG_KAISER))
    + ignore_flags |= _PAGE_NX;
    +
    + return (pgd_flags(pgd) & ~ignore_flags) != _KERNPG_TABLE;
    }

    static inline int pgd_none(pgd_t pgd)
    --
    2.14.1
    \
     
     \ /
      Last update: 2017-11-24 18:30    [W:3.235 / U:2.676 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site