arm64: mmu: invalidate all data caches before enable them

Datas in data cache are dirty before data caches are enabled,
so need to invalidate all data caches firstly before enable
them.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
This commit is contained in:
Jiafei Pan 2021-04-23 14:13:58 +08:00 committed by Carles Cufí
commit a89cb1cc13

View file

@ -7,6 +7,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <cache.h>
#include <device.h>
#include <init.h>
#include <kernel.h>
@ -762,6 +763,9 @@ static void enable_mmu_el1(struct arm_mmu_ptables *ptables, unsigned int flags)
/* Ensure these changes are seen before MMU is enabled */
isb();
/* Invalidate all data caches before enable them */
sys_dcache_all(K_CACHE_INVD);
/* Enable the MMU and data cache */
val = read_sctlr_el1();
write_sctlr_el1(val | SCTLR_M_BIT | SCTLR_C_BIT);