All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] implement flush_cache_vmap and flush_cache_vunmap for RISC-V
@ 2021-03-29  1:55 ` Jiuyang Liu
  0 siblings, 0 replies; 12+ messages in thread
From: Jiuyang Liu @ 2021-03-29  1:55 UTC (permalink / raw)
  To: Alex Ghiti
  Cc: Jiuyang Liu, Andrew Waterman, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, Andrew Morton, Geert Uytterhoeven, linux-riscv,
	linux-kernel

This patch implements flush_cache_vmap and flush_cache_vunmap for
RISC-V, since these functions might modify PTE. Without this patch,
SFENCE.VMA won't be added to related codes, which might introduce a bug
in some out-of-order micro-architecture implementations.

Signed-off-by: Jiuyang Liu <liu@jiuyang.me>
---
 arch/riscv/include/asm/cacheflush.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h
index 23ff70350992..4adf25248c43 100644
--- a/arch/riscv/include/asm/cacheflush.h
+++ b/arch/riscv/include/asm/cacheflush.h
@@ -8,6 +8,14 @@
 
 #include <linux/mm.h>
 
+/*
+ * flush_cache_vmap and flush_cache_vunmap might modify PTE, needs SFENCE.VMA.
+ * - flush_cache_vmap is invoked after map_kernel_range() has installed the page table entries.
+ * - flush_cache_vunmap is invoked before unmap_kernel_range() deletes the page table entries
+ */
+#define flush_cache_vmap(start, end) flush_tlb_all()
+#define flush_cache_vunmap(start, end) flush_tlb_all()
+
 static inline void local_flush_icache_all(void)
 {
 	asm volatile ("fence.i" ::: "memory");
-- 
2.31.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-04-12  6:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-29  1:55 [PATCH] implement flush_cache_vmap and flush_cache_vunmap for RISC-V Jiuyang Liu
2021-03-29  1:55 ` Jiuyang Liu
2021-03-30  7:02 ` Alex Ghiti
2021-03-30  7:02   ` Alex Ghiti
2021-04-01  6:37 ` Christoph Hellwig
2021-04-01  6:37   ` Christoph Hellwig
2021-04-11 21:41 ` Palmer Dabbelt
2021-04-11 21:41   ` Palmer Dabbelt
2021-04-12  0:13   ` Jiuyang Liu
2021-04-12  0:13     ` Jiuyang Liu
2021-04-12  6:22   ` Jisheng Zhang
2021-04-12  6:22     ` Jisheng Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.