From ddb4c9e04cc5849dc035c9db382fc2d113df928f Mon Sep 17 00:00:00 2001 From: Samuel Holland <samuel@sholland.org> Date: Sun, 27 Oct 2019 17:30:15 -0500 Subject: [PATCH] allwinner: Clean up MMU setup Remove the general BL31 mmap region: it duplicates the existing static mapping for the entire SRAM region. Use the helper definitions when applicable to simplify the code and add the MT_EXECUTE_NEVER flag. Signed-off-by: Samuel Holland <samuel@sholland.org> Change-Id: I7a6b79e50e4b5c698774229530dd3d2a89e94a6d --- plat/allwinner/common/include/platform_def.h | 2 +- plat/allwinner/common/sunxi_common.c | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/plat/allwinner/common/include/platform_def.h b/plat/allwinner/common/include/platform_def.h index 0a0007667..4de8b0bc4 100644 --- a/plat/allwinner/common/include/platform_def.h +++ b/plat/allwinner/common/include/platform_def.h @@ -32,7 +32,7 @@ #define CACHE_WRITEBACK_SHIFT 6 #define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT) -#define MAX_MMAP_REGIONS (4 + PLATFORM_MMAP_REGIONS) +#define MAX_MMAP_REGIONS (3 + PLATFORM_MMAP_REGIONS) #define MAX_XLAT_TABLES 1 #define PLAT_MAX_PWR_LVL_STATES U(2) diff --git a/plat/allwinner/common/sunxi_common.c b/plat/allwinner/common/sunxi_common.c index cff826819..3759c285e 100644 --- a/plat/allwinner/common/sunxi_common.c +++ b/plat/allwinner/common/sunxi_common.c @@ -20,15 +20,15 @@ static const mmap_region_t sunxi_mmap[PLATFORM_MMAP_REGIONS + 1] = { MAP_REGION_FLAT(SUNXI_SRAM_BASE, SUNXI_SRAM_SIZE, - MT_MEMORY | MT_RW | MT_SECURE), + MT_RW_DATA | MT_SECURE), MAP_REGION_FLAT(SUNXI_DEV_BASE, SUNXI_DEV_SIZE, - MT_DEVICE | MT_RW | MT_SECURE), + MT_DEVICE | MT_RW | MT_SECURE | MT_EXECUTE_NEVER), MAP_REGION(SUNXI_DRAM_BASE, SUNXI_DRAM_VIRT_BASE, SUNXI_DRAM_SEC_SIZE, - MT_MEMORY | MT_RW | MT_SECURE), + MT_RW_DATA | MT_SECURE), MAP_REGION(PLAT_SUNXI_NS_IMAGE_OFFSET, SUNXI_DRAM_VIRT_BASE + SUNXI_DRAM_SEC_SIZE, SUNXI_DRAM_MAP_SIZE, - MT_MEMORY | MT_RO | MT_NS), + MT_RO_DATA | MT_NS), {}, }; @@ -48,9 +48,6 @@ uintptr_t plat_get_ns_image_entrypoint(void) void sunxi_configure_mmu_el3(int flags) { - mmap_add_region(BL31_BASE, BL31_BASE, - BL31_LIMIT - BL31_BASE, - MT_MEMORY | MT_RW | MT_SECURE); mmap_add_region(BL_CODE_BASE, BL_CODE_BASE, BL_CODE_END - BL_CODE_BASE, MT_CODE | MT_SECURE); -- GitLab