[PATCH v5 06/15] arch/arm: don't initialize kasan if it's disabled

Baoquan He
2026-02-25T08:15:58Z

Here, kasan is disabled if specified 'kasan=off' in kernel cmdline.

And also call jump_label_init() early in setup_arch() so that later
kasan_init() can enable static key kasan_flag_enabled. Put
jump_label_init() beofre parse_early_param() as other architectures
do.

Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org
---
arch/arm/kernel/setup.c | 6 ++++++
arch/arm/mm/kasan_init.c | 3 +++
2 files changed, 9 insertions(+)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 0bfd66c7ada0..453a47a4c715 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -1135,6 +1135,12 @@ void __init setup_arch(char **cmdline_p)
early_fixmap_init();
early_ioremap_init();

+ /*
+ * Initialise the static keys early as they may be enabled by the
+ * kasan_init() or early parameters.
+ */
+ jump_label_init();
+
parse_early_param();

#ifdef CONFIG_MMU
diff --git a/arch/arm/mm/kasan_init.c b/arch/arm/mm/kasan_init.c
index c6625e808bf8..82ec043c891f 100644
--- a/arch/arm/mm/kasan_init.c
+++ b/arch/arm/mm/kasan_init.c
@@ -212,6 +212,9 @@ void __init kasan_init(void)
phys_addr_t pa_start, pa_end;
u64 i;

+ /* If KASAN is disabled via command line, don't initialize it. */
+ if (kasan_arg_disabled)
+ return;
/*
* We are going to perform proper setup of shadow memory.
*