Skip to content

Commit 950b879

Browse files
guoren83palmer-dabbelt
authored andcommitted
riscv: Fixup race condition on PG_dcache_clean in flush_icache_pte
In commit 588a513 ("arm64: Fix race condition on PG_dcache_clean in __sync_icache_dcache()"), we found RISC-V has the same issue as the previous arm64. The previous implementation didn't guarantee the correct sequence of operations, which means flush_icache_all() hasn't been called when the PG_dcache_clean was set. That would cause a risk of page synchronization. Fixes: 08f051e ("RISC-V: Flush I$ when making a dirty page executable") Signed-off-by: Guo Ren <[email protected]> Signed-off-by: Guo Ren <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent eb74232 commit 950b879

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/riscv/mm/cacheflush.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ void flush_icache_pte(pte_t pte)
9090
if (PageHuge(page))
9191
page = compound_head(page);
9292

93-
if (!test_and_set_bit(PG_dcache_clean, &page->flags))
93+
if (!test_bit(PG_dcache_clean, &page->flags)) {
9494
flush_icache_all();
95+
set_bit(PG_dcache_clean, &page->flags);
96+
}
9597
}
9698
#endif /* CONFIG_MMU */
9799

0 commit comments

Comments
 (0)