mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Rouven Czerwinski <r.czerwinski@pengutronix.de>
To: Peter Rosin <peda@axentia.se>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	 Ahmad Fatoum <ahmad@a3f.at>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 3/4] Revert "ARM: mmu: use client domain permissions to support ARMv7 eXecute Never"
Date: Sun, 19 Sep 2021 09:06:59 +0200	[thread overview]
Message-ID: <e14fb2eb0ea344ac272b823c51ee3a4049a51c33.camel@pengutronix.de> (raw)
In-Reply-To: <d4eb8281-121e-91a3-7300-83336ba0f285@axentia.se>

Hi Peter,

while this may break for your board, it fundamentally introduces the
possibility to speculate out of the RAM area on speculation happy
processors. Are you calling into SAMA5D3 ROM code somewhere? If so an
exception can be added similar to the handling for the HAB code
(arch/arm/cpu/mmu_early.c):

	if (IS_ENABLED(CONFIG_HABV4) && IS_ENABLED(CONFIG_ARCH_IMX6))
		map_region(0x0, SZ_1M, PMD_SECT_DEF_CACHED);

which allows calls into the NXP boot ROM to retrieve the HAB status.

Regards,
Rouven

On Sat, 2021-09-18 at 00:40 +0200, Peter Rosin wrote:
> This reverts commit 3e4a0405455f66fbae0a98dc1faee5c7c39f17a2.
> 
> The patch breaks my SAMA5D3 board.
> 
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  arch/arm/cpu/mmu-early.c | 7 +------
>  arch/arm/cpu/mmu.c       | 7 +------
>  arch/arm/cpu/mmu.h       | 1 -
>  3 files changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/arm/cpu/mmu-early.c b/arch/arm/cpu/mmu-early.c
> index b985aa455fe8..92b1161985fb 100644
> --- a/arch/arm/cpu/mmu-early.c
> +++ b/arch/arm/cpu/mmu-early.c
> @@ -29,12 +29,7 @@ void mmu_early_enable(unsigned long membase, unsigned long memsize,
>  	arm_set_cache_functions();
>  
>  	set_ttbr(ttb);
> -
> -	/* For the XN bit to take effect, we can't be using DOMAIN_MANAGER. */
> -	if (cpu_architecture() >= CPU_ARCH_ARMv7)
> -		set_domain(DOMAIN_CLIENT);
> -	else
> -		set_domain(DOMAIN_MANAGER);
> +	set_domain(DOMAIN_MANAGER);
>  
>  	/*
>  	 * This marks the whole address space as uncachable as well as
> diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
> index 6388e1bf14f6..d0aff9e7f027 100644
> --- a/arch/arm/cpu/mmu.c
> +++ b/arch/arm/cpu/mmu.c
> @@ -452,12 +452,7 @@ void __mmu_init(bool mmu_on)
>  		ttb = xmemalign(ARM_TTB_SIZE, ARM_TTB_SIZE);
>  
>  		set_ttbr(ttb);
> -
> -		/* For the XN bit to take effect, we can't be using DOMAIN_MANAGER. */
> -		if (cpu_architecture() >= CPU_ARCH_ARMv7)
> -			set_domain(DOMAIN_CLIENT);
> -		else
> -			set_domain(DOMAIN_MANAGER);
> +		set_domain(DOMAIN_MANAGER);
>  
>  		create_flat_mapping(ttb);
>  		__mmu_cache_flush();
> diff --git a/arch/arm/cpu/mmu.h b/arch/arm/cpu/mmu.h
> index c85e0ea05033..e8b72662cddc 100644
> --- a/arch/arm/cpu/mmu.h
> +++ b/arch/arm/cpu/mmu.h
> @@ -36,7 +36,6 @@ static inline void set_ttbr(void *ttb)
>  	asm volatile ("mcr  p15,0,%0,c2,c0,0" : : "r"(ttb) /*:*/);
>  }
>  
> -#define DOMAIN_CLIENT	1
>  #define DOMAIN_MANAGER	3
>  
>  static inline unsigned long get_domain(void)



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-09-19  7:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17 22:37 at91 sama5d3 "regressions" Peter Rosin
2021-09-17 22:39 ` [PATCH 1/4] common.h: reintroduce region_overlap() as, old_region_overlap() Peter Rosin
2021-09-17 22:39 ` [PATCH 2/4] ARM: copy data if there is a region overlap Peter Rosin
2021-09-17 22:40 ` [PATCH 3/4] Revert "ARM: mmu: use client domain permissions to support ARMv7 eXecute Never" Peter Rosin
2021-09-19  7:06   ` Rouven Czerwinski [this message]
2021-09-19  7:50     ` Peter Rosin
2021-09-19 20:33       ` Peter Rosin
2021-09-20  9:14       ` Ahmad Fatoum
2021-09-20 10:22         ` Peter Rosin
2021-09-17 22:41 ` [PATCH 4/4] lds: the RO_DATA_SECTION macro does not work on my SAMA5D3 board Peter Rosin
2021-09-17 23:57 ` at91 sama5d3 "regressions" Peter Rosin
2021-09-19  6:32   ` Peter Rosin
2021-09-22  7:06     ` Ahmad Fatoum
2021-09-22  7:41       ` Peter Rosin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e14fb2eb0ea344ac272b823c51ee3a4049a51c33.camel@pengutronix.de \
    --to=r.czerwinski@pengutronix.de \
    --cc=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    --cc=peda@axentia.se \
    --cc=s.hauer@pengutronix.de \
    --subject='Re: [PATCH 3/4] Revert "ARM: mmu: use client domain permissions to support ARMv7 eXecute Never"' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox