[RFC PATCH v2 2/8] lib: sbi: Preserve optional H-extension state across domain switches
Radim Krcmar
rkrcmar at qti.qualcomm.com
Tue Oct 27 11:24:45 PDT 2026
Btw. you're adding optional state in [1/8] as well, so why not squash at
least the interrupt parts?
2026-10-23T00:09:19-07:00, Theodorus Wensan Februanto <theodoruswensanfebruanto025 at gmail.com>:
> Preserve hypervisor interrupt enable state provided by Smaia and
> hypervisor state-enable CSRs provided by Smstateen.
>
> Use extension checks so systems without these CSRs are unaffected.
> The 64-bit helper preserves the corresponding high-half CSRs on RV32.
>
> Link: https://github.com/riscv-software-src/opensbi/issues/433
> Signed-off-by: Theodorus Wensan Februanto <theodoruswensanfebruanto025 at gmail.com>
> ---
> diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c
> @@ -208,6 +211,19 @@ static int switch_to_next_domain_context(struct hart_context *ctx,
> ctx->hext.hviph = csr_swap(CSR_HVIPH, dom_ctx->hext.hviph);
> }
> #endif
> + if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMAIA))
> + ctx->hext.hvien = csr_swap64(CSR_HVIEN, dom_ctx->hext.hvien);
hvien also needs to be carefully ordered because it has an effect on
vsip and vsie.
(hvictl, hviprio1, and hviprio2 are missing.)
Thanks.
More information about the opensbi
mailing list