Commit Graph
2 Commits
Author SHA1 Message Date
whensun 7774b82e4a lib: sbi: Fix FP state enable in sbi_fp_save
sbi_fp_save() currently sets mstatus.VS before executing floating-point
store instructions. VS controls vector state and does not enable
floating-point instructions.

Set mstatus.FS instead, matching sbi_fp_restore(), so floating-point
state can be saved when FS was previously Off.

Fixes: 718e1d194f ("lib: sbi: Add floating-point context save/restore support.")
Signed-off-by: whensun <theodoruswensanfebruanto025@gmail.com>
Co-developed-by: Huamao Wu <huamao.wu@spacemit.com>
Signed-off-by: Huamao Wu <huamao.wu@spacemit.com>
Link: https://lore.kernel.org/r/20260828213104.84490-1-theodoruswensanfebruanto025@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-05 12:33:48 +05:30
Dave Patel 718e1d194f lib: sbi: Add floating-point context save/restore support.
Add support for saving and restoring RISC-V floating-point (F/D) extension
state in OpenSBI. This introduces a floating-point context structure and
helper routines to perform full context save and restore.

The floating-point context includes storage for all 32 FPi registers (f0–f31)
along with the fcsr control and status register. The register state is saved
and restored using double-precision load/store instructions (fsd/fld), and
single-precision load/store instructions (fsw/flw) on an RV64 system with
F and D-extension support.

The implementation follows an eager context switching model where the entire
FP state is saved and restored on every context switch. This avoids the need
for trap-based lazy management and keeps the design simple and deterministic.

Signed-off-by: Dave Patel <dave.patel@riscstar.com>
Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260518083023.997323-3-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-05-18 14:02:28 +05:30