mirror-linux/arch/um/include/asm
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
..
fpu um: Include linux/types.h in asm/fpu/api.h 2025-05-07 16:45:40 +08:00
Kbuild loongarch, um, xtensa: get rid of generated arch/$ARCH/include/asm/param.h 2025-06-24 22:02:05 -04:00
archrandom.h random: handle archrandom with multiple longs 2022-07-25 13:26:14 +02:00
asm-prototypes.h um: Add cmpxchg8b_emu and checksum functions to asm-prototypes.h 2025-05-05 10:22:07 +02:00
bpf_perf_event.h um: don't generate asm/bpf_perf_event.h 2024-07-10 14:23:30 +02:00
cache.h
cacheflush.h
common.lds.S UML: add support for KASAN under x86_64 2022-07-17 23:35:22 +02:00
cpufeature.h um: Replace __ASSEMBLY__ with __ASSEMBLER__ in the usermode headers 2025-07-22 17:12:45 +02:00
current.h um: Replace __ASSEMBLY__ with __ASSEMBLER__ in the usermode headers 2025-07-22 17:12:45 +02:00
delay.h
dma.h
futex.h
hardirq.h
io.h
irq.h um: Track userspace children dying in SECCOMP mode 2025-06-02 15:17:19 +02:00
irqflags.h
kasan.h kasan: introduce ARCH_DEFER_KASAN and unify static key across modes 2025-09-21 14:21:58 -07:00
kvm_para.h
mmu.h um: Track userspace children dying in SECCOMP mode 2025-06-02 15:17:19 +02:00
mmu_context.h um: Stop tracking stub's PID via userspace_pid[] 2025-07-13 19:42:49 +02:00
msi.h
page.h um: Replace __ASSEMBLY__ with __ASSEMBLER__ in the usermode headers 2025-07-22 17:12:45 +02:00
pci.h PCI/MSI: Get rid of PCI_MSI_IRQ_DOMAIN 2022-11-17 15:15:19 +01:00
pgalloc.h mm: pgtable: convert some architectures to use tlb_remove_ptdesc() 2025-04-01 15:17:13 -07:00
pgtable-2level.h um: remove custom definition of mk_pte() 2025-05-11 17:48:03 -07:00
pgtable-4level.h um: remove custom definition of mk_pte() 2025-05-11 17:48:03 -07:00
pgtable.h mm: pgtable: fix pte_swp_exclusive 2025-06-11 14:52:08 -07:00
processor-generic.h um: mark rodata read-only and implement _nofault accesses 2025-03-18 11:03:14 +01:00
ptrace-generic.h um: Replace __ASSEMBLY__ with __ASSEMBLER__ in the usermode headers 2025-07-22 17:12:45 +02:00
sections.h
setup.h
smp.h
stacktrace.h
syscall-generic.h syscall.h: introduce syscall_set_nr() 2025-05-11 17:48:15 -07:00
thread_info.h um: Replace __ASSEMBLY__ with __ASSEMBLER__ in the usermode headers 2025-07-22 17:12:45 +02:00
timex.h um: use fallback for random_get_entropy() instead of zero 2022-05-13 23:59:23 +02:00
tlb.h
tlbflush.h um: Abandon the _PAGE_NEWPROT bit 2024-10-23 09:52:49 +02:00
uaccess.h um: fix _nofault accesses 2025-05-05 10:06:51 +02:00
unwind.h
vmalloc.h
vmlinux.lds.h
xor.h um: Remove straying parenthesis 2022-07-17 23:24:20 +02:00