[PATCH -fixes] riscv: Re-introduce global icache flush in patch_text_XXX()
Alexandre Ghiti
alexghiti at rivosinc.com
Tue Jul 30 06:59:21 PDT 2024
commit edf2d546bfd6 ("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: edf2d546bfd6 ("riscv: patch: Flush the icache right after patching to avoid illegal insns")
Reported-by: Samuel Holland <samuel.holland at sifive.com>
Closes: https://lore.kernel.org/linux-riscv/CAHVXubh8Adb4=-vN4cSh0FrZ16TeOKJbLj4AF09QC241bRk1Jg@mail.gmail.com/T/#m800757c26f72a1d45c240cb815650430166c82ea
Signed-off-by: Alexandre Ghiti <alexghiti at rivosinc.com>
---
arch/riscv/kernel/patch.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
index ab03732d06c4..91edfd764ed9 100644
--- a/arch/riscv/kernel/patch.c
+++ b/arch/riscv/kernel/patch.c
@@ -205,6 +205,9 @@ int patch_text_set_nosync(void *addr, u8 c, size_t len)
ret = patch_insn_set(tp, c, len);
+ if (!ret)
+ flush_icache_range((uintptr_t)tp, (uintptr_t)tp + len);
+
return ret;
}
NOKPROBE_SYMBOL(patch_text_set_nosync);
@@ -237,6 +240,9 @@ int patch_text_nosync(void *addr, const void *insns, size_t len)
ret = patch_insn_write(tp, insns, len);
+ if (!ret)
+ flush_icache_range((uintptr_t) tp, (uintptr_t) tp + len);
+
return ret;
}
NOKPROBE_SYMBOL(patch_text_nosync);
--
2.39.2
More information about the linux-riscv
mailing list