mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	barebox@lists.infradead.org
Subject: Re: [PATCH 2/4] arm: mmu: traverse reserved mem map as uncached
Date: Mon, 2 Nov 2020 11:19:52 +0100	[thread overview]
Message-ID: <961a3244-cd4d-a449-897f-6871e8b7f648@pengutronix.de> (raw)
In-Reply-To: <20201102093002.15851-2-r.czerwinski@pengutronix.de>

Hello,

On 11/2/20 10:30 AM, Rouven Czerwinski wrote:
> Traverse the reserved memory map and map areas which are marked with
> uncached as uncached (and thus noexec).
> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> ---
>  arch/arm/cpu/mmu.c | 14 ++++++++++++++
>  include/of.h       |  5 +++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
> index 6af228505d..5974e1e38a 100644
> --- a/arch/arm/cpu/mmu.c
> +++ b/arch/arm/cpu/mmu.c
> @@ -17,6 +17,7 @@
>  #include <memory.h>
>  #include <asm/system_info.h>
>  #include <asm/sections.h>
> +#include <of.h>
>  
>  #include "mmu.h"
>  
> @@ -393,6 +394,8 @@ static void vectors_init(void)
>  void __mmu_init(bool mmu_on)
>  {
>  	struct memory_bank *bank;
> +	struct of_reserve_map *res_map;
> +	int i;
>  
>  	arm_set_cache_functions();
>  
> @@ -453,6 +456,17 @@ void __mmu_init(bool mmu_on)
>  		__mmu_cache_flush();
>  	}
>  
> +	res_map = of_get_reserve_map();
> +	if (res_map) {
> +		for (i = 0; i < res_map->num_entries; i++) {
> +			if (res_map->uncached & BIT(i)) {
> +				create_sections(ttb, res_map->start[i],
> +						res_map->end[i],
> +						PMD_SECT_DEF_UNCACHED);

PMD_SECT_DEF_UNCACHED does _not_ include PMD_SECT_XN. See create_flat_mapping()
Also, code earlier does __mmu_cache_flush() after each create_sections.
Don't we need this here as well? (Or is it not needed at all?)

> +			}
> +		}
> +	}
> +
>  	__mmu_cache_on();
>  }
>  
> diff --git a/include/of.h b/include/of.h
> index 5d7f54fb36..3d8c26f319 100644
> --- a/include/of.h
> +++ b/include/of.h
> @@ -1042,6 +1042,11 @@ static inline int of_firmware_load_overlay(struct device_node *overlay, const ch
>  {
>  	return -ENOSYS;
>  }
> +
> +static inline struct of_reserve_map *of_get_reserve_map(void)
> +{
> +	return NULL;
> +}

This should results in an error because a static declaration follows a non-static
one. You need to move the extern of_get_reserve_map into the #ifdef as well.

>  #endif
>  
>  #endif /* __OF_H */
> 

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

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

  reply	other threads:[~2020-11-02 10:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02  9:29 [PATCH 1/4] of: reserve: add uncached flag mem entries Rouven Czerwinski
2020-11-02  9:30 ` [PATCH 2/4] arm: mmu: traverse reserved mem map as uncached Rouven Czerwinski
2020-11-02 10:19   ` Ahmad Fatoum [this message]
2020-11-02  9:30 ` [PATCH 3/4] mmu-early: remove OP-TEE from the MMU mapping Rouven Czerwinski
2020-11-02 10:22   ` Ahmad Fatoum
2020-11-02 10:36     ` Ahmad Fatoum
2020-11-02  9:30 ` [PATCH 4/4] start: reserve OP-TEE memory for PBL-OPTEE Rouven Czerwinski
2020-11-02 10:23   ` Ahmad Fatoum
2020-11-02 10:14 ` [PATCH 1/4] of: reserve: add uncached flag mem entries Ahmad Fatoum

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=961a3244-cd4d-a449-897f-6871e8b7f648@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=r.czerwinski@pengutronix.de \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox