]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[riscv] Zero SATP after any failed attempt to enable paging
authorMichael Brown <mcb30@ipxe.org>
Mon, 2 Jun 2025 07:08:02 +0000 (08:08 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 2 Jun 2025 07:09:15 +0000 (08:09 +0100)
commit88cffd75a9c2cc15780d465fe4e9ccf45719d6c9
tree244b964335499c1875f3aff87a095046aff6d6ed
parentbb2011241fcf15de4edd962fe9656e513ad19174
[riscv] Zero SATP after any failed attempt to enable paging

The RISC-V specification states that "if SATP is written with an
unsupported mode, the entire write has no effect; no fields in SATP
are modified".  We currently rely on this specified behaviour when
calculating the early UART base address: if SATP has a non-zero value
then we assume that paging must be enabled.

The XuanTie C910 CPU (as used in the Lichee Pi 4A) does not conform to
this specified behaviour.  Writing SATP with an unsupported mode will
leave SATP.MODE as zero (i.e. bare physical addressing) but the write
to SATP.PPN will still take effect, leaving SATP with an illegal
non-zero value.

Work around this misbehaviour by explicitly writing zero to SATP if we
detect that the mode change has not taken effect (e.g. because the CPU
does not support the requested paging mode).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/riscv/prefix/libprefix.S