Files
ack-tegra/include/linux
Sabyrzhan Tasbolatov 1e338f4d99 kasan: introduce ARCH_DEFER_KASAN and unify static key across modes
Patch series "kasan: unify kasan_enabled() and remove arch-specific
implementations", v6.

This patch series addresses the fragmentation in KASAN initialization
across architectures by introducing a unified approach that eliminates
duplicate static keys and arch-specific kasan_arch_is_ready()
implementations.

The core issue is that different architectures have inconsistent approaches
to KASAN readiness tracking:
- PowerPC, LoongArch, and UML arch, each implement own kasan_arch_is_ready()
- Only HW_TAGS mode had a unified static key (kasan_flag_enabled)
- Generic and SW_TAGS modes relied on arch-specific solutions
  or always-on behavior


This patch (of 2):

Introduce CONFIG_ARCH_DEFER_KASAN to identify architectures [1] that need
to defer KASAN initialization until shadow memory is properly set up, and
unify the static key infrastructure across all KASAN modes.

[1] PowerPC, UML, LoongArch selects ARCH_DEFER_KASAN.

The core issue is that different architectures haveinconsistent approaches
to KASAN readiness tracking:
- PowerPC, LoongArch, and UML arch, each implement own
  kasan_arch_is_ready()
- Only HW_TAGS mode had a unified static key (kasan_flag_enabled)
- Generic and SW_TAGS modes relied on arch-specific solutions or always-on
    behavior

This patch addresses the fragmentation in KASAN initialization across
architectures by introducing a unified approach that eliminates duplicate
static keys and arch-specific kasan_arch_is_ready() implementations.

Let's replace kasan_arch_is_ready() with existing kasan_enabled() check,
which examines the static key being enabled if arch selects
ARCH_DEFER_KASAN or has HW_TAGS mode support.  For other arch,
kasan_enabled() checks the enablement during compile time.

Now KASAN users can use a single kasan_enabled() check everywhere.

Link: https://lkml.kernel.org/r/20250810125746.1105476-1-snovitoll@gmail.com
Link: https://lkml.kernel.org/r/20250810125746.1105476-2-snovitoll@gmail.com
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217049
Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> #powerpc
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: David Gow <davidgow@google.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Huacai Chen <chenhuacai@loongson.cn>
Cc: Marco Elver <elver@google.com>
Cc: Qing Zhang <zhangqing@loongson.cn>
Cc: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-09-21 14:21:58 -07:00
..
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-23 01:38:56 -04:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-21 18:18:51 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-31 11:28:03 -04:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-31 18:23:53 -07:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-07 12:24:50 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-06-27 16:38:02 -07:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-22 15:57:02 +00:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-16 14:28:21 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-19 18:59:51 -07:00
…
…
…
…
…
…
…
…
…
…
2025-07-24 19:12:32 -07:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-08-02 12:06:10 -07:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-02 17:18:01 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-17 06:01:16 -06:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-09-13 16:55:20 -07:00
2025-09-13 16:55:10 -07:00
…
…
2025-09-13 16:54:50 -07:00
…
…
…
…
…
2025-09-13 16:55:07 -07:00
2025-09-13 16:55:07 -07:00
2025-09-13 16:55:07 -07:00
2025-07-09 22:41:56 -07:00
2025-09-13 16:55:20 -07:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-14 15:20:02 -07:00
…
2025-07-14 15:20:02 -07:00
…
…
…
2025-07-08 19:11:57 -04:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-09-13 16:55:07 -07:00
2025-09-13 16:55:20 -07:00
…
…
…
…
…
…
…
…
…
2025-07-31 16:11:43 -05:00
…
…
…
2025-09-13 16:55:07 -07:00
…
2025-07-09 19:32:30 -07:00
…
2025-06-19 14:28:24 +02:00
2025-06-19 14:28:24 +02:00
…
…
…
…
…
…
2025-07-22 18:07:11 +02:00
…
…
…
…
…
2025-07-01 12:29:29 +02:00
…
…
…
…
2025-07-10 09:39:18 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-19 10:17:56 +05:30
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-23 11:56:02 +02:00
…
…
…
…
…
…
2025-07-21 17:48:32 -07:00
…
…
…
…
…
…
…
…
…
…
…
2025-06-25 15:12:17 -07:00
…
…
…
…
…
…
…
…
…
…
2025-06-26 09:44:45 -07:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-07-17 11:26:56 +02:00
…
…
2025-09-13 16:55:14 -07:00
…
…
…
2025-08-02 12:01:37 -07:00
…
…
…
…
…
…
…
…
…