fix(riscv): enforce RVV reserved encoding constraints - #203
Conversation
|
@carlosqwqqwq — PR #203 is now ready for review and all CI checks are green. It consolidates the RVV fixes from #197, #198, #199, #200, and #201 into shared pre-execution validation, adds direct/SMIR-JIT/QEMU differential coverage, and includes the CI repairs for no-JIT builds, ARMv6 microkernel linking, and experimental cross-target reporting. Could you review the combined architectural constraints, especially register-group overlap and reserved |
|
@carlosqwqqwq — I reviewed the additional PRs #206, #208, and #210 and incorporated their underlying fixes into #203 alongside #197, #198, #199, #200, and #201. The widening implementation here also covers the missing fractional-EMUL, destructive MAC/FMA, The updated branch is green locally across 8,229 library tests (2 ignored), the full RISC-V lift/JIT/QEMU integration binaries, both portable all-targets feature builds, formatting, and Clippy. Could you review the consolidated behavior and the corrected differences from #206/#208/#210? |
Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
0ad9d18 to
66e798d
Compare
Implement the four legal FP16-to-integer8 vfncvt forms while keeping FP8-producing encodings reserved. Cover exact saturation, rounding, flags, SMIR/JIT parity, and QEMU differential behavior. Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
carlosqwqqwq
left a comment
There was a problem hiding this comment.
Confirmed the consolidated validation in vector_validation.rs against RVV 1.0 (§5.2 register-group overlap, §11 reserved encodings, §7 vstart, §8 SEW=8 FP) and QEMU 8.2.2 differential witnesses: frm=5/6/7 rejection for OPFVV/OPFVF, vmsbf/vmsif/vmsof vd==vs2 and masked vd==v0, vadc/vsbc vd==v0, vslideup group overlap, narrowing fractional-EMUL and lowest-register overlap, widening vv/vx/vf/.w forms, vzext/vsext source scaling, and reduction source-group alignment all match the spec and our local fixed builds.
Independent gaps outside #203 that remain on master (f508a8d, unchanged): vid.v non-zero vs2 (#213/#214), vmv.v.v reserved vs2, VLM/VSM and whole-register load/store vstart handling, vsetvl vstart clearing, reduction non-zero vstart, same-width vadd group alignment, vill exception path, and faulting-element vstart publication. Our D/S series (CSR/counters/misa/Zcmp and SMIR/JIT gating) are non-RVV and disjoint.
One semantic note on #206/#208: our patches allowed MAC/FMA high-part overlap while #203 rejects any vs2 overlap for destructive forms, which matches RVV §5.2. We treat the stricter #203 behavior as authoritative.
Validate the VMUNARY0 source field before execution, preserving transactional trap behavior across the direct, SMIR, and native helper paths. Add masked and unmasked QEMU controls. Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
Decode FP load/store, OP-FP, FMA, and vector instructions with the lifter's configured extension set. Exercise F-enabled/D-disabled paths at every FP helper plus V-disabled and enabled controls. Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
|
@carlosqwqqwq — thank you for the detailed approval and for confirming that the stricter destructive MAC/FMA overlap rule is authoritative. Since that review, I incorporated corrected, co-authored versions of #212, #214, and #216; #203 now covers #197, #198, #199, #200, #201, #206, #208, #210, #212, #214, and #216, while #202 remains separate. I also added #204 to the closing references and recorded the remaining RVV gaps from your review as explicit follow-up scope. Could you review the three incremental commits, particularly the exact |
|
@carlosqwqqwq — one scope update to my previous review request: #202 is now also closed as superseded by #203. The rollup keeps the structural change focused on centralized validation and the touched mixed-width conversion module rather than taking the broader mechanical split separately. The PR description now reflects that decision. |
Close the remaining RVV validation, vill, configuration, and precise vector-memory restart gaps identified during rollup review. Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
|
@carlosqwqqwq — I addressed all seven remaining RVV gaps from your approval in commit
The commit carries your Could you review the incremental commit, particularly the memory restart frontier and whole-register |
|
@carlosqwqqwq — final validation update for |
|
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. |
@carlosqwqqwq — this rollup consolidates the architectural fixes from #197, #198, #199, #200, #201, #202, #206, #208, #210, #212, #214, and #216. The broader module split in #202 is superseded by the focused validation and vector configuration/memory extraction in this rollup and was closed in favor of #203. Could you review the incremental #212/#214/#216 integrations and approval follow-up commit
9bf48ace, especially FP16-to-integer8 flags, precise RVV restart state, and decoder-profile gating?Overview
This PR centralizes RVV architectural-constraint checking before any instruction can mutate guest state, completes the restart behavior identified during review, and corrects the related SMIR decode profile boundary:
vmsbf.m,vmsif.m, andvmsof.mrestart and destination-overlap constraints.v0destination for every decodedvadc/vsbcform.vslideup,vslide1up, andvfslide1up, while retaining legal downward-slide overlap.frm=5/6/7for every decoded OPFVV/OPFVF encoding, including exact and fixed-rounding operations whenvl=0orvstart>=vl..w, conversion, extension, and reduction forms. Destructive MAC/FMA operands reject every overlap, as required when one source register would be read at two EEWs.vfncvtforms at SEW=8, including exact RNE/RTZ behavior, signed and unsigned saturation, NaN/infinity handling, and accrued NV/NX flags. FP8-producing variants remain reserved.vs2field ofvid.vto encodev0in masked and unmasked forms.rv64gcprofile.vs2=v0field forvmv.v.v/vmv.v.x/vmv.v.i; validate same-width integer vector groups; reject reductions with nonzerovstart; resetvstartafter successfulvsetvli/vsetivli/vsetvl; and implement precisevstartunits, fault publication,villhandling, and restart semantics for mask and whole-register memory transfers.The rational group model also validates
vzext/vsextsource EMUL forvf2/vf4/vf8. Widening reductions retain the scalarvd/vs1exemption while still validating the vector source group.Execution-plane behavior
The pre-execution validator is shared by the direct interpreter and the opaque SMIR/JIT RVV helper. Invalid arithmetic encodings trap before architectural state or memory is committed; legal overlap, fractional-LMUL, reduction-scalar, mixed conversion, and reserved-field controls remain accepted.
RVV memory restart state is now modeled at the architectural frontier. VLM/VSM use byte-indexed
vstart; whole-register transfers use encoded-EEW element indices and remain legal withvill; all vector memory paths publish the exact faulting element; and the opaque SMIR interpreter commits partial vector state plusvstarton a memory trap. Native vector-memory lowering remains fail-closed, while native OP-V execution inherits the centralized validator and configuration behavior.The touched oversized CPU implementation is split into focused
vector_configandvector_memorymodules. No new SMIR IR operation, optimizer contract, public Rust API, C ABI, backend adapter, or machine/device model is introduced. The SMIR profile fix reuses the existingdecoder_isa()projection at every affected helper. The QEMU vector oracle applies inputvstartaftervsetvl, so restartability probes are not silently reset before execution.Validation
cargo fmt --all --checkcargo build --all-targets --no-default-features --features x86_64-suite,smir-jitcargo build --all-targets --no-default-features --features x86_64-suitecargo clippy --all-targets --features x86_64-suitecargo test --no-default-features --features x86_64-suite,smir-jit --lib -- --include-ignored --test-threads=1: 8,249/8,249 passed, with zero ignored or filtered.vstartmemory traps.vstartunits,vill, and faulting-element publication.CI stability
The earlier CI repair commit in this rollup also:
__aeabi_uread4helper required by the current nightly, with all four address residues tested during bare-metal boot;Review notes and completed follow-up
Carlos independently confirmed the centralized overlap and reserved-encoding behavior, including the stricter destructive MAC/FMA rule, against RVV 1.0 and QEMU/native probes. The acknowledgements on #206, #208, and #210 do not request further rollup changes. The edited #204 report is fully covered by the shared slide-up group validator.
The newly opened #217/#218, #219/#220, #221/#222, and #223/#224 pairs cover separate, non-RVV SMIR control-flow, system-extension, and scalar-memory gaps. They were reviewed independently and are intentionally not consolidated here; each currently needs to be rebased off the closed #202 split and have its duplicated test attribute removed before merge. #222 also needs independent Zicsr/F/V gate controls, and #224 needs end-to-end optimized/native fault and side-effect coverage for its otherwise unused load result.
Commit
9bf48aceimplements all seven remaining RVV gaps identified in the approval:vmvreserved fields, mask/whole-register memoryvstart,vsetvlreset behavior, nonrestartable reductions, same-width group alignment, the whole-registervillexception, and precise faulting-element publication. It carries Carlos's co-author trailer.Fixes #192
Fixes #193
Fixes #194
Fixes #195
Fixes #196
Fixes #204
Fixes #205
Fixes #207
Fixes #209
Fixes #211
Fixes #213
Fixes #215