summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@foss.st.com>2021-02-05 13:53:32 +0100
committerTom Rini <trini@konsulko.com>2021-03-02 15:53:37 -0500
commit1419e5b5167e6ff35882473b81741d0815c453ea (patch)
treec1bbeee7457b47ffbe2f3ee4f802cfe8c61db362
parent35b65dd8ef3d37a088ee9169763a4d891aed618d (diff)
downloadu-boot-1419e5b5167e6ff35882473b81741d0815c453ea.tar.gz
stm32mp: update MMU config before the relocation
Mark the top of ram, used for relocated U-Boot as a normal memory (cacheable and executable) to avoid permission access issue when U-Boot jumps to this relocated code. When MMU is activated in pre-reloc stage; only the beginning of DDR is marked executable. This patch avoids access issue when DACR is correctly managed. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
-rw-r--r--arch/arm/mach-stm32mp/dram_init.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c
index ad6977fd44..66e81bacca 100644
--- a/arch/arm/mach-stm32mp/dram_init.c
+++ b/arch/arm/mach-stm32mp/dram_init.c
@@ -13,6 +13,7 @@
#include <log.h>
#include <ram.h>
#include <asm/global_data.h>
+#include <asm/system.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -41,6 +42,7 @@ int dram_init(void)
ulong board_get_usable_ram_top(ulong total_size)
{
+ phys_size_t size;
phys_addr_t reg;
struct lmb lmb;
@@ -48,10 +50,13 @@ ulong board_get_usable_ram_top(ulong total_size)
lmb_init(&lmb);
lmb_add(&lmb, gd->ram_base, gd->ram_size);
boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
- reg = lmb_alloc(&lmb, CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K);
+ size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE),
+ reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE);
- if (reg)
- return ALIGN(reg + CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K);
+ if (!reg)
+ reg = gd->ram_top - size;
- return gd->ram_top;
+ mmu_set_region_dcache_behaviour(reg, size, DCACHE_DEFAULT_OPTION);
+
+ return reg + size;
}