[PATCH -next v6 03/10] arm: armv8: mmu: export mmu_setup

Ilias Apalodimas ilias.apalodimas at linaro.org
Fri Sep 12 08:02:39 CEST 2025


On Fri, 12 Sept 2025 at 08:59, Ilias Apalodimas
<ilias.apalodimas at linaro.org> wrote:
>
> On Fri, 5 Sept 2025 at 11:19, Anshul Dalal <anshuld at ti.com> wrote:
> >
> > The mmu_setup function configures the page tables based on the board
> > supplied mem_map struct array. It is called implicitly as part of
> > dcache_enable but this limits us to only be able to use APIs such as
> > mmu_change_region_attr only after caches are enabled.
> >
> > This might lead to speculative accesses before we can unmap a region
> > that is marked as cacheable in the static memory map.
> >
> > Therefore this patch exports the mmu_setup function in mmu.h allowing
> > users to have more control over when the mmu is configured.
> >
> > For K3 specifically this allows for the following configuration sequence
> > as part of enable_caches:
> >
> > static mem_map fixups (TODO) -> mmu_setup -> carveouts using
> > mmu_change_region_attr (TODO) -> icache/dcache enable
> >
> > Signed-off-by: Anshul Dalal <anshuld at ti.com>
> > ---
> >  arch/arm/include/asm/armv8/mmu.h | 5 +++++
> >  arch/arm/mach-k3/common.c        | 3 +++
> >  2 files changed, 8 insertions(+)
> >
> > diff --git a/arch/arm/include/asm/armv8/mmu.h b/arch/arm/include/asm/armv8/mmu.h
> > index 6af8cd111a4..3807c702fb6 100644
> > --- a/arch/arm/include/asm/armv8/mmu.h
> > +++ b/arch/arm/include/asm/armv8/mmu.h
> > @@ -197,6 +197,11 @@ struct mm_region {
> >  extern struct mm_region *mem_map;
> >  void setup_pgtables(void);
> >  u64 get_tcr(u64 *pips, u64 *pva_bits);
> > +
> > +/**
> > + * mmu_setup() - Sets up the mmu page tables as per mem_map
> > + */
> > +void mmu_setup(void);
> >  #endif
> >
> >  #endif /* _ASM_ARMV8_MMU_H_ */
> > diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
> > index 9d6c6fea451..e9b48b528d6 100644
> > --- a/arch/arm/mach-k3/common.c
> > +++ b/arch/arm/mach-k3/common.c
> > @@ -30,6 +30,7 @@
> >  #include <soc.h>
> >  #include <dm/uclass-internal.h>
> >  #include <dm/device-internal.h>
> > +#include <asm/armv8/mmu.h>
> >
> >  #define PROC_BOOT_CTRL_FLAG_R5_CORE_HALT       0x00000001
> >  #define PROC_BOOT_STATUS_FLAG_R5_WFI           0x00000002
> > @@ -261,6 +262,8 @@ void board_prep_linux(struct bootm_headers *images)
> >
> >  void enable_caches(void)
> >  {
> > +       mmu_setup();
> > +
>
> mmu_setup() will run twice here. I assume that's ok ?
>
> Thanks
> /Ilias

Oh I misread this. It won't

Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> >         icache_enable();
> >         dcache_enable();
> >  }
> > --
> > 2.50.1
> >


More information about the U-Boot mailing list