decoder: enforce fixed-zero fields for HLV/HSV and CBO - #3563
Open
124107157-KV wants to merge 1 commit into
Open
124107157-KV wants to merge 1 commit into
124107157-KV wants to merge 1 commit into
Conversation
Signed-off-by: 124107157-KV <124107157@umail.ucc.ie>
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.
Why is this PR needed?
The decoder currently accepts several reserved encodings where the ISA encoding requires particular instruction fields to be zero.
For the hypervisor load/store instructions, some unsupported
rs2values can pass through decode without settingillegal_instr, and the HSV encodings do not enforce the fixed-zerordfield.Similarly, CBO.INVAL, CBO.CLEAN, and CBO.FLUSH do not currently enforce their fixed-zero
rdfield.As a result, malformed encodings can proceed through the pipeline instead of raising an illegal-instruction exception.
What does this PR change?
This PR adds explicit decoder legality checks for the affected fixed fields.
For the HLV/HLVX instruction families:
rs2 = 0orrs2 = 1.rs2 = 0,1, or3.rs2 = 0,1, or3.rs2 = 0.rs2encoding in these instruction families is marked illegal.For HSV:
rdfield to be zero.rdis marked illegal.For the cache-block operations:
rdfield to be zero.rdis marked illegal before the CBO operation is selected.Verification
Two directed assembly regressions were added:
decoder-hlv-hsv-fixed-fields-rv64decoder-cbo-rd-zero-rv64The HLV/HLVX/HSV regression uses raw instruction encodings covering:
rs2rs2rs2rs2rdEach malformed encoding is expected to raise an illegal-instruction exception with
mcause = 2.The CBO regression checks CBO.INVAL, CBO.CLEAN, and CBO.FLUSH with non-zero
rd, with each encoding expected to raisemcause = 2.The regressions were also added to
verif/regress/issue-tests.sh.HLV/HLVX/HSV
Target:
cv64a6_imafdch_sv39Original decoder:
RED_H=1Patched decoder:
GREEN_H=0CBO.INVAL/CLEAN/FLUSH
Target:
cv64a6_imafdc_sv39_hpdcacheOriginal decoder:
RED_CBO=1Patched decoder:
GREEN_CBO=0Both directed tests also compile successfully with the RISC-V GCC toolchain, and the expected malformed raw instruction encodings were verified in the generated ELF files.
Limitations
This change only adds the missing decoder legality checks for the fixed fields reported in the issue. It does not change the execution semantics of any valid HLV, HLVX, HSV, or CBO instruction encoding.
Fixes #3463