diff options
| author | Michael Brown | 2025-06-12 13:26:11 +0200 |
|---|---|---|
| committer | Michael Brown | 2025-06-12 13:33:46 +0200 |
| commit | 41e65df19d4dc3a5f5621ce0e9d74f270d4efb3f (patch) | |
| tree | d682eab2ae18f9edbf02bad2cbe8c193b52f1ec3 /src/arch/riscv/include | |
| parent | [fdt] Allow paths and aliases to be terminated with separator characters (diff) | |
| download | ipxe-41e65df19d4dc3a5f5621ce0e9d74f270d4efb3f.tar.gz ipxe-41e65df19d4dc3a5f5621ce0e9d74f270d4efb3f.tar.xz ipxe-41e65df19d4dc3a5f5621ce0e9d74f270d4efb3f.zip | |
[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>
Diffstat (limited to 'src/arch/riscv/include')
| -rw-r--r-- | src/arch/riscv/include/ipxe/riscv_io.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/arch/riscv/include/ipxe/riscv_io.h b/src/arch/riscv/include/ipxe/riscv_io.h index 8f9030418..be4449ff1 100644 --- a/src/arch/riscv/include/ipxe/riscv_io.h +++ b/src/arch/riscv/include/ipxe/riscv_io.h @@ -128,7 +128,7 @@ RISCV_WRITEX ( w, uint16_t, "h" ); */ static inline __always_inline void IOAPI_INLINE ( riscv, mb ) ( void ) { - __asm__ __volatile__ ( "fence rw, rw" ); + __asm__ __volatile__ ( "fence" : : : "memory" ); } /* Dummy PIO */ |
