Skip to content

fix(riscv): gate FP instructions and CSRs on mstatus.FS - #322

Open
carlosqwqqwq wants to merge 10 commits into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-fs-gate
Open

fix(riscv): gate FP instructions and CSRs on mstatus.FS#322
carlosqwqqwq wants to merge 10 commits into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-fs-gate

Conversation

@carlosqwqqwq

@carlosqwqqwq carlosqwqqwq commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

RISC-V requires mstatus.FS=Off to make floating-point state inaccessible in every privilege mode. This change gates scalar/vector FP execution and fflags/frm/fcsr availability on FS != Off. The opt-in RISC-V JIT keeps FP state-sensitive instructions on the interpreter path because its native ABI does not carry privilege or mstatus.FS.

Validation

  • fp_instructions_and_csrs_trap_when_fs_is_off: scalar/vector FP and FP CSR accesses with FS=Off trap in U/M mode; FS=Initial permits execution, and successful scalar/vector FP plus guest FP CSR writes transition FS to Dirty.
  • jit_falls_back_for_fp_state_gates_at_o0_and_o2: JIT O0/O2 preserve the same traps for scalar FP, fcsr, and vector FP while recording an interpreter fallback.

Closes #317

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.

FP instructions and FP CSRs are not gated on mstatus.FS

1 participant