Open ha0lyu opened 2 weeks ago
Here is the picture shows that instr
0x310d1413
is decodedaes64ks1i s0,s10,784
by Xiangshan & NEMU, spike decoded it asaes64ks1i s0, s10, 0
. Spike is right.
Thank you for your issue.
This is indeed a bug in NEMU. When decoding the aes64ks1i
instruction, NEMU incorrectly selects the high 12 bits of the instruction as the immediate value, rather than the 4 bits specified in the manual.
For example, for the instruction 0x310d1413
, the decoded immediate value is 0x310, which corresponds to 784 in NEMU.
Additionally, NEMU does not check the immediate value range for aes64ks1i
:
Note that rnum
must be in the range 0x0..0xA. The values 0xB..0xF are reserved.
I will fix this bug and then check if a similar issue exists in XiangShan.
I will fix this bug and then check if a similar issue exists in XiangShan.
I believe that this PR can fix this bug in NEMU.
However, additionally, based on my tests, it seems that XiangShan does not check the value of rnum
, and it does not report an exception for the instruction aes64ks1i s1, t6, 15.
Thanks for your confirmation and PR.
Could you tell me how do you run emu
to check whether xiangshan check the value of rnum
or other registers?
Could you tell me how do you run
emu
to check whether xiangshan check the value ofrnum
or other registers?
I performed differential testing again with the fixed versions of NEMU and XiangShan. For the aes64ks1i s1, t6, 15
instruction, I found that XiangShan did not raise an illegal instruction exception.
Additionally, this PR should have fixed the issue.
Thanks for your reply and PR.
Thanks for your reply and PR.
It seems that there are indeed some issues with our implementation of the Cryptography extension. We welcome and look forward to you finding other bugs in the Cryptography extension.
I will test it later after this bug fixed.
Thank you.
I will test it later after this bug fixed.
I will also double-check before merging this PR to ensure that no checks related to the Cryptography extension have been missed.
Before start
Describe the bug
Here is the picture shows that instr
0x310d1413
is decodedaes64ks1i s0,s10,784
by Xiangshan & NEMU, spike decoded it asaes64ks1i s0, s10, 0
. Spike is right.However, the commit instr trace shows
0x310d1413
is decoded correctly, but: Xiangshan & NEMU decode0x317e9f13
asaes64ks1i t5, t4, 7
, this is wrong. Spike still right:core 0: 0x000000008000017c (0x31ff9493) aes64ks1i s1, t6, 15
. Spike is right because of a piece of asm code:I am not sure the inside of Xiangshan & NEMU whether decode correctly, if they are right, I got this:
Expected behavior
Instruction trace show correct instructions.
s1
is right.To Reproduce
test.zip
Environment
Additional context
No response