riscv-openocd icon indicating copy to clipboard operation
riscv-openocd copied to clipboard

Stop assuming dmi.address is not changed in `riscv_decode_dmi_scan()`

Open en-sc opened this issue 10 months ago • 0 comments

Related to #1025.

When a DMI read result is decoded, the current code assumes that the hardware provides the read address in the dmi.address field when returning the dmi.data.

That is however not required by the spec, and therefore not guaranteed.

Spike ISA simulator behaves like that but other RISC-V debug implementations may not.

e.g.

Debug: 409 19 riscv-013.c:420 dump_field(): 50b r 00000000 @10 -> + 00000000 @10; 3i
Debug: 419 20 riscv-013.c:420 dump_field(): 50b - 00000000 @10 -> + 04010001 @10; 3i
Debug: 420 20 riscv-013.c:434 dump_field(): read: dmcontrol=0x4010001 {...}

Here the decoding on the 3-rd line is based on the dmi.address field OpenOCD got in the result of the nop opreation on the 2-nd line.

en-sc avatar Apr 17 '24 09:04 en-sc