From: Sabyrzhan Tasbolatov <snovit...@gmail.com> With the help of static key kasan_flag_enabled, kasan_arch_is_ready() is not needed any more. So reomve the unneeded kasan_arch_is_ready() and the relevant codes.
And also error out if both CONFIG_STATIC_LINK and CONFIG_KASAN_INLINE are set at the same time as UML supports each of them but done's support both at the same time. And also add code comment to explain why static key kasan_flag_enabled need be deferred to arch_mm_preinit(). Signed-off-by: Sabyrzhan Tasbolatov <snovit...@gmail.com> Signed-off-by: Baoquan He <b...@redhat.com> --- arch/um/include/asm/kasan.h | 5 ++--- arch/um/kernel/mem.c | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/um/include/asm/kasan.h b/arch/um/include/asm/kasan.h index f97bb1f7b851..b54a4e937fd1 100644 --- a/arch/um/include/asm/kasan.h +++ b/arch/um/include/asm/kasan.h @@ -24,10 +24,9 @@ #ifdef CONFIG_KASAN void kasan_init(void); -extern int kasan_um_is_ready; -#ifdef CONFIG_STATIC_LINK -#define kasan_arch_is_ready() (kasan_um_is_ready) +#if defined(CONFIG_STATIC_LINK) && defined(CONFIG_KASAN_INLINE) +#error UML does not work in KASAN_INLINE mode with STATIC_LINK enabled! #endif #else static inline void kasan_init(void) { } diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 392a23d4ef96..d62f494e0808 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -35,7 +35,11 @@ void kasan_init(void) */ kasan_map_memory((void *)KASAN_SHADOW_START, KASAN_SHADOW_SIZE); init_task.kasan_depth = 0; - kasan_um_is_ready = true; + /* + * Since kasan_init() is called before main(), + * KASAN is initialized but the enablement is deferred after + * jump_label_init(). See arch_mm_preinit(). + */ } static void (*kasan_init_ptr)(void) -- 2.41.0