[PATCH] lib: sbi: Try to make each domain have boot hart

Anup Patel anup at brainfault.org
Mon Jul 3 20:48:38 PDT 2023


On Tue, Jun 20, 2023 at 6:02 PM Xiang W <wxjstz at 126.com> wrote:
>
> domain register will move the hart from the old domain to the
> new domain, and should not move the boot hart to prevent the
> old domain from losing the boot hart.
>
> Signed-off-by: Xiang W <wxjstz at 126.com>
> ---
>  lib/sbi/sbi_domain.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> index 38a5902..46a4aef 100644
> --- a/lib/sbi/sbi_domain.c
> +++ b/lib/sbi/sbi_domain.c
> @@ -543,9 +543,23 @@ int sbi_domain_register(struct sbi_domain *dom,
>                         continue;
>
>                 tdom = sbi_hartid_to_domain(i);
> -               if (tdom)
> +               if (tdom) {
> +                       if (i == tdom->boot_hartid) {
> +                               /* Newly registered domain should not
> +                                * take up the boot hart of the older domain */
> +                               if (i == dom->boot_hartid)
> +                                       sbi_printf("%s: failed assign Hart%d to %s, "
> +                                               "conflict with %s\n",
> +                                               __func__, i, dom->name, tdom->name);
> +                               else
> +                                       sbi_printf("%s: skip assign Hart%d to %s, "
> +                                               "because Hart%d is boot hart of %s\n",
> +                                               __func__, i, dom->name, i, tdom->name);
> +                               continue;
> +                       }

This is not needed because sbi_domain_finalize() already checks that
dom->boot_hartid is assigned to dom before starting dom->boot_hartid.

The cold boot HART is by default boot HART of the root domain and
assigned to the root domain. This patch prevents cold boot HART from
changing its own domain.

NACK for this patch.

Regards,
Anup

>                         sbi_hartmask_clear_hart(i,
>                                         &tdom->assigned_harts);
> +               }
>                 update_hartid_to_domain(i, dom);
>                 sbi_hartmask_set_hart(i, &dom->assigned_harts);
>
> --
> 2.39.2
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list