[RFC PATCH 5/5] lib: sbi: Preserve the supervisor indirect CSR selector

whensun theodoruswensanfebruanto025 at gmail.com
Thu Oct 22 19:43:45 PDT 2026


From: Theodorus Wensan Februanto <theodoruswensanfebruanto025 at gmail.com>

Save the supervisor indirect CSR selector when Sscsrind is available.

The sireg windows refer to different backing state depending on
siselect. This change preserves the selector only and does not save
the indirect backing state, IMSIC files, or CTR records.

Link: https://github.com/riscv-software-src/opensbi/issues/433
Signed-off-by: Theodorus Wensan Februanto <theodoruswensanfebruanto025 at gmail.com>
---
 lib/sbi/sbi_domain_context.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c
index 0541bf8e..15e9f543 100644
--- a/lib/sbi/sbi_domain_context.c
+++ b/lib/sbi/sbi_domain_context.c
@@ -73,6 +73,8 @@ struct hart_context {
 	u64 stimecmp;
 	/** Supervisor counter inhibit configuration */
 	unsigned long scountinhibit;
+	/** Supervisor indirect CSR selector */
+	unsigned long siselect;
 
 	/** Float context state */
 	struct sbi_fp_context fp_ctx;
@@ -207,6 +209,8 @@ static int switch_to_next_domain_context(struct hart_context *ctx,
 	    (csr_read64(CSR_MENVCFG) & ENVCFG_CDE))
 		ctx->scountinhibit = csr_swap(CSR_SCOUNTINHIBIT,
 						 dom_ctx->scountinhibit);
+	if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCSRIND))
+		ctx->siselect = csr_swap(CSR_SISELECT, dom_ctx->siselect);
 
 	/* Eager context switch for float */
 	if (sbi_hart_has_extension(scratch, SBI_HART_EXT_F) ||
-- 
2.43.0




More information about the opensbi mailing list