Skip to contentSkip to conversation

riscv: Use flush_icache_mm for flush_icache_user_range

PATCH Superseded Guo Ren 2 participants 2 messages Jan 24, 2020 – Jan 30, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Guo Ren

author
#0 lore raw

PATCH 1/1 riscv: Use flush_icache_mm for flush_icache_user_range

The only call path is:

__access_remote_vm -> copy_to_user_page -> flush_icache_user_range

Seems it's ok to use flush_icache_mm instead of flush_icache_all and it could reduce flush_icache_all called on other harts.

I think the patch is the fixup for the commit 08f051eda33b.

Cc Andrew Waterman <[email protected]>
Cc Palmer Dabbelt <[email protected]>
---
 arch/riscv/include/asm/cacheflush.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/include/asm/cacheflush.h +1 -1
index b69aecbb36d3..26589623fd57 100644
@@ -85,7 +85,7 @@ static inline void flush_dcache_page(struct page *page)
  * so instead we just flush the whole thing.
  */
 #define flush_icache_range(start, end) flush_icache_all()
-#define flush_icache_user_range(vma, pg, addr, len) flush_icache_all()
+#define flush_icache_user_range(vma, pg, addr, len) flush_icache_mm(vma->vm_mm, 0)
 
 void dma_wbinv_range(unsigned long start, unsigned long end);
 void dma_wb_range(unsigned long start, unsigned long end);
Signature · 1 line
2.17.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · On Fri, 24 Jan 2020 16:18:10 GMT (+0000), [email protected] wrote:

The only call path is:

__access_remote_vm -> copy_to_user_page -> flush_icache_user_range

Seems it's ok to use flush_icache_mm instead of flush_icache_all and it could reduce flush_icache_all called on other harts.

I think the patch is the fixup for the commit 08f051eda33b.

Cc Andrew Waterman <[email protected]>
Cc Palmer Dabbelt <[email protected]>
---
 arch/riscv/include/asm/cacheflush.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/include/asm/cacheflush.h +0 -0
index b69aecbb36d3..26589623fd57 100644

arch/riscv/include/asm/cacheflush.h static inline void flush_dcache_page(struct page *page) · line 91

Quoted 8 lines
arch/riscv/include/asm/cacheflush.h +1 -1
@@ -85,7 +85,7 @@ static inline void flush_dcache_page(struct page *page)
  * so instead we just flush the whole thing.
  */
 #define flush_icache_range(start, end) flush_icache_all()
-#define flush_icache_user_range(vma, pg, addr, len) flush_icache_all()
+#define flush_icache_user_range(vma, pg, addr, len) flush_icache_mm(vma->vm_mm, 0)
 
 void dma_wbinv_range(unsigned long start, unsigned long end);
 void dma_wb_range(unsigned long start, unsigned long end);

I've added this to for-next with some minor modifications as 4d99abce8ce80e866020ffa5b2bd790269235f37. It missed the PR I'm sending now-ish, but I'll include it as part of the next one even if it's during an early RC.

Thanks!