mm: Introduce flush_cache_vmap_early()
authorAlexandre Ghiti <alexghiti@rivosinc.com>
Tue, 12 Dec 2023 21:34:56 +0000 (22:34 +0100)
committerDennis Zhou <dennis@kernel.org>
Thu, 14 Dec 2023 08:23:17 +0000 (00:23 -0800)
commit7a92fc8b4d20680e4c20289a670d8fca2d1f2c1b
treef02aada180e46f0f74910d88d85b96c0f181061e
parent33cc938e65a98f1d29d0a18403dbbee050dcad9a
mm: Introduce flush_cache_vmap_early()

The pcpu setup when using the page allocator sets up a new vmalloc
mapping very early in the boot process, so early that it cannot use the
flush_cache_vmap() function which may depend on structures not yet
initialized (for example in riscv, we currently send an IPI to flush
other cpus TLB).

But on some architectures, we must call flush_cache_vmap(): for example,
in riscv, some uarchs can cache invalid TLB entries so we need to flush
the new established mapping to avoid taking an exception.

So fix this by introducing a new function flush_cache_vmap_early() which
is called right after setting the new page table entry and before
accessing this new mapping. This new function implements a local flush
tlb on riscv and is no-op for other architectures (same as today).

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
17 files changed:
arch/arc/include/asm/cacheflush.h
arch/arm/include/asm/cacheflush.h
arch/csky/abiv1/inc/abi/cacheflush.h
arch/csky/abiv2/inc/abi/cacheflush.h
arch/m68k/include/asm/cacheflush_mm.h
arch/mips/include/asm/cacheflush.h
arch/nios2/include/asm/cacheflush.h
arch/parisc/include/asm/cacheflush.h
arch/riscv/include/asm/cacheflush.h
arch/riscv/include/asm/tlbflush.h
arch/riscv/mm/tlbflush.c
arch/sh/include/asm/cacheflush.h
arch/sparc/include/asm/cacheflush_32.h
arch/sparc/include/asm/cacheflush_64.h
arch/xtensa/include/asm/cacheflush.h
include/asm-generic/cacheflush.h
mm/percpu.c