Files
Zhongyi Cheng c9a7d00992 platform: generic/starfive: deny S-mode access to the JH7110 firmware alias
The JH7110 DDR controller folds physical addresses beyond the 8GB DDR
window back into DRAM: PA (X + 0x200000000) resolves to the same cells
as PA X. PMP entries match the presented address, so an aliased S-mode
access to the firmware region bypasses the entry protecting the
firmware and matches the allow-everything root region, letting root
read and write the firmware through the alias.

Add a root domain memory region covering the alias of the firmware
image (fw_start + 0x200000000 .. fw_start + fw_size) with M-mode-only
permissions, in platform early_init() so that it is in place before
sbi_domain_finalize(). The region sorts before the allow-everything
region, so it gets a lower PMP entry index and denies S/U-mode access
to the firmware alias. The rest of the alias window is left untouched.

This follows the same approach as the RZ/Five ILM/DLM protection.

Verified on QEMU riscv64 (root region list and PMP encodings) and on a
VisionFive 2 board: S/U-mode accesses to both the alias (0x240000000)
and the firmware region (0x40000000) fault as expected after this
patch, while normal boot is unaffected.

Reported-by: Zhongyi Cheng <zhongyicheng241@mails.ucas.ac.cn>
Signed-off-by: Zhongyi Cheng <zhongyicheng241@mails.ucas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260928032414.4125686-1-zhongyicheng241@mails.ucas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-11-02 13:02:06 +05:30
..