Skip to content

Commit ee9a683

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Re-introduce global icache flush in patch_text_XXX()
commit edf2d54 ("riscv: patch: Flush the icache right after patching to avoid illegal insns") mistakenly removed the global icache flush in patch_text_nosync() and patch_text_set_nosync() functions, so reintroduce them. Fixes: edf2d54 ("riscv: patch: Flush the icache right after patching to avoid illegal insns") Reported-by: Samuel Holland <[email protected]> Closes: https://lore.kernel.org/linux-riscv/[email protected]/ Signed-off-by: Alexandre Ghiti <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Reviewed-by: Charlie Jenkins <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent de9c2c6 commit ee9a683

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/riscv/kernel/patch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ int patch_text_set_nosync(void *addr, u8 c, size_t len)
205205
int ret;
206206

207207
ret = patch_insn_set(addr, c, len);
208+
if (!ret)
209+
flush_icache_range((uintptr_t)addr, (uintptr_t)addr + len);
208210

209211
return ret;
210212
}
@@ -239,6 +241,8 @@ int patch_text_nosync(void *addr, const void *insns, size_t len)
239241
int ret;
240242

241243
ret = patch_insn_write(addr, insns, len);
244+
if (!ret)
245+
flush_icache_range((uintptr_t)addr, (uintptr_t)addr + len);
242246

243247
return ret;
244248
}

0 commit comments

Comments
 (0)