From: Radim Krcmar <rkrcmar@qti.qualcomm.com>
To: "dave.patel@riscstar.com" <dave.patel@riscstar.com>,
Samuel Holland <samuel.holland@sifive.com>
Cc: Scott Bambrough <scott@riscstar.com>,
Robin Randhawa <robin.randhawa@sifive.com>,
Anup Patel <anuppate@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@lists.infradead.org>,
opensbi <opensbi-bounces@lists.infradead.org>
Subject: Re: [PATCH v3 1/3] lib: sbi: Add RISC-V vector context save/restore support
Date: Mon, 30 Mar 2026 12:42:45 +0000 [thread overview]
Message-ID: <DHG4IUERGFUV.3TT9CFPZ9YEDG@qti.qualcomm.com> (raw)
In-Reply-To: <20260327171601.169103-2-dave.patel@riscstar.com>
2026-03-27T17:15:59+00:00, <dave.patel@riscstar.com>:
> From: Dave Patel <dave.patel@riscstar.com>
>
> Eager context switch: Add support for saving and restoring RISC-V vector
> extension state in OpenSBI. This introduces a per-hart vector context
> structure and helper routines to perform full context save and restore.
>
> The vector context includes vl, vtype, vcsr CSRs along with storage for all
> 32 vector registers. The register state is saved and restored using byte-wise
> vector load/store instructions (vse8.v/vle8.v), making the implementation
> independent of current SEW/LMUL configuration.
Using the whole register store/load (vs8r/vl8r) is more appropriate.
We must manipulate the whole architectural register file regardless of
what is configured by lower privileged modes.
(I think vse/vle shouldn't be used for the purpose of context-switching
as it's too easy to introduce a security issue with them.)
> The implementation follows an eager context switching model where the entire
> vector state is saved and restored on every context switch. This provides a
> simple and deterministic mechanism without requiring lazy trap-based
> management.
The code below uses the lower privilege's vl/vtype, which means that we
do not save the entire vector register file, but only the subset that is
currently configured by lower-privileges. This creates a side-channel.
> Notes:
> - The SBI_MAX_VLENB is configured using CONFIG_SBI_MAX_VLENB.
>
> Signed-off-by: Dave Patel <dave.patel@riscstar.com>
> ---
> diff --git a/include/sbi/sbi_vector.h b/include/sbi/sbi_vector.h
[...]
> + /* Restore CSRs first */
> + WRITE_CSR(vtype, src->vtype);
> + WRITE_CSR(vl, src->vl);
vl and vtype are read-only registers... how does this work?
Thanks.
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2026-03-30 12:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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:15 ` [PATCH v3 1/3] lib: sbi: Add RISC-V vector context save/restore support dave.patel
2026-03-30 12:42 ` Radim Krcmar [this message]
2026-03-27 17:16 ` [PATCH v3 2/3] lib: sbi: Add floating-point " 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
-- strict thread matches above, loose matches on Subject: below --
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ář
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=DHG4IUERGFUV.3TT9CFPZ9YEDG@qti.qualcomm.com \
--to=rkrcmar@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