diff --git a/include/common/bl_common.h b/include/common/bl_common.h index af598d0da9217471c2eede232b451de5c28e0142..2ecf281c00da15f43404afab85cb49039f3a6084 100644 --- a/include/common/bl_common.h +++ b/include/common/bl_common.h @@ -193,6 +193,11 @@ extern const char version_string[]; void print_entry_point_info(const entry_point_info_t *ep_info); uintptr_t page_align(uintptr_t value, unsigned dir); +struct mmap_region; + +void setup_page_tables(const struct mmap_region *bl_regions, + const struct mmap_region *plat_regions); + #endif /*__ASSEMBLY__*/ #endif /* __BL_COMMON_H__ */ diff --git a/include/lib/xlat_tables/xlat_tables_compat.h b/include/lib/xlat_tables/xlat_tables_compat.h new file mode 100644 index 0000000000000000000000000000000000000000..4650a8c6f41cce8321b298dea60aaeea5fec8f1c --- /dev/null +++ b/include/lib/xlat_tables/xlat_tables_compat.h @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#if XLAT_TABLES_LIB_V2 +#include <xlat_tables_v2.h> +#else +#include <xlat_tables.h> +#endif diff --git a/include/plat/arm/board/common/v2m_def.h b/include/plat/arm/board/common/v2m_def.h index 02c349418fd0eba9e19c976bb21619963bcd96e1..4a1d43c8501c49bfd2a2d61454e09632a6f3e2f9 100644 --- a/include/plat/arm/board/common/v2m_def.h +++ b/include/plat/arm/board/common/v2m_def.h @@ -6,8 +6,7 @@ #ifndef V2M_DEF_H #define V2M_DEF_H -#include <arm_xlat_tables.h> - +#include <xlat_tables_compat.h> /* V2M motherboard system registers & offsets */ #define V2M_SYSREGS_BASE UL(0x1c010000) diff --git a/include/plat/arm/common/arm_xlat_tables.h b/include/plat/arm/common/arm_xlat_tables.h deleted file mode 100644 index 0923ad8a1a06932a1c65740dfa8f043c96bf08ed..0000000000000000000000000000000000000000 --- a/include/plat/arm/common/arm_xlat_tables.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#if ARM_XLAT_TABLES_LIB_V1 -#include <xlat_tables.h> -#else -#include <xlat_tables_v2.h> -#endif /* ARM_XLAT_TABLES_LIB_V1 */ diff --git a/include/plat/arm/common/plat_arm.h b/include/plat/arm/common/plat_arm.h index 773c3603e92d366e3963193bf666c32258302a43..bdcb1441540e6ed138fb904f092a14ae14a069cd 100644 --- a/include/plat/arm/common/plat_arm.h +++ b/include/plat/arm/common/plat_arm.h @@ -6,7 +6,6 @@ #ifndef __PLAT_ARM_H__ #define __PLAT_ARM_H__ -#include <arm_xlat_tables.h> #include <bakery_lock.h> #include <cassert.h> #include <cpu_data.h> @@ -14,6 +13,7 @@ #include <spinlock.h> #include <tzc_common.h> #include <utils_def.h> +#include <xlat_tables_compat.h> /******************************************************************************* * Forward declarations @@ -66,12 +66,6 @@ typedef struct arm_tzc_regions_info { <= MAX_MMAP_REGIONS, \ assert_max_mmap_regions); -/* - * Utility functions common to ARM standard platforms - */ -void arm_setup_page_tables(const mmap_region_t bl_regions[], - const mmap_region_t plat_regions[]); - void arm_setup_romlib(void); #if defined(IMAGE_BL31) || (defined(AARCH32) && defined(IMAGE_BL32)) diff --git a/lib/xlat_tables_v2/xlat_tables.mk b/lib/xlat_tables_v2/xlat_tables.mk index 9507ad7155f92a263e6155bb500de688f7a251e5..c946315bf8294d6454d9b0343dd57dc66fe58055 100644 --- a/lib/xlat_tables_v2/xlat_tables.mk +++ b/lib/xlat_tables_v2/xlat_tables.mk @@ -10,3 +10,6 @@ XLAT_TABLES_LIB_SRCS := $(addprefix lib/xlat_tables_v2/, \ xlat_tables_context.c \ xlat_tables_core.c \ xlat_tables_utils.c) + +XLAT_TABLES_LIB_V2 := 1 +$(eval $(call add_define,XLAT_TABLES_LIB_V2)) diff --git a/plat/arm/board/fvp/fvp_common.c b/plat/arm/board/fvp/fvp_common.c index aa4f8398de776581d3a2e42e19704a2e3164e785..f5198f68678824c1ea19d6a99ea7f49f159dfd4a 100644 --- a/plat/arm/board/fvp/fvp_common.c +++ b/plat/arm/board/fvp/fvp_common.c @@ -7,7 +7,6 @@ #include <arm_config.h> #include <arm_def.h> #include <arm_spm_def.h> -#include <arm_xlat_tables.h> #include <assert.h> #include <cci.h> #include <ccn.h> @@ -18,6 +17,8 @@ #include <platform.h> #include <secure_partition.h> #include <v2m_def.h> +#include <xlat_tables_compat.h> + #include "../fvp_def.h" #include "fvp_private.h" @@ -52,8 +53,8 @@ arm_config_t arm_config; /* * Table of memory regions for various BL stages to map using the MMU. - * This doesn't include Trusted SRAM as arm_setup_page_tables() already - * takes care of mapping it. + * This doesn't include Trusted SRAM as setup_page_tables() already takes care + * of mapping it. * * The flash needs to be mapped as writable in order to erase the FIP's Table of * Contents in case of unrecoverable error (see plat_error_handler()). diff --git a/plat/arm/board/juno/juno_common.c b/plat/arm/board/juno/juno_common.c index 40b1a275af6e08a29047dbcc3523eced777df5bc..2e6b01134f7dc6e55bbe4bcde0397e55d895243e 100644 --- a/plat/arm/board/juno/juno_common.c +++ b/plat/arm/board/juno/juno_common.c @@ -8,8 +8,8 @@ /* * Table of memory regions for different BL stages to map using the MMU. - * This doesn't include Trusted SRAM as arm_setup_page_tables() already - * takes care of mapping it. + * This doesn't include Trusted SRAM as setup_page_tables() already takes care + * of mapping it. */ #ifdef IMAGE_BL1 const mmap_region_t plat_arm_mmap[] = { diff --git a/plat/arm/common/arm_bl1_setup.c b/plat/arm/common/arm_bl1_setup.c index 717e96f8548bc8b2d3d8a60918c41b7d53c6fc0e..f760e18dceb8ae86266b7bbbad8324e828556ef9 100644 --- a/plat/arm/common/arm_bl1_setup.c +++ b/plat/arm/common/arm_bl1_setup.c @@ -6,7 +6,6 @@ #include <arch.h> #include <arm_def.h> -#include <arm_xlat_tables.h> #include <assert.h> #include <bl1.h> #include <bl_common.h> @@ -15,6 +14,8 @@ #include <platform_def.h> #include <sp805.h> #include <utils.h> +#include <xlat_tables_compat.h> + #include "../../../bl1/bl1_private.h" /* Weak definitions may be overridden in specific ARM standard platform */ @@ -122,7 +123,7 @@ void arm_bl1_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); #ifdef AARCH32 enable_mmu_svc_mon(0); #else diff --git a/plat/arm/common/arm_bl2_el3_setup.c b/plat/arm/common/arm_bl2_el3_setup.c index c67ab4914271ce60d67300041001cf9eb0ee6c4e..4f5e6a9e6e2794add41ef0cbd934c2db5dfc5c11 100644 --- a/plat/arm/common/arm_bl2_el3_setup.c +++ b/plat/arm/common/arm_bl2_el3_setup.c @@ -79,7 +79,7 @@ void arm_bl2_el3_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); #ifdef AARCH32 enable_mmu_svc_mon(0); diff --git a/plat/arm/common/arm_bl2_setup.c b/plat/arm/common/arm_bl2_setup.c index d31f6dc3c75f332a5e0ea06b7d7a4598e4ea8538..628a50def42c136b85816d06c5700e03eb8ba1fb 100644 --- a/plat/arm/common/arm_bl2_setup.c +++ b/plat/arm/common/arm_bl2_setup.c @@ -125,7 +125,7 @@ void arm_bl2_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); #ifdef AARCH32 enable_mmu_svc_mon(0); diff --git a/plat/arm/common/arm_bl2u_setup.c b/plat/arm/common/arm_bl2u_setup.c index b518f0f62fec0a10472cdc4d8f19aacf7711cd38..3848aa065d8b80a671562f8ecf4efe7efbd3d181 100644 --- a/plat/arm/common/arm_bl2u_setup.c +++ b/plat/arm/common/arm_bl2u_setup.c @@ -80,7 +80,7 @@ void arm_bl2u_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); #ifdef AARCH32 enable_mmu_svc_mon(0); diff --git a/plat/arm/common/arm_bl31_setup.c b/plat/arm/common/arm_bl31_setup.c index e218c2f0593cfc677bb23139ce59a3cca6386f44..24d55709545fd43dc2f1a6d8602e2ca83efea3b7 100644 --- a/plat/arm/common/arm_bl31_setup.c +++ b/plat/arm/common/arm_bl31_setup.c @@ -16,7 +16,7 @@ #include <platform.h> #include <ras.h> #include <utils.h> -#include <arm_xlat_tables.h> +#include <xlat_tables_compat.h> /* * Placeholder variables for copying the arguments that have been passed to @@ -302,7 +302,7 @@ void __init arm_bl31_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); enable_mmu_el3(0); diff --git a/plat/arm/common/arm_common.c b/plat/arm/common/arm_common.c index a21d189e9b7606df65f68a2f62a7cfa0698ed0f6..6b1478545371765e4097e526f2ecec1d1ac41f7f 100644 --- a/plat/arm/common/arm_common.c +++ b/plat/arm/common/arm_common.c @@ -5,7 +5,6 @@ */ #include <arch.h> #include <arch_helpers.h> -#include <arm_xlat_tables.h> #include <assert.h> #include <debug.h> #include <mmio.h> @@ -14,6 +13,7 @@ #include <platform_def.h> #include <romlib.h> #include <secure_partition.h> +#include <xlat_tables_compat.h> /* Weak definitions may be overridden in specific ARM standard platform */ #pragma weak plat_get_ns_image_entrypoint @@ -32,42 +32,6 @@ void arm_setup_romlib(void) #endif } -/* - * Set up the page tables for the generic and platform-specific memory regions. - * The size of the Trusted SRAM seen by the BL image must be specified as well - * as an array specifying the generic memory regions which can be; - * - Code section; - * - Read-only data section; - * - Init code section, if applicable - * - Coherent memory region, if applicable. - */ - -void __init arm_setup_page_tables(const mmap_region_t bl_regions[], - const mmap_region_t plat_regions[]) -{ -#if LOG_LEVEL >= LOG_LEVEL_VERBOSE - const mmap_region_t *regions = bl_regions; - - while (regions->size != 0U) { - VERBOSE("Region: 0x%lx - 0x%lx has attributes 0x%x\n", - regions->base_va, - (regions->base_va + regions->size), - regions->attr); - regions++; - } -#endif - /* - * Map the Trusted SRAM with appropriate memory attributes. - * Subsequent mappings will adjust the attributes for specific regions. - */ - mmap_add(bl_regions); - /* Now (re-)map the platform-specific memory regions */ - mmap_add(plat_regions); - - /* Create the page tables to reflect the above mappings */ - init_xlat_tables(); -} - uintptr_t plat_get_ns_image_entrypoint(void) { #ifdef PRELOADED_BL33_BASE diff --git a/plat/arm/common/sp_min/arm_sp_min_setup.c b/plat/arm/common/sp_min/arm_sp_min_setup.c index b8234c186190a99cfe3b55532b7e38abdc57ca11..e151073f7c6aa6223792877827d4202a261e109c 100644 --- a/plat/arm/common/sp_min/arm_sp_min_setup.c +++ b/plat/arm/common/sp_min/arm_sp_min_setup.c @@ -208,7 +208,7 @@ void sp_min_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); enable_mmu_svc_mon(0); } diff --git a/plat/arm/common/tsp/arm_tsp_setup.c b/plat/arm/common/tsp/arm_tsp_setup.c index 2d42d8e00be77b57c6492798e8a93a08f4e1469b..3cf88251f1fb2e4292fcb343de4e6437b6ac84a2 100644 --- a/plat/arm/common/tsp/arm_tsp_setup.c +++ b/plat/arm/common/tsp/arm_tsp_setup.c @@ -85,6 +85,6 @@ void tsp_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); enable_mmu_el1(0); } diff --git a/plat/common/plat_bl_common.c b/plat/common/plat_bl_common.c index 264d5180d3a3c58e64d769f2975e93e72275ad13..4cf1cc57355d83fc1f95d80f2ad1077da3346e08 100644 --- a/plat/common/plat_bl_common.c +++ b/plat/common/plat_bl_common.c @@ -13,6 +13,7 @@ #include <mbedtls_config.h> #endif #include <platform.h> +#include <xlat_tables_compat.h> /* * The following platform functions are weakly defined. The Platforms @@ -72,3 +73,40 @@ int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) return 0; } #endif /* TRUSTED_BOARD_BOOT */ + +/* + * Set up the page tables for the generic and platform-specific memory regions. + * The size of the Trusted SRAM seen by the BL image must be specified as well + * as an array specifying the generic memory regions which can be; + * - Code section; + * - Read-only data section; + * - Init code section, if applicable + * - Coherent memory region, if applicable. + */ + +void __init setup_page_tables(const mmap_region_t *bl_regions, + const mmap_region_t *plat_regions) +{ +#if LOG_LEVEL >= LOG_LEVEL_VERBOSE + const mmap_region_t *regions = bl_regions; + + while (regions->size != 0U) { + VERBOSE("Region: 0x%lx - 0x%lx has attributes 0x%x\n", + regions->base_va, + regions->base_va + regions->size, + regions->attr); + regions++; + } +#endif + /* + * Map the Trusted SRAM with appropriate memory attributes. + * Subsequent mappings will adjust the attributes for specific regions. + */ + mmap_add(bl_regions); + + /* Now (re-)map the platform-specific memory regions */ + mmap_add(plat_regions); + + /* Create the page tables to reflect the above mappings */ + init_xlat_tables(); +} diff --git a/plat/qemu/platform.mk b/plat/qemu/platform.mk index 9167c9fcf840ae5f90bf2f0e41e700571d30469d..982886a9330283b04b62aa6682f5040c0f9afbc6 100644 --- a/plat/qemu/platform.mk +++ b/plat/qemu/platform.mk @@ -38,24 +38,12 @@ ifeq (${ARM_ARCH_MAJOR},8) PLAT_INCLUDES += -Iinclude/plat/arm/common/${ARCH} endif -# Use translation tables library v2 by default -ARM_XLAT_TABLES_LIB_V1 := 0 -$(eval $(call assert_boolean,ARM_XLAT_TABLES_LIB_V1)) -$(eval $(call add_define,ARM_XLAT_TABLES_LIB_V1)) - - PLAT_BL_COMMON_SOURCES := plat/qemu/qemu_common.c \ plat/qemu/qemu_console.c \ drivers/arm/pl011/${ARCH}/pl011_console.S \ -ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) -PLAT_BL_COMMON_SOURCES += lib/xlat_tables/xlat_tables_common.c \ - lib/xlat_tables/${ARCH}/xlat_tables.c -else include lib/xlat_tables_v2/xlat_tables.mk - PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS} -endif ifneq (${TRUSTED_BOARD_BOOT},0) diff --git a/plat/qemu/qemu_common.c b/plat/qemu/qemu_common.c index 376ff2f1151e2bf195b097a2fd723c590a8c49da..43a3f7012b48ee9f6f6c835f9c2fcc2573dec7bf 100644 --- a/plat/qemu/qemu_common.c +++ b/plat/qemu/qemu_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,7 +7,8 @@ #include <arch_helpers.h> #include <bl_common.h> #include <platform_def.h> -#include <arm_xlat_tables.h> +#include <xlat_tables_v2.h> + #include "qemu_private.h" #define MAP_DEVICE0 MAP_REGION_FLAT(DEVICE0_BASE, \ diff --git a/plat/ti/k3/common/k3_bl31_setup.c b/plat/ti/k3/common/k3_bl31_setup.c index f84b9d4490d187383a065ad908533d4929cb18f6..e438dc36c69d2957770cb502c7e90cba6e4a05df 100644 --- a/plat/ti/k3/common/k3_bl31_setup.c +++ b/plat/ti/k3/common/k3_bl31_setup.c @@ -108,7 +108,7 @@ void bl31_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); enable_mmu_el3(0); } diff --git a/plat/xilinx/zynqmp/bl31_zynqmp_setup.c b/plat/xilinx/zynqmp/bl31_zynqmp_setup.c index a14388f56a147f10652d7a782ae5d2bf8e862be9..01634500aff0d06c974da8447c97d368b7c6cabe 100644 --- a/plat/xilinx/zynqmp/bl31_zynqmp_setup.c +++ b/plat/xilinx/zynqmp/bl31_zynqmp_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -193,6 +193,6 @@ void bl31_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); enable_mmu_el3(0); } diff --git a/plat/xilinx/zynqmp/platform.mk b/plat/xilinx/zynqmp/platform.mk index 33859ee5edc748cf41899740b1bc0dd2f4bf9972..35c8983cdb1928a0a3629f1cfd2ad905b2f7d74f 100644 --- a/plat/xilinx/zynqmp/platform.mk +++ b/plat/xilinx/zynqmp/platform.mk @@ -16,10 +16,6 @@ ENABLE_SVE_FOR_NS := 0 WORKAROUND_CVE_2017_5715 := 0 -ARM_XLAT_TABLES_LIB_V1 := 1 -$(eval $(call assert_boolean,ARM_XLAT_TABLES_LIB_V1)) -$(eval $(call add_define,ARM_XLAT_TABLES_LIB_V1)) - ifdef ZYNQMP_ATF_MEM_BASE $(eval $(call add_define,ZYNQMP_ATF_MEM_BASE)) diff --git a/plat/xilinx/zynqmp/tsp/tsp_plat_setup.c b/plat/xilinx/zynqmp/tsp/tsp_plat_setup.c index 52d4bf8cc335fd625b7f333fc6559d45c1e18011..a27f34b45b8af924b8130a449e89646ac0ba6bea 100644 --- a/plat/xilinx/zynqmp/tsp/tsp_plat_setup.c +++ b/plat/xilinx/zynqmp/tsp/tsp_plat_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -57,6 +57,6 @@ void tsp_plat_arch_setup(void) {0} }; - arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); + setup_page_tables(bl_regions, plat_arm_get_mmap()); enable_mmu_el1(0); }