[RFC PATCH 09/12] platform: generic: parse root domain WID config from DT
Yu-Chien Peter Lin
peter.lin at sifive.com
Mon Jul 20 23:24:54 PDT 2026
On Mon, Jul 20, 2026 at 02:14:16PM -0700, Pawandeep Oza wrote:
> I gave the comment on your cover letter which was defining DT. pasting
> it here for the reference.
>
> Oza: lets start a bit from here from device tree.
>
> cpus {
> riscv,nworlds = <4>;
>
> cpu at 0 {
> riscv,pmwid = <3>; /* M-mode lives in World 3 */
> riscv,pmwidlist = <0x0 0xf>; /* M-mode can access Worlds 0-3 */
> riscv,pmlwidlist = <0x0 0xf>; /* S/U-mode can use Worlds 0-3 */
> };
> };
>
> chosen {
> opensbi-domains {
> /* WID 3 — M-mode (implicit, via pmwid) */
> trusted-domain {
> wid = <2>; /* WID 2 — trusted S-mode */
> widlist = <0x0 0x4>; /* can delegate WID 2 to U-mode */
> };
> untrusted-domain {
> wid = <1>; /* WID 1 — untrusted S-mode */
> widlist = <0x0 0x0>; /* no delegation */
> };
> root-domain {
> wid = <0>; /* WID 0 — root/unprotected */
> widlist = <0x0 0x0>;
Ah, I overlooked that reply, thanks Anup and Oza for suggestion.
I will follow it.
Regards,
Peter Lin
>
> On Mon, Jul 20, 2026 at 3:39 AM Anup Patel <anup at brainfault.org> wrote:
> >
> > On Mon, Jul 20, 2026 at 2:24 PM Yu-Chien Peter Lin <peter.lin at sifive.com> wrote:
> > >
> > > On Wed, Jul 08, 2026 at 05:39:34PM -0700, Pawandeep Oza wrote:
> > > > On Fri, Jun 26, 2026 at 3:17 AM Yu-Chien Peter Lin <peter.lin at sifive.com> wrote:
> > > > >
> > > > > Parse root-domain-next-wid (32-bit) and root-domain-next-widlist
> > > > > (64-bit) properties from /chosen/opensbi,config node during
> > > > > generic_domains_init(). Sets root.next_wid/has_next_wid and
> > > > > root.next_widlist.
> > > > >
> > > > > Signed-off-by: Yu-Chien Peter Lin <peter.lin at sifive.com>
> > > > > ---
> > > > > platform/generic/platform.c | 20 +++++++++++++++++++-
> > > > > 1 file changed, 19 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/platform/generic/platform.c b/platform/generic/platform.c
> > > > > index 51e9f342..de12deb5 100644
> > > > > --- a/platform/generic/platform.c
> > > > > +++ b/platform/generic/platform.c
> > > > > @@ -11,6 +11,7 @@
> > > > > #include <platform_override.h>
> > > > > #include <sbi/riscv_asm.h>
> > > > > #include <sbi/sbi_bitops.h>
> > > > > +#include <sbi/sbi_domain.h>
> > > > > #include <sbi/sbi_hartmask.h>
> > > > > #include <sbi/sbi_heap.h>
> > > > > #include <sbi/sbi_platform.h>
> > > > > @@ -276,7 +277,9 @@ int generic_extensions_init(bool cold_boot)
> > > > > int generic_domains_init(void)
> > > > > {
> > > > > const void *fdt = fdt_get_address();
> > > > > - int offset, ret;
> > > > > + const fdt32_t *val;
> > > > > + int len, offset, ret;
> > > > > + u64 val64;
> > > > >
> > > > > ret = fdt_domains_populate(fdt);
> > > > > if (ret < 0)
> > > > > @@ -290,6 +293,21 @@ int generic_domains_init(void)
> > > > > if (offset >= 0 &&
> > > > > fdt_get_property(fdt, offset, "system-suspend-test", NULL))
> > > > > sbi_system_suspend_test_enable();
> > > > > +
> > > > > + if (offset >= 0) {
> > > > > + val = fdt_getprop(fdt, offset, "root-domain-next-wid", &len);
> > > > > + if (val && len == sizeof(fdt32_t)) {
> > > > > + root.next_wid = fdt32_to_cpu(val[0]);
> > > > > + root.has_next_wid = true;
> > > > > + }
> > > > > +
> > > > > + val = fdt_getprop(fdt, offset, "root-domain-next-widlist", &len);
> > > > Oza: Root domain WID config is semantically identical to per-domain
> > > > WID config but lives in a completely different DT location
> > > > root can be another default domain under chosen { opensbi-domains {
> > >
> > > Sure, it would be better to have root domain wid configuration
> > > specified under the opensbi-domain parent node alongside other
> > > domains. I also am planning to introduce "opensbi,domain,instance,root"
> > > compatible string.
> >
> > Another approach is to treat DT node named "root" under path
> > "/chosen/opensbi-domains" for RISC-V worlds related DT property.
> > In the future, same "root" DT node can be used other root domain
> > DT properties.
> >
> > Regards,
> > Anup
> >
> > >
> > > Thanks,
> > > Peter Lin
> > >
> > > > > + if (val && (len == (2 * sizeof(fdt32_t)))) {
> > > > > + val64 = fdt32_to_cpu(val[0]);
> > > > > + val64 = (val64 << 32) | fdt32_to_cpu(val[1]);
> > > > > + root.next_widlist = val64;
> > > > > + }
> > > > > + }
> > > > > }
> > > > >
> > > > > return 0;
> > > > > --
> > > > > 2.43.7
> > > > >
> > > > >
> > > > > --
> > > > > opensbi mailing list
> > > > > opensbi at lists.infradead.org
> > > > > http://lists.infradead.org/mailman/listinfo/opensbi
More information about the opensbi
mailing list