]> git.ipfire.org Git - thirdparty/linux.git/commit
riscv: mm: Use mmu-type from FDT to limit SATP mode
authorJunhui Liu <junhui.liu@pigmoral.tech>
Mon, 21 Jul 2025 16:53:11 +0000 (00:53 +0800)
committerPaul Walmsley <pjw@kernel.org>
Thu, 18 Sep 2025 14:18:14 +0000 (08:18 -0600)
commit17e9521044c9b3ee839f861d1ac35c5b5c20d16b
treec2584e6122c77c858bdb4d92e5a6a4a790f50eef
parentf3243bed39c26ce0f13e6392a634f91d409b2d02
riscv: mm: Use mmu-type from FDT to limit SATP mode

Some RISC-V implementations may hang when attempting to write an
unsupported SATP mode, even though the latest RISC-V specification
states such writes should have no effect. To avoid this issue, the
logic for selecting SATP mode has been refined:

The kernel now determines the SATP mode limit by taking the minimum of
the value specified by the kernel command line (noXlvl) and the
"mmu-type" property in the device tree (FDT). If only one is specified,
use that.
- If the resulting limit is sv48 or higher, the kernel will probe SATP
  modes from this limit downward until a supported mode is found.
- If the limit is sv39, the kernel will directly use sv39 without
  probing.

This ensures SATP mode selection is safe and compatible with both
hardware and user configuration, minimizing the risk of hangs.

Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com>
Link: https://lore.kernel.org/r/20250722-satp-from-fdt-v1-2-5ba22218fa5f@pigmoral.tech
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/kernel/pi/fdt_early.c
arch/riscv/kernel/pi/pi.h
arch/riscv/mm/init.c