Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

book3s64/radix: Refactoring common kfence related functions

Both radix and hash on book3s requires to detect if kfence
early init is enabled or not. Hash needs to disable kfence
if early init is not enabled because with kfence the linear map is
mapped using PAGE_SIZE rather than 16M mapping.
We don't support multiple page sizes for slb entry used for kernel
linear map in book3s64.

This patch refactors out the common functions required to detect kfence
early init is enabled or not.

Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/f4a787224fbe5bb787158ace579780c0257f6602.1729271995.git.ritesh.list@gmail.com

authored by

Ritesh Harjani (IBM) and committed by
Michael Ellerman
b5fbf7e2 8fec58f5

+20 -14
+6 -2
arch/powerpc/include/asm/kfence.h
··· 15 15 #define ARCH_FUNC_PREFIX "." 16 16 #endif 17 17 18 - #ifdef CONFIG_KFENCE 18 + extern bool kfence_early_init; 19 19 extern bool kfence_disabled; 20 20 21 21 static inline void disable_kfence(void) ··· 27 27 { 28 28 return !kfence_disabled; 29 29 } 30 - #endif 30 + 31 + static inline bool kfence_early_init_enabled(void) 32 + { 33 + return IS_ENABLED(CONFIG_KFENCE) && kfence_early_init; 34 + } 31 35 32 36 #ifdef CONFIG_PPC64 33 37 static inline bool kfence_protect_page(unsigned long addr, bool protect)
+13
arch/powerpc/mm/book3s64/pgtable.c
··· 37 37 unsigned long __pmd_frag_size_shift; 38 38 EXPORT_SYMBOL(__pmd_frag_size_shift); 39 39 40 + #ifdef CONFIG_KFENCE 41 + extern bool kfence_early_init; 42 + static int __init parse_kfence_early_init(char *arg) 43 + { 44 + int val; 45 + 46 + if (get_option(&arg, &val)) 47 + kfence_early_init = !!val; 48 + return 0; 49 + } 50 + early_param("kfence.sample_interval", parse_kfence_early_init); 51 + #endif 52 + 40 53 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 41 54 /* 42 55 * This is called when relaxing access to a hugepage. It's also called in the page
-12
arch/powerpc/mm/book3s64/radix_pgtable.c
··· 363 363 } 364 364 365 365 #ifdef CONFIG_KFENCE 366 - static bool __ro_after_init kfence_early_init = !!CONFIG_KFENCE_SAMPLE_INTERVAL; 367 - 368 - static int __init parse_kfence_early_init(char *arg) 369 - { 370 - int val; 371 - 372 - if (get_option(&arg, &val)) 373 - kfence_early_init = !!val; 374 - return 0; 375 - } 376 - early_param("kfence.sample_interval", parse_kfence_early_init); 377 - 378 366 static inline phys_addr_t alloc_kfence_pool(void) 379 367 { 380 368 phys_addr_t kfence_pool;
+1
arch/powerpc/mm/init-common.c
··· 33 33 bool disable_kuap = !IS_ENABLED(CONFIG_PPC_KUAP); 34 34 #ifdef CONFIG_KFENCE 35 35 bool __ro_after_init kfence_disabled; 36 + bool __ro_after_init kfence_early_init = !!CONFIG_KFENCE_SAMPLE_INTERVAL; 36 37 #endif 37 38 38 39 static int __init parse_nosmep(char *p)