fix(riscv): reject obsolete sfence.vm encoding - #265
Closed
carlosqwqqwq wants to merge 1 commit into
Closed
Conversation
carlosqwqqwq
force-pushed
the
fix-riscv-sfence-vm-obsolete
branch
from
August 13, 2026 05:08
31fa98d to
21cfb6c
Compare
Member
|
Thanks for the report and patch. I independently reproduced and validated this issue, then reimplemented the accepted behavior with shared direct/SMIR validation and expanded tests in #296. That rollup includes your co-author credit and asks for your review. I’m closing this PR as superseded by #296 so the fixes can be reviewed and merged as one coherent change. |
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.
Closes #260
Summary
The obsolete
sfence.vmencoding0x10400073was still decoded asOp::SfenceVmby the system-opcode table insrc/isa/riscv/decode.rs. RISC-V marked this encoding obsolete (riscv-isa-manual 20240411, "SFENCE.VM Instruction"); the current privileged ISA redefines it assctrclrof the Ssctr/Smctr extension, so a plainsfence.vmmust raise an illegal-instruction exception. QEMU traps the encoding with SIGILL.The fix removes the
0x08 if rs2(w) == 0x04 => base(Op::SfenceVm, w)branch so the encoding falls through toInsn::illegal, deletes the now-unusedOp::SfenceVmvariant and its disassembler case, and updates the existing decode test that assertedOp::SfenceVm.Validation
cargo test --lib: the updated decode test (decode_privileged_fence_and_hypervisor_tables) passes, and the full library test suite passes with no regressions.No new upstream test files are added; this is a source-only change.