From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: "Steven Rostedt" <rostedt@goodmis.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Björn Töpel" <bjorn@rivosinc.com>,
"Andy Chiu" <andy.chiu@sifive.com>,
"Puranjay Mohan" <puranjay12@gmail.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org,
"Conor Dooley" <conor.dooley@microchip.com>
Subject: Re: [PATCH -fixes] riscv: patch: Flush the icache right after patching to avoid illegal insns
Date: Tue, 9 Jul 2024 10:13:12 +0200 [thread overview]
Message-ID: <CAMuHMdUwx=rU2MWhFTE6KhYHm64phxx2Y6u05-aBLGfeG5696A@mail.gmail.com> (raw)
In-Reply-To: <20240624082141.153871-1-alexghiti@rivosinc.com>
Hi Alexandre,
On Mon, Jun 24, 2024 at 10:23 AM Alexandre Ghiti <alexghiti@rivosinc.com> wrote:
> We cannot delay the icache flush after patching some functions as we may
> have patched a function that will get called before the icache flush.
>
> The only way to completely avoid such scenario is by flushing the icache
> as soon as we patch a function. This will probably be costly as we don't
> batch the icache maintenance anymore.
>
> Fixes: 6ca445d8af0e ("riscv: Fix early ftrace nop patching")
> Reported-by: Conor Dooley <conor.dooley@microchip.com>
> Closes: https://lore.kernel.org/linux-riscv/20240613-lubricant-breath-061192a9489a@wendy/
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Thanks for your patch, which is now commit edf2d546bfd6f5c4 ("riscv:
patch: Flush the icache right after patching to avoid illegal
insns") in v6.10-rc6.
> --- a/arch/riscv/kernel/patch.c
> +++ b/arch/riscv/kernel/patch.c
> @@ -189,9 +205,6 @@ 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);
patch_text_set_nosync() is now identical to (static) patch_insn_set(),
and the latter has no other callers.
> @@ -224,9 +237,6 @@ 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);
patch_text_nosync() is now identical to patch_insn_write(), and both
functions are called from outside this file.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2024-07-09 8:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 8:21 [PATCH -fixes] riscv: patch: Flush the icache right after patching to avoid illegal insns Alexandre Ghiti
2024-06-24 11:49 ` Andy Chiu
2024-06-25 2:38 ` Andy Chiu
2024-06-26 12:59 ` Conor Dooley
2024-06-27 17:47 ` Palmer Dabbelt
2024-06-27 17:50 ` patchwork-bot+linux-riscv
2024-07-09 8:13 ` Geert Uytterhoeven [this message]
2024-07-15 8:12 ` Alexandre Ghiti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMuHMdUwx=rU2MWhFTE6KhYHm64phxx2Y6u05-aBLGfeG5696A@mail.gmail.com' \
--to=geert@linux-m68k.org \
--cc=alexghiti@rivosinc.com \
--cc=andy.chiu@sifive.com \
--cc=aou@eecs.berkeley.edu \
--cc=bjorn@rivosinc.com \
--cc=conor.dooley@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=puranjay12@gmail.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).