[RFC PATCH v4 4/4] lib: sbi: Initialize SMMPT during coldboot

Rahul Pathak rahul.pathak at oss.qualcomm.com
Sun Aug 23 22:43:37 PDT 2026


On Mon, Aug 24, 2026 at 11:00 AM Ranbir Singh
<ranbir.singh at oss.qualcomm.com> wrote:
>
> On Mon, Aug 24, 2026 at 7:41 AM Rahul Pathak
> <rahul.pathak at oss.qualcomm.com> wrote:
> >
> > Call sbi_mpt_init() function from coldboot path of
> > sbi_hart_init() to initialize the SMMPT core. It will
> > create and the MPT tables for each SBI domain and maps
> > its memregions with appropriate permissions in MPT tables.
> >
> > Also each MPT table requires to memory to install tables
> > so reserve more space in heap for MPT tables
> >
> > Signed-off-by: Rahul Pathak <rahul.pathak at oss.qualcomm.com>
> > ---
> >  lib/sbi/sbi_hart.c          | 8 +++++++-
> >  platform/generic/platform.c | 9 +++++++++
> >  2 files changed, 16 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
> > index 4261fea8..cc18b2c5 100644
> > --- a/lib/sbi/sbi_hart.c
> > +++ b/lib/sbi/sbi_hart.c
> > @@ -1,4 +1,4 @@
> > -/*
> > +/*sbi_hart.
>
> RS: Looks like this is mistakenly added.

Yes, typo, will correct it

>
> >   * SPDX-License-Identifier: BSD-2-Clause
> >   *
> >   * Copyright (c) 2019 Western Digital Corporation or its affiliates.
> > @@ -21,6 +21,7 @@
> >  #include <sbi/sbi_pmu.h>
> >  #include <sbi/sbi_string.h>
> >  #include <sbi/sbi_trap.h>
> > +#include <sbi/sbi_hart_mpt.h>
> >
> >  extern void __sbi_expected_trap(void);
> >  extern void __sbi_expected_trap_hext(void);
> > @@ -731,6 +732,11 @@ int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot)
> >                 rc = sbi_hart_pmp_init(scratch);
> >                 if (rc)
> >                         return rc;
> > +
> > +               /* Smmpt is optional. Continue if the Smmpt is not present. */
> > +               rc = sbi_mpt_init();
> > +               if (rc && rc != SBI_ENODEV)
> > +                       return rc;
> >         }
> >
> >         return sbi_hart_reinit(scratch);
> > diff --git a/platform/generic/platform.c b/platform/generic/platform.c
> > index 1df0280d..ccf6f756 100644
> > --- a/platform/generic/platform.c
> > +++ b/platform/generic/platform.c
> > @@ -42,6 +42,15 @@ static u32 fw_platform_calculate_heap_size(u32 hart_count)
> >         /* For TLB fifo */
> >         heap_size += SBI_TLB_INFO_SIZE * (hart_count) * (hart_count);
> >
> > +       /*
> > +        * MPT table budget
> > +        * 1 MiB memory for MPT allocated currently.
> > +        *
> > +        * TODO: Need better way to get the memory budget based on active
> > +        * SMMPT mode.
> > +        */
> > +       heap_size += 1024 * 1024;
>
> RS: See if it is better to define and use macros here like

I agree, will update

>         #define MB(x)  (x * 1024 * 1024)
>
>         heap_size += MB(1)
>
> > +
> >         return BIT_ALIGN(heap_size, HEAP_BASE_ALIGN);
> >  }
> >
> > --
> > 2.53.0
> >
> >
> > --
> > opensbi mailing list
> > opensbi at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list