Skip to content

fix(riscv): enforce execution, CSR, and SMIR constraints - #231

Merged
19h merged 8 commits into
fix/riscv-vector-issues-192-196from
agent/riscv-smir-validation-rollup
Aug 12, 2026
Merged

fix(riscv): enforce execution, CSR, and SMIR constraints#231
19h merged 8 commits into
fix/riscv-vector-issues-192-196from
agent/riscv-smir-validation-rollup

Conversation

@19h

@19h 19h commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

This independently reimplements, validates, and consolidates the RISC-V fixes proposed in #218, #220, #222, #224, #226, #228, #230, #233, #235, #237, #239, #241, and #244.

No contributor commits were cherry-picked or merged, and no contributor code was copied into this branch. The implementation was derived from the issue reproductions, the repository's current execution paths, and the RISC-V unprivileged/privileged architecture requirements. Carlos is credited as co-author on every rollup commit.

Fixes #217
Fixes #219
Fixes #221
Fixes #223
Fixes #225
Fixes #227
Fixes #229
Fixes #232
Fixes #234
Fixes #236
Fixes #238
Fixes #240
Fixes #243

Changes

  • enforce IALIGN=32 for SMIR JAL, branch, and dynamic JALR when C is disabled; reject reserved JALR funct3 values
  • gate FENCE.I, CSR, floating-point CSR, and vector CSR lifting on the required ISA extensions
  • preserve loads to x0 as observable, faulting memory operations in optimized and native execution
  • apply architectural WARL/projection rules to mepc, misa, and mtvec
  • reject unavailable CSR families, including RV32-only high counters on RV64 and extension-owned FP/vector/JVT CSRs
  • count only normally completed instructions in instret; ECALL, EBREAK, and synchronous traps do not retire
  • require D for compressed double-precision memory operations while preserving Zcmp/Zcmt overlay decoding
  • fail closed before native execution for predecoded illegal compressed instructions
  • validate failed SC.W/SC.D store ranges on direct and native paths, clear reservations at the correct point, and use a non-mutating backend probe so permission checks do not cause MMIO reads
  • correct Zcmp rlist=5 to {ra,s0} in compressed decode sizing, direct execution, disassembly, and SMIR/JIT while preserving the three-register rlist=6 behavior
  • split RISC-V control flow, CSR handling, and execution accounting out of oversized source modules

Validation

Each regression probe reproduced the reported defect against the pre-fix baseline before passing with the independent implementation.

  • fresh GitHub matrix on the final head: all 24 checks passed, including four host core-test lanes, the full cross-build matrix, formatting/Clippy, and both microkernel runs
  • exhaustive final-tree library gate: 8,267 passed, 0 failed, 0 ignored
  • direct plus production O0/O2 JIT regression coverage for control flow, load-to-x0, CSR traps, retirement, illegal native admission, SC.W/SC.D faults, and Zcmp register-list semantics
  • RISC-V module slice: 155 passed
  • exhaustive SMIR lift/oracle target: 13 passed
  • native x86-64 RISC-V SMIR/JIT target: 36 passed
  • live QEMU RISC-V scalar differential target: 30 passed, 0 skipped
  • independent Zcmp oracle check: LLVM decodes 0xb852 as cm.push {ra, s0}, -16 and 0xb856 as cm.push {ra, s0}, -32, matching the current RISC-V Zcmp register-list and stack-adjustment tables
  • cargo fmt --all --check
  • cargo clippy --all-targets --features x86_64-suite
  • cargo build --all-targets --no-default-features --features x86_64-suite,smir-jit

Integration note

This PR is intentionally stacked on #203 so it inherits the already reviewed and green CI/cross/microkernel repairs there. After #203 merges, this PR should be retargeted to master.

#203 independently covers the earlier contributor series #197, #198, #199, #200, #201, #202, #206, #208, #210, #212, #214, and #216. No commits from those PRs are included here either.

@carlosqwqqwq, thank you for reporting these architecture gaps. Please review this consolidation, especially the conservative no-C JALR fallback, extension/CSR profile combinations, compressed overlay handling, native illegal-instruction frontier, failed-SC exception ordering/probe behavior, and the Zcmp rlist=5/rlist=6 boundary and RV32/RV64 stack adjustments.

@19h 19h changed the title fix(riscv): enforce SMIR architectural constraints fix(riscv): enforce SMIR and machine CSR constraints Aug 11, 2026
@19h
19h changed the base branch from master to fix/riscv-vector-issues-192-196 August 11, 2026 20:06
19h and others added 2 commits August 11, 2026 22:09
Independently validate and consolidate the RISC-V SMIR control-flow, extension-profile, reserved-encoding, and load-to-x0 fixes.

Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
Independently validate and consolidate IALIGN-sensitive mepc behavior, MISA H/V projection, and reserved mtvec MODE canonicalization.

Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
@19h
19h force-pushed the agent/riscv-smir-validation-rollup branch from c12b32e to 77ebbc7 Compare August 11, 2026 20:11
19h and others added 5 commits August 11, 2026 22:46
Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
Independently validate and consolidate the architectural register list, stack adjustment, direct execution, disassembly, and SMIR expansion behavior.

Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>

19h commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

@carlosqwqqwq — the independent consolidation is complete at 3f57107d and all 24 GitHub checks are green.

#231 now covers #218, #220, #222, #224, #226, #228, #230, #233, #235, #237, #239, #241, and #244, with the corresponding issues linked for closure on merge. No commits or code were taken from those PRs; the fixes were independently reproduced, reimplemented, and validated, and every rollup commit credits you through the GitHub co-author trailer.

The latest addition corrects Zcmp rlist=5 across decode sizing, direct execution, disassembly, and SMIR/JIT, with rlist=6 boundary coverage and independent specification/LLVM oracle checks. Please review the consolidated implementation, especially the architectural fallback frontiers, extension/CSR gates, failed-SC ordering, and Zcmp RV32/RV64 stack-adjustment behavior.

@19h
19h merged commit 44e7037 into master Aug 12, 2026
24 checks passed
@19h

19h commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

The next independently implemented validation batch is now consolidated in #255, covering #245#249 and superseding #250#254. This keeps the follow-up chain from #203/#231 explicit and retains Carlos as co-author.

@19h
19h deleted the agent/riscv-smir-validation-rollup branch August 13, 2026 00:52

19h commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

Follow-up validation and independently reimplemented RISC-V fixes now continue in #296. It consolidates the newly reported vector-memory, operand-validation, SRET, and WFI gaps, carries contributor credit, and is ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment