[PATCH v2 7/8] ARM: mmu-early: map no-map entries XN & uncached
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Aug 5 07:24:28 PDT 2021
On 03.08.21 11:44, Rouven Czerwinski wrote:
> Ensure that reserved map entries with the no-map flag are marked as
> uncached and non-execute during the early MMU initialization.
>
> Signed-off-by: Rouven Czerwinski <r.czerwinski at pengutronix.de>
> ---
> arch/arm/cpu/mmu-early.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/arch/arm/cpu/mmu-early.c b/arch/arm/cpu/mmu-early.c
> index b985aa455f..9c3f01326b 100644
> --- a/arch/arm/cpu/mmu-early.c
> +++ b/arch/arm/cpu/mmu-early.c
> @@ -3,9 +3,11 @@
> #include <errno.h>
> #include <linux/sizes.h>
> #include <asm/memory.h>
> +#include <asm-generic/memory_layout.h>
> #include <asm/system.h>
> #include <asm/cache.h>
> #include <asm-generic/sections.h>
> +#include <pbl.h>
>
> #include "mmu.h"
>
> @@ -24,7 +26,10 @@ static inline void map_region(unsigned long start, unsigned long size,
> void mmu_early_enable(unsigned long membase, unsigned long memsize,
> unsigned long _ttb)
> {
> + const struct pbl_reserved_memory *res_mem;
> + int i;
> ttb = (uint32_t *)_ttb;
> + res_mem = get_pbl_reserved_memory();
Nitpick: could've been a single line.
>
> arm_set_cache_functions();
>
> @@ -58,6 +63,14 @@ void mmu_early_enable(unsigned long membase, unsigned long memsize,
> /* maps main memory as cachable */
> map_region(membase, memsize, PMD_SECT_DEF_CACHED);
>
> + for (i = 0; i < get_pbl_reserved_memory_num(); i++) {
> + if (res_mem->flags & FDT_RES_MEM_FLAG_NOMAP)
> + map_region(res_mem->base, res_mem->size,
> + PMD_SECT_DEF_UNCACHED | PMD_SECT_XN);
> + res_mem++;
> + }
> +
> +
Looks good:
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> /*
> * 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.
Would be nice to make this HAB exception just an entry in the reserved map,
but that's out of scope for this patch.
Cheers,
Ahmad
--
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 |
More information about the barebox
mailing list