Re: [PATCH 10/27] ARM: i.MX: Drop HAB workaround

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 12, 2023 at 08:09:06PM +0200, Ahmad Fatoum wrote:
> 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 :/

Ok, I'll add a

	arch_remap_range((void *)PAGE_SIZE, SZ_1M - PAGE_SIZE, MAP_UNCACHED);

to remap the remaining space as uncached.

Sascha


-- 
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 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux