]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mach-k3: enable mmu after reserved memory is unmapped
authorAnshul Dalal <anshuld@ti.com>
Wed, 20 May 2026 02:51:50 +0000 (08:21 +0530)
committerTom Rini <trini@konsulko.com>
Mon, 25 May 2026 15:29:50 +0000 (09:29 -0600)
Currently the sequence to enable caches for the A53/A72 core on K3
devices looks as follows:

 1. Map entire DDR banks
 2. Setup page tables (done by mmu_setup)
 3. Enable MMU
 4. Unmap reserved-memory regions
 5. Enable caches

However there is a brief period of execution between #3 and #4 where the
core can issue speculative accesses to the entire DDR space (including
the reserved-memory regions) despite the caches being disabled.

A firewall exception is triggered whenever such speculative access is
made to secure DDR region of TFA or OP-TEE. This patch fixes the issue
by re-ordering the sequence as follows:

 1. Map entire DDR banks
 2. Setup page tables
 3. Unmap reserved-memory regions
 4. Enable MMU
 5. Enable caches

Fixes: f1c694b8fdde ("mach-k3: map all banks using mem_map_from_dram_banks")
Reported-by: Suhaas Joshi <s-joshi@ti.com>
Signed-off-by: Anshul Dalal <anshuld@ti.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
arch/arm/mach-k3/common.c

index 396018b7a7aec5a1d9ee7017153c220520e9c0d4..19a6e24f38b206a4f288043f696cd687868c376e 100644 (file)
@@ -279,7 +279,6 @@ void enable_caches(void)
                       __func__, fdt_strerror(ret));
 
        mmu_setup();
-       mmu_enable();
 
        if (CONFIG_K3_ATF_LOAD_ADDR >= CFG_SYS_SDRAM_BASE) {
                ret = mmu_unmap_reserved_mem("tfa", true);
@@ -295,6 +294,7 @@ void enable_caches(void)
                               __func__, ret);
        }
 
+       mmu_enable();
        icache_enable();
        dcache_enable();
 }