linux/arch/riscv
Alexandre Ghiti 6ca445d8af
riscv: Fix early ftrace nop patching
Commit c97bf62996 ("riscv: Fix text patching when IPI are used")
converted ftrace_make_nop() to use patch_insn_write() which does not
emit any icache flush relying entirely on __ftrace_modify_code() to do
that.

But we missed that ftrace_make_nop() was called very early directly when
converting mcount calls into nops (actually on riscv it converts 2B nops
emitted by the compiler into 4B nops).

This caused crashes on multiple HW as reported by Conor and Björn since
the booting core could have half-patched instructions in its icache
which would trigger an illegal instruction trap: fix this by emitting a
local flush icache when early patching nops.

Fixes: c97bf62996 ("riscv: Fix text patching when IPI are used")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reported-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
Tested-by: Björn Töpel <bjorn@rivosinc.com>
Link: https://lore.kernel.org/r/20240523115134.70380-1-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2024-05-23 08:22:17 -07:00
..
boot riscv: make image compression configurable 2024-05-22 16:12:44 -07:00
configs RISC-V Patches for the 6.10 Merge Window, Part 1 2024-05-22 09:56:00 -07:00
crypto crypto: riscv - add vector crypto accelerated AES-CBC-CTS 2024-03-20 08:56:11 -07:00
errata RISC-V Patches for the 6.10 Merge Window, Part 1 2024-05-22 09:56:00 -07:00
include riscv: Fix early ftrace nop patching 2024-05-23 08:22:17 -07:00
kernel riscv: Fix early ftrace nop patching 2024-05-23 08:22:17 -07:00
kvm Kbuild updates for v6.10 2024-05-18 12:39:20 -07:00
lib riscv: uaccess: Relax the threshold for fast path 2024-05-22 16:12:55 -07:00
mm riscv: mm: accelerate pagefault when badaccess 2024-05-22 16:12:56 -07:00
net Modules changes for v6.10-rc1 2024-05-15 14:05:08 -07:00
purgatory Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
tools riscv: Check relocations at compile time 2023-04-19 07:46:32 -07:00
Kbuild RISC-V: hook new crypto subdir into build-system 2024-01-22 17:55:17 -08:00
Kconfig ftrace: riscv: move from REGS to ARGS 2024-05-22 16:12:48 -07:00
Kconfig.debug riscv: Add tests for riscv module loading 2023-11-07 14:59:32 -08:00
Kconfig.errata riscv: thead: Rename T-Head PBMT to MAE 2024-04-25 10:22:33 -07:00
Kconfig.socs RISC-V: drop SOC_VIRT for ARCH_VIRT 2024-04-10 11:37:50 +01:00
Makefile riscv: show help string for riscv-specific targets 2024-05-22 16:12:45 -07:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00