From: Vivian Wang Date: Tue, 3 Mar 2026 05:29:48 +0000 (+0800) Subject: riscv: mm: Use the bitmap API for new_valid_map_cpus X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26c171fc48539ac88d3697792b1fde9334af836c;p=thirdparty%2Flinux.git riscv: mm: Use the bitmap API for new_valid_map_cpus The bitmap was defined with incorrect size. Fix it by using the proper bitmap API in C code. The corresponding assembly code is still okay and remains unchanged. Signed-off-by: Vivian Wang Link: https://patch.msgid.link/20260303-handle-kfence-protect-spurious-fault-v2-4-f80d8354d79d@iscas.ac.cn Signed-off-by: Paul Walmsley --- diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h index 8c7a0ef2635a..8cfe59483a8f 100644 --- a/arch/riscv/include/asm/cacheflush.h +++ b/arch/riscv/include/asm/cacheflush.h @@ -41,19 +41,17 @@ do { \ } while (0) #ifdef CONFIG_64BIT -extern u64 new_valid_map_cpus[NR_CPUS / sizeof(u64) + 1]; +/* This is accessed in assembly code. cpumask_var_t would be too complex. */ +extern DECLARE_BITMAP(new_valid_map_cpus, NR_CPUS); extern char _end[]; static inline void mark_new_valid_map(void) { - int i; - /* * We don't care if concurrently a cpu resets this value since * the only place this can happen is in handle_exception() where * an sfence.vma is emitted. */ - for (i = 0; i < ARRAY_SIZE(new_valid_map_cpus); ++i) - new_valid_map_cpus[i] = -1ULL; + bitmap_fill(new_valid_map_cpus, NR_CPUS); } #define flush_cache_vmap flush_cache_vmap static inline void flush_cache_vmap(unsigned long start, unsigned long end) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index bede6845f767..ea8766c4f3a2 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -37,7 +37,7 @@ #include "../kernel/head.h" -u64 new_valid_map_cpus[NR_CPUS / sizeof(u64) + 1]; +DECLARE_BITMAP(new_valid_map_cpus, NR_CPUS); struct kernel_mapping kernel_map __ro_after_init; EXPORT_SYMBOL(kernel_map);