riscv-non-isa/riscv-arch-test

ecall check fails in CLIC mode

Opened this issue · 5 comments

This issue is only seen when using CLIC mode trap handling

https://github.com/riscv-non-isa/riscv-arch-test/blob/main/riscv-test-suite/env/arch_test.h#L1160

This code is supposed to check for ecall, and exit early when it is detected. However the way the code is doing this does not work correctly when mcause contains extra bits like in the case when CLIC is used. Typically bits 29:28 will contain 0b11 so mcause will somtimes have the value 0x3000000B when read by the handler and the code will not detect that this is actually an ecall with exception code = 0xB.

This issue has also been discussed in the following PR: #436 (comment)

Yes there might be other bits that are set, so in the case when CLIC is used we have to only look at bits 11:0 to inspect the exception/interrupt code. Here is a picture of the changes done to xcause for CLIC mode.

bilde

It looks like the arch_test.h file already contains a mask to extract the exception cause bits, however this is not used when checking for an ecall.

exception mask: https://github.com/riscv-non-isa/riscv-arch-test/blob/main/riscv-test-suite/env/arch_test.h#L157