]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: mm: Extract helper mark_new_valid_map()
authorVivian Wang <wangruikang@iscas.ac.cn>
Tue, 3 Mar 2026 05:29:45 +0000 (13:29 +0800)
committerPaul Walmsley <pjw@kernel.org>
Sun, 7 Jun 2026 05:48:15 +0000 (23:48 -0600)
In preparation of a future patch using the same mechanism for
non-vmalloc addresses, extract the mark_new_valid_map() helper from
flush_cache_vmap().

No functional change intended.

Cc: stable@vger.kernel.org
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Link: https://patch.msgid.link/20260303-handle-kfence-protect-spurious-fault-v2-1-f80d8354d79d@iscas.ac.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/include/asm/cacheflush.h

index 0092513c3376c56e1211f0f9514d90d1bf436bde..b1a2ac665792630f4f8f2c1edbb6a47461822b6d 100644 (file)
@@ -43,20 +43,23 @@ do {                                                        \
 #ifdef CONFIG_64BIT
 extern u64 new_vmalloc[NR_CPUS / sizeof(u64) + 1];
 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_vmalloc); ++i)
+               new_vmalloc[i] = -1ULL;
+}
 #define flush_cache_vmap flush_cache_vmap
 static inline void flush_cache_vmap(unsigned long start, unsigned long end)
 {
-       if (is_vmalloc_or_module_addr((void *)start)) {
-               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_vmalloc); ++i)
-                       new_vmalloc[i] = -1ULL;
-       }
+       if (is_vmalloc_or_module_addr((void *)start))
+               mark_new_valid_map();
 }
 #define flush_cache_vmap_early(start, end)     local_flush_tlb_kernel_range(start, end)
 #endif