[PATCH v5 0/2] riscv: fix text patching on minimal kernel configs

Xiaofeng Yuan posted 2 patches 1 month, 2 weeks ago
arch/riscv/kernel/patch.c | 2 ++
arch/riscv/mm/init.c      | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
[PATCH v5 0/2] riscv: fix text patching on minimal kernel configs
Posted by Xiaofeng Yuan 1 month, 2 weeks ago
This series fixes two related issues that break kprobes and kernel text
patching on RISC-V configurations where CONFIG_STRICT_MODULE_RWX is not
available (e.g. CONFIG_MODULES=n).

Patch 1 makes the EXECMEM_KPROBES range writable when
CONFIG_STRICT_MODULE_RWX is disabled, so kprobe instruction slot writes
do not fault on read-only executable pages.

Patch 2 makes patch_map() skip the temporary fixmap mapping when the
kernel text is already writable, i.e. when CONFIG_STRICT_KERNEL_RWX is
disabled. The module text path is still gated on CONFIG_STRICT_MODULE_RWX.

Changes since v4:
- 2/2: gate the kernel text fixmap on CONFIG_STRICT_KERNEL_RWX instead of
  returning early on !CONFIG_STRICT_MODULE_RWX. The v4 early return broke
  configs with CONFIG_MODULES=n, where CONFIG_STRICT_MODULE_RWX is
  unavailable but CONFIG_STRICT_KERNEL_RWX is still enabled and the kernel
  text is read-only, causing a boot-time kernel panic on BPI-F3 and RZ/Five
  (reported by Klara Modin and Lad Prabhakar).

Xiaofeng Yuan (2):
  riscv: mm: make EXECMEM_KPROBES writable without
    CONFIG_STRICT_MODULE_RWX
  riscv: patch: skip fixmap mapping when kernel text is already writable

 arch/riscv/kernel/patch.c | 2 ++
 arch/riscv/mm/init.c      | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.43.0
Re: [PATCH v5 0/2] riscv: fix text patching on minimal kernel configs
Posted by Paul Walmsley 1 month, 2 weeks ago
On Fri, 14 Aug 2026, Xiaofeng Yuan wrote:

> This series fixes two related issues that break kprobes and kernel text
> patching on RISC-V configurations where CONFIG_STRICT_MODULE_RWX is not
> available (e.g. CONFIG_MODULES=n).
> 
> Patch 1 makes the EXECMEM_KPROBES range writable when
> CONFIG_STRICT_MODULE_RWX is disabled, so kprobe instruction slot writes
> do not fault on read-only executable pages.
> 
> Patch 2 makes patch_map() skip the temporary fixmap mapping when the
> kernel text is already writable, i.e. when CONFIG_STRICT_KERNEL_RWX is
> disabled. The module text path is still gated on CONFIG_STRICT_MODULE_RWX.

Thanks, queued for v7.3-rc.


- Paul