kronos
kronos copied to clipboard
Bug report: Reading existent CSRs cause the CPU to hang in some microarchitectural conditions
Hi there!
In complement to #7 , I noticed that reading existing CSRs also causes the CPU to hang.
This happens only if the destination register is distinct from zero.
For example, in the snippet below, zero is never written to address zero.
.section ".text.init","ax",@progbits
.globl _start
.align 2
_start:
csrrw x1, mtvec, zero
nop
sw zero, (zero)
infinite_loop0:
j infinite_loop0
This does not happen in all cases, for example this snippet is fine, probably because the CSR register write signal is (legitimately) overwritten with 0 just after the first register write occurred.
.section ".text.init","ax",@progbits
.globl _start
.align 2
_start:
csrrw x1, mtvec, zero
csrw medeleg, zero
nop
sw zero, (zero)
infinite_loop0:
j infinite_loop0
It is possible that the bug only has symptoms when #6 is implemented (I haven't double checked that, since #6 or any such alternative is necessary for RISC-V compliance).
Thanks!