[PATCH v3 2/3] lib: sbi: Add floating-point context save/restore support.
Radim Krčmář
radim.krcmar at oss.qualcomm.com
Thu Apr 2 06:40:01 PDT 2026
2026-03-31T06:58:56+01:00, <dave.patel at riscstar.com>:
> From: Dave Patel <dave.patel at riscstar.com>
>
> 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 at riscstar.com>"
> ---
> diff --git a/lib/sbi/sbi_vector.c b/lib/sbi/sbi_vector.c
> @@ -50,8 +50,8 @@ void sbi_vector_save(struct sbi_vector_context *dst)
> if (!dst)
> return;
>
> -#define READ_CSR(dst, csr) ( \
> - do { \
> +#define READ_CSR(dst, csr) \
> + { \
Please, change the first patch instead of fixing the bug here.
(Btw. "({ ... })" is a superior macro wrapper.)
Thanks.
[...]
> - } while (0))
> + }
More information about the opensbi
mailing list