riscv: reject reserved shamt[5] bit of C.SLLI/C.SRLI/C.SRAI on RV32 - #287
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: reject reserved shamt[5] bit of C.SLLI/C.SRLI/C.SRAI on RV32
Problem
decode_c_shamt()ignores bit 12 for RV32, and the three compressed-shiftdecoders (
c.slli,c.srli,c.srai) never check it, so 1536 reserved RV32encodings (bit 12 == 1, i.e.
shamt[5]) are executed as valid shifts insteadof raising an illegal-instruction exception.
Change
Add an RV32-only check at the top of each shift decoder that raises an
illegal-instruction trap when bit 12 is set:
RV64 behavior is unchanged (bit 12 is the valid
shamt[5]).Verification
0x9101/0x9105) now trap on both the JIT and interpreter paths, matching QEMU.
c.slli/c.srli/c.srai(including therd == x0hints)and
c.andistill execute correctly.Fixes #285.