Skip to content

Commit d243b3c

Browse files
committed
riscv-rt: Align _vector_table to 256 instead of 4
The RISC-V Privileged Specification (version 1.11) for mtvec CSR says: > The value in the BASE field must always be aligned on a 4-byte boundary, and the MODE setting may > impose additional alignment constraints on the value in the BASE field. > [...] > An implementation may have different alignment constraints for different modes. In particular, > MODE=Vectored may have stricter alignment constraints than MODE=Direct. The Ibex Reference Guide for mtvec CSR says[^1]: > The trap-vector base address, always aligned to 256 bytes I'm not sure how we can parametrize mtvec alignment without cargo features, so this PR simply uses the stricter alignment. If a cargo feature is preferred, I can add `mtvec-align-256`. Note that multiple `mtvec-align-N` features are additive because the stricter one wins. [^1]: https://ibex-core.readthedocs.io/en/latest/03_reference/cs_registers.html#machine-trap-vector-base-address-mtvec
1 parent b391a48 commit d243b3c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

riscv-rt/src/interrupts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ core::arch::global_asm!(
8181
.type _vector_table, @function
8282
8383
.option push
84-
.balign 0x4 // TODO check if this is the correct alignment
84+
.balign 0x100 // RISC-V requires 4, but implementations may be stricter
8585
.option norelax
8686
.option norvc
8787

0 commit comments

Comments
 (0)