From: dave.patel@riscstar.com
To: 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>,
Dave Patel <dave.patel@riscstar.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
Subject: [PATCH v2 0/3] Add eager FP and RISC-V vector context switching support
Date: Thu, 26 Mar 2026 11:55:14 +0000 [thread overview]
Message-ID: <20260326115517.2156-1-dave.patel@riscstar.com> (raw)
Hi Samuel et. al,
Thanks you for the initial review and support, sending out v2 set of patch to gather
more consensus, currently the context switch itself in Opensbi is not being hooked up.
This series enhances OpenSBI domain context switching to properly save and restore
floating-point (FP) and vector (V) registers on multi-domain systems.
The context switch has now been corrected to the domain context switch instead of
trap handler; there is more understanding of how the one OS can context switch to
another OS for eg. Rich OS with Secure OS using Opensbi as monitor and that context
needs saving between the domain switch.
This eager context switching approach is more efficient as an alternative to lazy
context switch which cannot be used due to its limitation and is more efficient
to only store and restore on domain context switch.
This 3-patch series introduces:
1. **PATCH 1/3 – Domain data structure enhancements for Vector unit**
- Adds domain pointers for Vector (`vec_ctx`) contexts.
- Prepares the domain structure for storing isolated vector state.
- Fixing compilation within each set of patch
- Fixed all the assumptions
-- added vstart CSR aswell for context switching.
-- handled config based SBI_MAX_VLENB.
-- Fixed vector support for Zve32x
2. **PATCH 2/3 – FP and Vector domain init/exit routines**
- Adds domain pointers for FP (`fp_ctx`) contexts.
- Prepares the domain structure for storing isolated vector state.
- Fixing compilation within the patch and issue seen in v1 series.
- Fixed all the assumptions
-- added support for both 64 and 32 bit FP
-- added support for double and single precision support.
-- Support for correct context for Zve32x.
-- removed dependencies on PLATFORM_RISCV_ISA=rv64gcv
3. **PATCH 3/3 – Domain context switch updates**
- Updates `switch_to_next_domain_context()` to save and restore FP and vector
registers.
- Implements `sbi_fp_domain_init/exit` and `sbi_vector_domain_init/exit`.
- Initializes FP/vector contexts during domain registration.
- Cleans up context memory during shutdown.
- Provides safe no-op versions for harts without FP or vector extensions.
- Ensures FS and VS in `mstatus` are enabled only if Off.
- Preserves original `mstatus` after restoring FP/vector state.
- Works safely even on harts without FP or vector support.
Together, these changes ensure proper isolation of FP and vector registers between
domains, enabling robust multi-domain operation on RISC-V systems.
Signed-off-by: Dave Patel <dave.patel@riscstar.com>
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next reply other threads:[~2026-03-26 11:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 11:55 dave.patel [this message]
2026-03-26 11:55 ` [PATCH v2 1/3] lib: sbi: Add RISC-V vector context save/restore support (eager switching) dave.patel
2026-03-26 14:27 ` Samuel Holland
2026-03-26 11:55 ` [PATCH v2 2/3] lib: sbi: Add floating-point context save/restore support dave.patel
2026-03-26 14:32 ` Samuel Holland
2026-03-26 11:55 ` [PATCH v2 3/3] lib: sbi: domain FP/Vector context support for context switch dave.patel
2026-03-26 14:41 ` Samuel Holland
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=20260326115517.2156-1-dave.patel@riscstar.com \
--to=dave.patel@riscstar.com \
--cc=anup.patel@qti.qualcomm.com \
--cc=anuppate@qti.qualcomm.com \
--cc=dhaval@rivosinc.com \
--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