[PATCH] lib: sbi: Fix FP state enable in sbi_fp_save
Anup Patel
anup at brainfault.org
Sat Sep 5 00:04:51 PDT 2026
On Sat, Aug 29, 2026 at 3:01 AM whensun
<theodoruswensanfebruanto025 at gmail.com> wrote:
>
> 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: 718e1d194f5a ("lib: sbi: Add floating-point context save/restore support.")
>
> Signed-off-by: whensun <theodoruswensanfebruanto025 at gmail.com>
LGTM.
Reviewed-by: Anup Patel <anup at brainfault.org>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
> ---
> lib/sbi/sbi_fp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_fp.c b/lib/sbi/sbi_fp.c
> index c8941252..38fb7a01 100644
> --- a/lib/sbi/sbi_fp.c
> +++ b/lib/sbi/sbi_fp.c
> @@ -20,7 +20,7 @@ void sbi_fp_save(struct sbi_fp_context *dst)
> if (!dst)
> return;
>
> - mstatus_orig = csr_read_set(CSR_MSTATUS, MSTATUS_VS);
> + mstatus_orig = csr_read_set(CSR_MSTATUS, MSTATUS_FS);
>
> asm volatile(
> #if defined(__riscv_d)
> --
> 2.43.0
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
More information about the opensbi
mailing list