From: "Radim Krčmář" <radim.krcmar@oss.qualcomm.com>
To: <dave.patel@riscstar.com>, "Samuel Holland" <samuel.holland@sifive.com>
Cc: "Scott Bambrough" <scott@riscstar.com>,
"Robin Randhawa" <robin.randhawa@sifive.com>,
"Anup Patel" <anup.patel@qti.qualcomm.com>,
"Ray Mao" <raymond.mao@riscstar.com>,
"Anup Patel" <anuppate@qti.qualcomm.com>,
"Dhaval" <dhaval@rivosinc.com>,
"Peter Lin" <peter.lin@sifive.com>, <opensbi@lists.infradead.org>,
"opensbi" <opensbi-bounces@lists.infradead.org>
Subject: Re: [PATCH v3 3/3] lib: sbi: domain FP/Vector context support for context switch
Date: Thu, 02 Apr 2026 15:54:18 +0200 [thread overview]
Message-ID: <DHIPX9YUMY2L.2M8SIQJDJ6Q4U@oss.qualcomm.com> (raw)
In-Reply-To: <20260331055858.305207-4-dave.patel@riscstar.com>
2026-03-31T06:58:57+01:00, <dave.patel@riscstar.com>:
> From: Dave Patel <dave.patel@riscstar.com>
>
> This patch adds proper support for per-domain floating-point (FP) and
> vector (V) contexts in the domain context switch logic. Each domain
> now maintains its own FP and vector state, which is saved and restored
> during domain switches.
>
> Changes include:
>
> - Added `fp_ctx` and `vec_ctx` members to `struct sbi_domain`.
> - Introduced `sbi_vector_domain_init` for vlen check
> to allocate and free per-domain FP and vector context.
> - Modified `sbi_domain_register()` to initialize FP/Vector context per domain.
> - Updated `switch_to_next_domain_context()` to save/restore FP and vector
> contexts safely:
> - Ensures FS/VS fields in `mstatus` are enabled (set to Initial) only if Off.
> - Restores original FS/VS bits after context switch.
> - Adds NULL checks to handle domains without FP or Vector extensions.
> - Updated domain context deinit to free FP and vector contexts per domain.
> - Added runtime checks for FP and vector extensions where needed.
> - Corrected handling of MSTATUS FS/VS bits to avoid unsafe full-bit writes.
>
> This improves support for multi-domain systems with FP and Vector
> extensions, and prevents corruption of FP/Vector state during domain
> switches.
>
> Signed-off-by: Dave Patel <dave.patel@riscstar.com>
> ---
> diff --git a/include/sbi/sbi_fp.h b/include/sbi/sbi_fp.h
> @@ -8,13 +8,8 @@
> #ifndef __SBI_FP_H__
> #define __SBI_FP_H__
>
> -#include <sbi/riscv_encoding.h>
> #include <sbi/sbi_types.h>
>
> -#if defined(__riscv_f) || defined(__riscv_d)
> -
> -#include <stdint.h>
> -
> struct sbi_fp_context {
> #if __riscv_d
> uint64_t f[32];
> @@ -22,13 +17,7 @@ struct sbi_fp_context {
> uint32_t f[32];
> #endif
> uint32_t fcsr;
> -} __aligned(16);
> -
> -#else /* No FP (e.g., Zve32x) */
> -
> -struct sbi_fp_context { };
> -
> -#endif //defined(__riscv_f) || defined(__riscv_d)
> +};
Similar comment as to [2/3]: these should have been introduced earlier.
(There is a lot of other random artifacts in the patch.)
> diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c
> @@ -143,6 +146,15 @@ static int switch_to_next_domain_context(struct hart_context *ctx,
> + /* Make sure FS and VS is on before context switch */
> + csr_set(CSR_MSTATUS, MSTATUS_FS | MSTATUS_VS);
Where is the ctx->sstatus restored to CSR_SSTATUS?
Thanks.
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2026-04-02 13:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 5:58 [PATCH v3 0/3] Add eager FP and RISC-V vector context switching support dave.patel
2026-03-31 5:58 ` [PATCH v3 1/3] lib: sbi: Add RISC-V vector context save/restore support dave.patel
2026-04-02 13:35 ` Radim Krčmář
2026-03-31 5:58 ` [PATCH v3 2/3] lib: sbi: Add floating-point " dave.patel
2026-04-02 13:40 ` Radim Krčmář
2026-03-31 5:58 ` [PATCH v3 3/3] lib: sbi: domain FP/Vector context support for context switch dave.patel
2026-04-02 13:54 ` Radim Krčmář [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-03-27 17:15 [PATCH v3 0/3] Add eager FP and RISC-V vector context switching support dave.patel
2026-03-27 17:16 ` [PATCH v3 3/3] lib: sbi: domain FP/Vector context support for context switch dave.patel
2026-03-30 12:53 ` Radim Krcmar
2026-03-31 5:49 ` Dave Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DHIPX9YUMY2L.2M8SIQJDJ6Q4U@oss.qualcomm.com \
--to=radim.krcmar@oss.qualcomm.com \
--cc=anup.patel@qti.qualcomm.com \
--cc=anuppate@qti.qualcomm.com \
--cc=dave.patel@riscstar.com \
--cc=dhaval@rivosinc.com \
--cc=opensbi-bounces@lists.infradead.org \
--cc=opensbi@lists.infradead.org \
--cc=peter.lin@sifive.com \
--cc=raymond.mao@riscstar.com \
--cc=robin.randhawa@sifive.com \
--cc=samuel.holland@sifive.com \
--cc=scott@riscstar.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox