-
Notifications
You must be signed in to change notification settings - Fork 207
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
🐛 fix bug in instruction-misaligned exception handling #734
Conversation
…lter the link register
@stnolting so reading the spec there really isn't an "xRET" instruction, from what I can gather it seems its just short-hand for JAL. Because of this fixing JAL to handle mis-aligned targets should also fix "xRET". So we shouldn't need to tie xEPC[1] to 0. An additional "fun" detail with JALR is: Spec 2.2 chapter 2.5.1 unconditional branches. This explains this note for JAL/JALR, as the PC LSB is forced to be 0 disregarding its content. After thanksgiving I'll take a stab at the v1.9.1.4 release in a local branch and see if it passes our compliance check. Our checker is much more punishing than the riscv-arch test suite. |
to check for correct handling of misaligned instruction exception; C extension is still tested/verified in neorv32-riscof
Right, I was just referring to the "special"
Well, this is what I have found in the specs.: Priv. spec regarding
|
i.e. if the C ISA extension is disabled
More a note on the branch misalign fix added in v1.9.1.4. |
That sounds great! 🎉 |
Bug identified by @mikaelsky in #728 (comment).
The current processor version captures unaligned instruction addresses in the pipeline's front-end. Hence, any misaligned instruction will still trigger an instruction fetch and jump-and-link instruction will still update the link register. This PR aims to fix this:
I am not quite sure about the handling of
xRET
instructions whenxEPC
contains a misaligned address. The RISC-V priv. spec states:So I think
xEPC[1]
should be hardwired to zero if IALIGN=32 (i.e. theC
extension is NOT enabled). Hence,xRET
cannot raise a misaligned instruction exception. However, I cannot find anything regardingdret
/dpc
but I assume that we should expect the same behavior there. @mikaelsky can you confirm this?