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 <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@kernel.org> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230127035306.1819561-1-guoren@kernel.org Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent eb74232 commit 950b879

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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)