fix(riscv): validate vector, scalar, and privileged semantics - #296
Conversation
carlosqwqqwq
left a comment
There was a problem hiding this comment.
Reviewed the consolidated rollup against the reported issues. All accepted behaviors are implemented through the shared pre-execution validator (direct interpreter and SMIR/JIT helper paths), and the regression tests cover the reported encodings:
- RV32 C.FLW/C.FSW F-extension gate, reserved CBO funct7, obsolete SFENCE.VM and URET handling;
- operand-group alignment for vmul/vdiv/vrem, vsaddu/vsadd/vssubu/vssub, vssrl/vssra, vslide1down/vfslide1down, vsmul, vmseq family, vid.v, segment and non-segment vector memory ops;
- masked-destination v0 rule, vmadc/vmsbc mask-result overlap, viota.m overlap disposition, whole-register moves honoring vstart, segment fault-only-first execution semantics, SRET supervisor restore, and WFI local-wake semantics.
I also verified locally on the current head (75e7172): cargo test --lib evex_fma3_register_replay (8/8), evex_integer_unary_memory_source (12/12), evex_packed_extend_memory_source (13/13), and evex_packed_fp_unary_memory_source (21/21) all pass, including the native replay cases that previously raised SIGILL on the hosted linux-x64 lane. CI on the replacement hosted run is green across all platforms.
Thanks for the co-author credit and for consolidating these fixes.
75e7172 to
87852fb
Compare
|
@carlosqwqqwq, the CI repair is complete on |
Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
c08010f to
b53add4
Compare
Validate CSR privilege, counter-enable, WARL, and SD behavior; enforce fetch IALIGN; and implement the missing RV32 Zfa and HLVX.WU forms across direct and SMIR/JIT paths. Co-authored-by: carlos <102978772+carlosqwqqwq@users.noreply.github.com>
|
@carlosqwqqwq, I have pushed commit 9027ae1 and expanded this rollup to cover #297, #298, #299, #301, #307, #309, #310, and #311. The corresponding implementation PRs #302, #303, #304, #306, #312, #314, #315, and #316 are now closed as consolidated here. I also independently checked #300/#305 and #308/#313 and documented in the PR description why those two proposals contradict the current specifications. Please review the updated direct, CSR, SMIR/JIT, and differential coverage when convenient. |
@carlosqwqqwq, this is the next independently implemented consolidation after #203, #231, and #255. Thank you for continuing to identify RISC-V gaps. Please review the consolidated behavior and tests here.
Overview
This change independently reproduces the reported failures against the current ISA contracts and implements the accepted fixes without importing contributor commits or copying their patches:
vltrimming;vstartin SEW elements and preserve overlapping sources;mstatus,mip,medeleg, andmidelegWARL fields and derive the read-onlymstatus.SDaggregate;mcounteren, addscounteren, and enforce lower-privilege counter access gates;fmvh.x.d/fmvp.d.xand admitHLVX.WUon RV32 across decode, direct execution, disassembly, and SMIR/JIT;Scope reconciliation
The x86 native-replay and AVX-512 repairs that temporarily accompanied this branch independently landed on
masterine0f2daf6. This PR was rebased onto that master and contains only the RISC-V consolidation in commitsb53add43and9027ae1f.Consolidated reports
This supersedes #261, #262, #263, #264, #265, #272, #273, #274, #275, #282, #283, #284, #285, #291, #292, #293, #294, #295, #302, #303, #304, #306, #312, #314, #315, and #316.
#271 is already covered by merged #255. #281 was withdrawn after its reduction-overlap report proved to be a false positive, so it is intentionally excluded.
For #294, SRET is incorporated, while URET is rejected because the current privileged architecture no longer defines the former N-extension instruction. For #295, the valid WFI wake condition is incorporated, while the proposed unconditional trap is not: wake eligibility and interrupt trap eligibility are separate architectural decisions.
#300/#305 and #308/#313 were independently falsified and closed rather than incorporated:
sip/sieare restricted views ofmip/mie; when SSIP is not delegated throughmideleg, the supervisor-visible bit is read-only zero. Making it writable regardless of delegation would violate the privileged architecture.Issues
Fixes #256
Fixes #257
Fixes #258
Fixes #259
Fixes #260
Fixes #267
Fixes #268
Fixes #269
Fixes #270
Fixes #277
Fixes #278
Fixes #279
Fixes #280
Fixes #286
Fixes #287
Fixes #288
Fixes #289
Fixes #290
Fixes #297
Fixes #298
Fixes #299
Fixes #301
Fixes #307
Fixes #309
Fixes #310
Fixes #311
#266 is a duplicate of behavior already fixed by #255. #276 was withdrawn with #281. #300 and #308 were closed as invalid after the specification checks above.
Validation
Final local tree:
cargo fmt --all --checkcargo clippy --all-targets --features x86_64-suitecargo clippy --lib --no-default-features --features x86_64-suite,smir-jit -- -D warningscargo build --all-targets --no-default-features --features x86_64-suite,smir-jitHosted checks for head
9027ae1f328eb81e705c2e42a11d8d61e41ce216are available on the PR checks page and will be reflected here after completion.Change-surface audit
HLVX.WU.scounterenstate; derives SD on reads; rejected forms and traps remain transactional. No public ABI layout changes.HLVX.WUuses the existing hypervisor-load memory contract.HLVX.WUuses the existing load representation.OpKindis required.Assumption Register
vltrimming.vl; first-element faults remain precise.vstart.Privrepresentation agree.mcounterenandscounteren; S-mode requiresmcounteren.HLVX.WUdecode legality can use the repository's existing flat-memory H-load execution model.Out-of-scope findings
hypervisor_virtual_load_store_use_flat_memorycontract and shared HLV/HLVX execution arms.Co-authored-by: carlos 102978772+carlosqwqqwq@users.noreply.github.com