]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[riscv] Maximise barrier effects of memory fences
authorMichael Brown <mcb30@ipxe.org>
Thu, 12 Jun 2025 11:26:11 +0000 (12:26 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 12 Jun 2025 11:33:46 +0000 (12:33 +0100)
commit41e65df19d4dc3a5f5621ce0e9d74f270d4efb3f
treed682eab2ae18f9edbf02bad2cbe8c193b52f1ec3
parent7e96e5f2ef074c6c17a75dad20beb2a61ecca2f8
[riscv] Maximise barrier effects of memory fences

The RISC-V "fence" instruction encoding includes bits for predecessor
and successor input and output operations, separate from read and
write operations.  It is up to the CPU implementation to decide what
counts as I/O space rather than memory space for the purposes of this
instruction.

Since we do not expect fencing to be performance-critical, keep
everything as simple and reliable as possible by using the unadorned
"fence" instruction (equivalent to "fence iorw, iorw").

Add a memory clobber to ensure that the compiler does not reorder the
barrier.  (The volatile qualifier seems to already prevent reordering
in practice, but this is not guaranteed according to the compiler
documentation.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/riscv/include/ipxe/riscv_io.h