riscv: propagate register-class decode failure in custom decoders - #3071
Open
jmestwa-coder wants to merge 1 commit into
Open
riscv: propagate register-class decode failure in custom decoders#3071jmestwa-coder wants to merge 1 commit into
jmestwa-coder wants to merge 1 commit into
Conversation
The hand-written decoders ignored the status of Decode*RegisterClass, so an out-of-range register (RVE mode, and the COREV/XTHead paths) left the operand uncreated while the instruction still decoded as success. The printer then read the missing operand, dereferencing a NULL register name in release builds. Check the status and fail the decode, matching the generated table decoders.
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.
Your checklist for this pull request
Detailed description
Several hand-written RISC-V decoders drop the status of
Decode*RegisterClass:decodeRegReg,decodeRVCInstrRdRs2,decodeRVCInstrRdRs1Rs2,decodeXTHeadMemPairanddecodeRVCInstrRdRs1ImmZerocall it and ignore the return>= 16is rejected (also reachable through the COREV and XThead paths), so the operand is never created but the decoder still returns successprintRegRegpasses a NULL register name toSStream_concat0, which is a NULL deref in release builds;printOperandreads a slot of unknown kind for the compressed and XThead formsCheck()Return
MCDisassembler_Failwhen the register-class decode fails, at each site.Test plan
cstool -d riscv32+e+corev 2b330a2a(COREVcv.sh) faults on a NULL register name before the fix; after it, the word is rejectedtest_riscv_rve_unchecked_reg_decodetotests/integration/test_poc.c, one input per fixed decoder, run under the ASAN/UBSan jobtests/issues/fuzzing.yamlctest --test-dir buildis greenClosing issues