New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
c.jr/c.jalr semantic wrong #981
Comments
Hi @Ye-Jinhong, can you elaborate the issue more? (i.e., what was the unexpected output for c.jal/c.jalr?) |
Hi @hnpl , it is specified that
And in "C" extension,
So the result of In decoder.isa, line 450 to 456
and line 468 to 471
The NPC is not correct due to not masking the bit 0 like I came across this when I build my own o3 cpu model, when the rs1 is not even in wrong path, fetch unit will fetch from the unaligned Addr. Although this will not cause error as a squash following, but it is a sematic wrong against RISC-V unpriviledge spec. Affects version Expected behavior |
I see. If I'm not mistaken, that's a bug. Interestingly, gem5 O3CPU does jump to the correct location due to branch prediction mechanism [1]. This is because c_jr's and c_jalr's branchTarget() function do generate the correct address, and if Rc1 is not 2-byte aligned, it is a branch misprediction (and if the branch predictor learned this, there'll be no misprediction later on). I'm not sure about the c_jr and c_jalr in other gem5 cpu types given that they call the instructions's execute() function directly to get the new PC.
[1] Lines 717 to 723 in ffd0680
@powerjg, @aarmejach: please correct if I'm wrong, my memory is rather vague on O3CPU branch prediction. |
@Ye-Jinhong can you make a PR that fixes this? |
The bit 0 of register should be 0 for jump address. Wrong handling the jump address may cause infinite run or segment fault. gem5 issue: #981
Describe the bug
As RISC-V unpriviledge isa spec says,
c.jr/c.jalr
expands tojalr x0/x1 0(rs1)
. Sincejalr
should force the bit 0 to zero, I thinkc.jr/c.jalr
should act the same way.The text was updated successfully, but these errors were encountered: