You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have generated random code with unaligned instructions enabled. During code execution, an unaligned jump causes an illegal compressed instruction to be executed. The opcode of the illegal instruction is 0x401a, it consists of c.lwsp with a target register rd=0, which is illegal according to the specification (RD must be different from zero)
The execution of this instruction causes a trap_illegal_instruction on the spike side, but the DUT continues to execute the instruction because the target register is not checked for non-zero, and tries to load at address x80000000 + 132 = 0x80000084, causing a trap_load_page_fault.
To fix this, we added checking the target register to see if it is different from zero
wave
Here are the output signals after the correction, we can clearly see that the instruction is considered illegal.
The signals and logs after the correction also show that the tval of the trap in the spike is 0x0000401A and in the DUT is 0x8931401A because the mask is not applied as you mentioned (TODO)
//TODO don't forget to mask INSTRUCTION_DECOMPRESSED upper bits if RVC for traps mtval
//TODO trap on illegal RVC
According to the riscv-compressed-spec, there are several compressed instructions that require a check that the RS and RD registers are different from zero, and these registers are not checked in the DUT, so there are other checks to be done for other instructions.
The text was updated successfully, but these errors were encountered:
Hi,
I have generated random code with unaligned instructions enabled. During code execution, an unaligned jump causes an illegal compressed instruction to be executed. The opcode of the illegal instruction is
0x401a
, it consists ofc.lwsp
with a target registerrd=0
, which is illegal according to the specification (RD must be different from zero)The execution of this instruction causes a
trap_illegal_instruction
on the spike side, but the DUT continues to execute the instruction because the target register is not checked for non-zero, and tries to load at addressx80000000 + 132 = 0x80000084
, causing atrap_load_page_fault
.Here is the execution result
Dump
Spike log
Tracer log
To fix this, we added checking the target register to see if it is different from zero
wave
Here are the output signals after the correction, we can clearly see that the instruction is considered illegal.
The signals and logs after the correction also show that the
tval
of the trap in the spike is0x0000401A
and in the DUT is0x8931401A
because the mask is not applied as you mentioned (TODO)NaxRiscv/src/main/scala/naxriscv/frontend/DecompressorPlugin.scala
Lines 51 to 52 in bc18f66
According to the riscv-compressed-spec, there are several compressed instructions that require a check that the RS and RD registers are different from zero, and these registers are not checked in the DUT, so there are other checks to be done for other instructions.
The text was updated successfully, but these errors were encountered: