On 12.05.23 13:09, Sascha Hauer wrote: > The i.MX HAB code on i.MX6 has to jump into ROM which happens to start > at 0x0. To make that possible we used to map the ROM cached and jumped > to it before the MMU is initialized. Instead, remap the ROM as needed > in the HAB code so that we can safely jump into ROM with MMU enabled. > > Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> > --- > arch/arm/cpu/mmu-early_32.c | 7 ------- > drivers/hab/habv4.c | 9 ++++++++- > 2 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/cpu/mmu-early_32.c b/arch/arm/cpu/mmu-early_32.c > index 07c5917e6a..94bde44c9b 100644 > --- a/arch/arm/cpu/mmu-early_32.c > +++ b/arch/arm/cpu/mmu-early_32.c > @@ -58,12 +58,5 @@ void mmu_early_enable(unsigned long membase, unsigned long memsize, > /* maps main memory as cachable */ > map_region(membase, memsize, PMD_SECT_DEF_CACHED); > > - /* > - * With HAB enabled we call into the ROM code later in imx6_hab_get_status(). > - * Map the ROM cached which has the effect that the XN bit is not set. > - */ > - if (IS_ENABLED(CONFIG_HABV4) && IS_ENABLED(CONFIG_ARCH_IMX6)) > - map_region(0x0, SZ_1M, PMD_SECT_DEF_CACHED); > - > __mmu_cache_on(); > } > diff --git a/drivers/hab/habv4.c b/drivers/hab/habv4.c > index 252e38f655..d2494db114 100644 > --- a/drivers/hab/habv4.c > +++ b/drivers/hab/habv4.c > @@ -11,6 +11,9 @@ > #include <hab.h> > #include <init.h> > #include <types.h> > +#include <mmu.h> > +#include <zero_page.h> > +#include <linux/sizes.h> > #include <linux/arm-smccc.h> > #include <asm/cache.h> > > @@ -613,12 +616,16 @@ static int init_imx6_hab_get_status(void) > /* can happen in multi-image builds and is not an error */ > return 0; > > + arch_remap_range(0x0, SZ_1M, MAP_CACHED); This affects SZ_1M bytes. > + > /* > * Nobody will check the return value if there were HAB errors, but the > * initcall will fail spectaculously with a strange error message. > */ > imx6_hab_get_status(); > > + zero_page_faulting(); This affects only 4K. The rest of the 1M can now be speculated into :/ > + > return 0; > } > > @@ -627,7 +634,7 @@ static int init_imx6_hab_get_status(void) > * which will no longer be accessible when the MMU sets the zero page to > * faulting. > */ > -postconsole_initcall(init_imx6_hab_get_status); > +postmmu_initcall(init_imx6_hab_get_status); > > int imx28_hab_get_status(void) > { -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |