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

Pawandeep Oza pawandeep.oza at oss.qualcomm.com
Thu Sep 3 15:00:34 PDT 2026


On Mon, Aug 17, 2026 at 2:05 AM Yu-Chien Peter Lin <peter.lin at sifive.com> wrote:
>
> Display domain-specific World ID (Wid/Widdeleg)
> and M-mode World ID source (from mwid/pmwid) during
> initialization for RISC-V Worlds debugging and
> verification.
>
> Signed-off-by: Yu-Chien Peter Lin <peter.lin at sifive.com>
> ---
>  lib/sbi/sbi_domain.c | 31 +++++++++++++++++++++++++++++++
>  lib/sbi/sbi_init.c   | 13 +++++++++++++
>  2 files changed, 44 insertions(+)
>
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> index fa69170b..d1f7bb0c 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>
> @@ -533,6 +534,8 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix)
>         u32 i, j, k;
>         unsigned long rstart, rend;
>         struct sbi_domain_memregion *reg;
> +       struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
> +       const struct sbi_hart_features *hf = sbi_hart_features_ptr(scratch);
>
>         sbi_printf("Domain%d Name        %s: %s\n",
>                    dom->index, suffix, dom->name);
> @@ -608,6 +611,34 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix)
>                 break;
>         }
>
> +       if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMLWID)) {
> +               if (dom->has_wid) {
> +                       sbi_printf("Domain%d Wid         %s: %u\n",
> +                                  dom->index, suffix, dom->wid);
> +               } else if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMWID)) {
> +                       sbi_printf("Domain%d Wid         %s: %lu (mwid)\n",
> +                                  dom->index, suffix,
> +                                  csr_read(CSR_MWID) & ~MWID_LOCK);
> +               } else if (hf->has_pmwid) {
> +                       sbi_printf("Domain%d Wid         %s: %u (pmwid)\n",
> +                                  dom->index, suffix, hf->pmwid);
> +               } else {
> +                       sbi_printf("Domain%d Wid         %s: unknown\n",
> +                                  dom->index, suffix);
> +               }
> +       } 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
>

if you decide to remove all the booleans may be then this patch will
change as well

Reviewed-by: Pawandeep Oza <pawandeep.oza at oss.qualcomm.com>



More information about the opensbi mailing list