[PATCH v3 5/9] lib: sbi_domain_context: propagate error from sbi_hart_protection_reconfigure

Anup Patel anup at brainfault.org
Wed Oct 28 03:54:08 PDT 2026


On Tue, Oct 27, 2026 at 2:05 PM Yu-Chien Peter Lin <peter.lin at sifive.com> wrote:
>
> Propagate the return value of sbi_hart_protection_reconfigure in
> switch_to_next_domain_context to ensure that domain transition
> failures are correctly handled by the caller.
>
> Signed-off-by: Yu-Chien Peter Lin <peter.lin at sifive.com>

LGTM.

Reviewed-by: Anup Patel <anup at brainfault.org>

Regards,
Anup

> ---
> Change v2->v3:
> - New patch: propagate return value of sbi_hart_protection_reconfigure()
>   in switch_to_next_domain_context().
> ---
>  lib/sbi/sbi_domain_context.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c
> index 987ac7fa..1751d016 100644
> --- a/lib/sbi/sbi_domain_context.c
> +++ b/lib/sbi/sbi_domain_context.c
> @@ -110,6 +110,7 @@ static int switch_to_next_domain_context(struct hart_context *ctx,
>         MUST_NOT_HOLD(&ctx->dom->assigned_harts_lock)
>         MUST_NOT_HOLD(&dom_ctx->dom->assigned_harts_lock)
>  {
> +       int rc;
>         u32 hartindex = current_hartindex();
>         struct sbi_trap_context *trap_ctx;
>         struct sbi_domain *current_dom, *target_dom;
> @@ -173,7 +174,9 @@ static int switch_to_next_domain_context(struct hart_context *ctx,
>          * is also required for some of the above CSR updates (such
>          * as satp CSR).
>          */
> -       sbi_hart_protection_reconfigure(scratch, current_dom, target_dom);
> +       rc = sbi_hart_protection_reconfigure(scratch, current_dom, target_dom);
> +       if (rc)
> +               return rc;
>
>         /* Mark current context structure initialized because context saved */
>         ctx->initialized = true;
> --
> 2.43.7
>



More information about the opensbi mailing list