Skip to content

fix(riscv): reject obsolete sfence.vm encoding - #265

Closed
carlosqwqqwq wants to merge 1 commit into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-sfence-vm-obsolete
Closed

fix(riscv): reject obsolete sfence.vm encoding#265
carlosqwqqwq wants to merge 1 commit into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-sfence-vm-obsolete

Conversation

@carlosqwqqwq

Copy link
Copy Markdown
Contributor

Closes #260

Summary

The obsolete sfence.vm encoding 0x10400073 was still decoded as Op::SfenceVm by the system-opcode table in src/isa/riscv/decode.rs. RISC-V marked this encoding obsolete (riscv-isa-manual 20240411, "SFENCE.VM Instruction"); the current privileged ISA redefines it as sctrclr of the Ssctr/Smctr extension, so a plain sfence.vm must 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 to Insn::illegal, deletes the now-unused Op::SfenceVm variant and its disassembler case, and updates the existing decode test that asserted Op::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.

19h commented Aug 13, 2026

Copy link
Copy Markdown
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.

@19h 19h closed this Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the obsolete sfence.vm encoding 0x10400073 is accepted

2 participants