[PATCH v3 8/9] lib: sbi: display World ID configuration at boot

Anup Patel anup at brainfault.org
Wed Oct 28 04:11:24 PDT 2026


On Tue, Oct 27, 2026 at 2:06 PM Yu-Chien Peter Lin <peter.lin at sifive.com> wrote:
>
> Print per-domain Wid/Widdeleg and boot HART's M-mode
> World ID (mwid/pmwid fallback).
>
> Signed-off-by: Yu-Chien Peter Lin <peter.lin at sifive.com>

LGTM.

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

Thanks,
Anup

> ---
> Change v2->v3:
> - Display dom->wid directly when Smlwid is present.
> ---
>  lib/sbi/sbi_domain.c | 18 ++++++++++++++++++
>  lib/sbi/sbi_init.c   | 13 +++++++++++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> index be9020d0..f92ebc2f 100644
> --- a/lib/sbi/sbi_domain.c
> +++ b/lib/sbi/sbi_domain.c
> @@ -10,6 +10,7 @@
>  #include <sbi/riscv_asm.h>
>  #include <sbi/sbi_console.h>
>  #include <sbi/sbi_domain.h>
> +#include <sbi/sbi_hart.h>
>  #include <sbi/sbi_hartmask.h>
>  #include <sbi/sbi_heap.h>
>  #include <sbi/sbi_hsm.h>
> @@ -613,6 +614,7 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix)
>         u32 i, j, k;
>         unsigned long rstart, rend;
>         const struct sbi_domain_memregion *reg;
> +       struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
>
>         sbi_printf("Domain%d Name        %s: %s\n",
>                    dom->index, suffix, dom->name);
> @@ -691,6 +693,22 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix)
>                 break;
>         }
>
> +       if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMLWID)) {
> +               sbi_printf("Domain%d Wid         %s: %u\n",
> +                          dom->index, suffix, dom->wid);
> +       } else {
> +               sbi_printf("Domain%d Wid         %s: unsupported\n",
> +                          dom->index, suffix);
> +       }
> +
> +       if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMWIDDELEG)) {
> +               sbi_printf("Domain%d Widdeleg    %s: 0x%" PRIx64 "\n",
> +                          dom->index, suffix, dom->widdeleg);
> +       } else {
> +               sbi_printf("Domain%d Widdeleg    %s: unsupported\n",
> +                          dom->index, suffix);
> +       }
> +
>         sbi_printf("Domain%d SysReset    %s: %s\n",
>                    dom->index, suffix, (dom->system_reset_allowed) ? "yes" : "no");
>
> diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
> index acd2f8b6..f771f548 100644
> --- a/lib/sbi/sbi_init.c
> +++ b/lib/sbi/sbi_init.c
> @@ -167,6 +167,7 @@ static void sbi_boot_print_hart(struct sbi_scratch *scratch, u32 hartid)
>         int xlen;
>         char str[256];
>         const struct sbi_domain *dom = sbi_domain_thishart_ptr();
> +       struct sbi_hart_features *hf = sbi_hart_features_ptr(scratch);
>
>         if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)
>                 return;
> @@ -199,6 +200,18 @@ static void sbi_boot_print_hart(struct sbi_scratch *scratch, u32 hartid)
>         sbi_printf("Boot HART Debug Triggers    : %d triggers\n",
>                    sbi_dbtr_get_total_triggers());
>         sbi_hart_delegation_dump(scratch, "Boot HART ", "           ");
> +       if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMWID)) {
> +               ulong mwid = csr_read(CSR_MWID);
> +
> +               sbi_printf("Boot HART M-mode World ID   : %lu (%s)\n",
> +                          mwid & ~MWID_LOCK,
> +                          (mwid & MWID_LOCK) ? "locked" : "unlocked");
> +       } else if (hf->has_pmwid) {
> +               sbi_printf("Boot HART M-mode World ID   : %u (pmwid)\n",
> +                          hf->pmwid);
> +       } else {
> +               sbi_printf("Boot HART M-mode World ID   : unsupported\n");
> +       }
>  }
>
>  static unsigned long coldboot_done;
> --
> 2.43.7
>



More information about the opensbi mailing list