Open dariuszst opened 3 years ago
Note that x3
is an alias for gp
, so what you're doing is writing the address of write_tohost
into tohost
. tohost
can only be written with a certain set of values. If you're trying to exit with success, you should write 1 to tohost. If you're trying to exit with failure, write an odd-numbered value other than 1.
OK, it seems that there is a bug in the SV riscv-dv generator that generates assembly code in which the GP register content is destroyed by overwriting it by using x3 register for jump purposes.
However the output generated by spike still looks like unexpected application error and this behavior should be probably corrected.
It is meant to be a fatal error, but the message could certainly be less terse.
The problem occurs for the assembly code generated by riscv-dv generator. The code generated y riscv-dv is assembled with gcc toolchain compiler:
riscv64-unknown-elf-gcc -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles riscv_jump_stress_test_1.S -I./../riscv-dv/user_extension -T./../riscv-dv/scripts/link.ld -o riscv_jump_stress_test_1.o -march=rv32i -mabi=ilp32
and then simulate with a comannd:
spike --log-commits --isa=rv32i -l riscv_jump_stress_test_1.o &> riscv_jump_stress_test.1.log
There is an example of a program (and log file) for the rv32i target in the attached zip file (riscv_jump_stress_test.zip). It seems that write_tohost: procedure called in the ecall_handler: routine:
makes the spike stuck in a forever loop that ends with an internal error: