powerpc/mmu: add is_strict_kernel_rwx() helper
authorChristophe Leroy <christophe.leroy@c-s.fr>
Thu, 21 Feb 2019 19:08:45 +0000 (19:08 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 23 Feb 2019 10:04:32 +0000 (21:04 +1100)
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>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/mmu.h
arch/powerpc/mm/init_32.c

index 6d22a8e..d34ad16 100644 (file)
@@ -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.
index 3e59e5d..ee5a430 100644 (file)
@@ -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
 }
 
 /*