lkml.org 
[lkml]   [2019]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v5 09/16] powerpc/mmu: add is_strict_kernel_rwx() helper
    Date
    Add a helper to know whether STRICT_KERNEL_RWX is enabled.

    This is based on rodata_enabled flag which is defined only
    when CONFIG_STRICT_KERNEL_RWX is selected.

    Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
    ---
    arch/powerpc/include/asm/mmu.h | 11 +++++++++++
    arch/powerpc/mm/init_32.c | 4 +---
    2 files changed, 12 insertions(+), 3 deletions(-)

    diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
    index 6d22a8e78fe2..d34ad1657d7b 100644
    --- a/arch/powerpc/include/asm/mmu.h
    +++ b/arch/powerpc/include/asm/mmu.h
    @@ -289,6 +289,17 @@ static inline u16 get_mm_addr_key(struct mm_struct *mm, unsigned long address)
    }
    #endif /* CONFIG_PPC_MEM_KEYS */

    +#ifdef CONFIG_STRICT_KERNEL_RWX
    +static inline bool strict_kernel_rwx_enabled(void)
    +{
    + return rodata_enabled;
    +}
    +#else
    +static inline bool strict_kernel_rwx_enabled(void)
    +{
    + return false;
    +}
    +#endif
    #endif /* !__ASSEMBLY__ */

    /* The kernel use the constants below to index in the page sizes array.
    diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
    index 3e59e5d64b01..ee5a430b9a18 100644
    --- a/arch/powerpc/mm/init_32.c
    +++ b/arch/powerpc/mm/init_32.c
    @@ -108,12 +108,10 @@ static void __init MMU_setup(void)
    __map_without_bats = 1;
    __map_without_ltlbs = 1;
    }
    -#ifdef CONFIG_STRICT_KERNEL_RWX
    - if (rodata_enabled) {
    + if (strict_kernel_rwx_enabled()) {
    __map_without_bats = 1;
    __map_without_ltlbs = 1;
    }
    -#endif
    }

    /*
    --
    2.13.3
    \
     
     \ /
      Last update: 2019-02-21 20:10    [W:16.337 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site