Skip to content

fix(riscv): reject reserved CBO funct7 encodings - #262

Closed
carlosqwqqwq wants to merge 1 commit into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-cbo-funct7-full
Closed

fix(riscv): reject reserved CBO funct7 encodings#262
carlosqwqqwq wants to merge 1 commit into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-cbo-funct7-full

Conversation

@carlosqwqqwq

Copy link
Copy Markdown
Contributor

Closes #257

Summary

The Zicbom / Zicboz instructions are encoded with a full 7-bit funct7 field of 0b0000000. The affected decoder only checked the top five bits of funct7 ((w >> 27) & 0x1f == 0), so any encoding whose funct7[1:0] is nonzero — a reserved encoding that must raise an illegal-instruction exception — was still decoded as cbo.inval / cbo.clean / cbo.flush / cbo.zero. QEMU raises SIGILL for the same encoding (0x0605200f) because its decoder matches the full 7-bit funct7 pattern.

The fix checks the full 7-bit funct7 in the CBO decode path.

Validation

  • cargo test --lib: the targeted CBO decode tests pass, 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.

CBO encodings with nonzero funct7 low bits are executed

2 participants