Repository navigation
Description
Environment Setup
Stock XLEN=32 configuration, F enabled, C disabled, IALIGN=32. Tested at commit b447578d9f3bb116d658c614cf3407153f0536da. Driver: rtlsim built DEBUG=1; the tests are bare-metal ELFs.
Three tests, each jumping/branching to a target whose bit 1 is set: dut_jal.elf / ref_jal.elf, dut_jalr_auipc.elf / ref_jalr_auipc.elf, dut_branch.elf / ref_branch.elf. The prebuilt ELFs are attached.
# rtlsim built DEBUG=1 from the commit above (XLEN=32, F on, C off).
# Binary used for these measurements:
# sha256 7781afec22ac961b5151f336f91592e17a9da160b2517526c9b27f21342c83d7
P=jal # or: jalr_auipc, branch
spike -l --log-commits --isa=rv32imaf -m128 prebuilt/ref_$P.elf
./rtlsim prebuilt/dut_$P.elfAll three tests ran. Results: spike_rc=1 (the reference ELF's local misaligned handler exits 1), dut_rc=65 / 54 / 99 respectively (DUT exit markers, not crashes).
Expected behavior
With IALIGN=32, a control transfer to a target whose bit 1 is set must raise an instruction-address-misaligned exception (cause 0). Per the RISC-V Privileged Specification, machine.adoc (mepc register / IALIGN text) and the mcause definition: on implementations supporting only IALIGN=32, the two low bits of an instruction address are always zero, and a taken branch/JAL/JALR to a misaligned target raises cause 0.
Observed results
jal test, jump at PC 0x80000010 (j pc + 0x6 → target 0x80000016):
| Engine | Result |
|---|---|
| Vortex | commits the jump and continues at 0x80000016, no trap |
| Spike | exception trap_instruction_address_misaligned, epc 0x80000010, tval 0x80000016 |
DUT (logs/jal_dut.dbg.log):
301: ...-commit commit: ... PC=0x80000010, ex=ALU, wb=0, rd=0, ... data={0x80000014, ...} (#4)
335: ...-commit commit: ... PC=0x80000016, ex=ALU, wb=1, rd=10, ... data={0x41, ...} (#5) <--
Spike (logs/jal_ref.commits):
core 0: 0x80000010 (0x0060006f) j pc + 0x6
core 0: exception trap_instruction_address_misaligned, epc 0x80000010 <--
core 0: tval 0x80000016
The same pattern holds for the other two tests:
| test | Spike trap | DUT next committed PC |
|---|---|---|
jalr_auipc |
exception trap_instruction_address_misaligned, epc 0x8000001c, tval 0x80000036 |
0x80000036 (the misaligned target itself), no trap |
branch |
exception trap_instruction_address_misaligned, epc 0x80000014, tval 0x8000001e |
0x8000001e, no trap |
jalr_auipc DUT log (commit of the control transfer at 0x8000001c, then the next commit):
355: ...-commit commit: ... PC=0x8000001c, ex=ALU, wb=0, rd=0, ... data={0x80000020, ...} (#7)
(the data word 0x80000020 is the JALR's link value in rd=x0, not the next PC)
fetch req: PC=0x80000036 ... instr=0x517 (#8)
... next commit at PC=0x80000036, op=AUIPC, wb=1, rd=10 ... data={0x41, ...} <--
branch DUT log:
321: ...-commit commit: ... PC=0x80000014, ex=ALU, wb=0, rd=63, ... data={0x2, ...} (#5)
355: ...-commit commit: ... PC=0x8000001e, ex=ALU, wb=1, rd=10, ... data={0x63, ...} (#6)
In all three tests the DUT fetches and commits the instruction at the misaligned target address (PC bit 1 set), so no exception is ever raised on the control transfer.
Affected revision and environment
- Tested at commit
b447578d9f3bb116d658c614cf3407153f0536da VERSION:VORTEX_VERSION=3.0,TOOLCHAIN_REV=v3.0.1- DUT simulator:
rtlsimDEBUG=1, sha2567781afec22ac961b5151f336f91592e17a9da160b2517526c9b27f21342c83d7 - Reference: Spike
--isa=rv32imaf -m128 - OS: Linux 6.8.0-90-generic x86_64.
Minimal RTL reproducer
The DUT log excerpts are from logs/jal_dut.dbg.log, logs/branch_dut.dbg.log and logs/jalr_auipc_dut.dbg.log in the attachment.
Attachment: testcase.zip contains the three dut_*.elf / ref_*.elf pairs (under prebuilt/), their .S sources, link.ld, probe_macros.h, and the full DUT and Spike logs for all three tests (logs/*_dut.dbg.log, logs/*_ref.commits). The command block above is the one that produced these results.
The leading comments in the .S files were shortened after the runs; the assembled .text is unchanged — reassembling the attached .S reproduces the .text of the attached ELFs byte for byte.
The exit-code scheme of the tests is documented in the .S headers (1 = trap taken, other markers = no-trap paths).
Activity
tinebp commentedon Nov 19, 2026
Fixed by #487.