]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: mm: Use the bitmap API for new_valid_map_cpus
authorVivian Wang <wangruikang@iscas.ac.cn>
Tue, 3 Mar 2026 05:29:48 +0000 (13:29 +0800)
committerPaul Walmsley <pjw@kernel.org>
Sun, 7 Jun 2026 05:48:15 +0000 (23:48 -0600)
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 <wangruikang@iscas.ac.cn>
Link: https://patch.msgid.link/20260303-handle-kfence-protect-spurious-fault-v2-4-f80d8354d79d@iscas.ac.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/include/asm/cacheflush.h
arch/riscv/mm/init.c

index 8c7a0ef2635adf112bfe4192222cd3790704f9e6..8cfe59483a8f28c29b35e54fa2584e6bfb58760f 100644 (file)
@@ -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)
index bede6845f767215118acc6ed08b4c2c2b2d2f84b..ea8766c4f3a23c1558b42bf4480d9dce85c9119c 100644 (file)
@@ -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);