diff options
author | Sathees Balya <sathees.balya@arm.com> | 2019-01-25 11:36:01 +0000 |
---|---|---|
committer | Sathees Balya <sathees.balya@arm.com> | 2019-01-30 11:17:38 +0000 |
commit | cedfa04ba58841b5c547b409e435c0bdafa4c912 (patch) | |
tree | f7de45c25aed76ee15d2ee3930e3bbdeb624fd65 /lib | |
parent | 83a2285ec8d5e4bdbf12481b441489eed5bb6018 (diff) | |
download | platform_external_arm-trusted-firmware-cedfa04ba58841b5c547b409e435c0bdafa4c912.tar.gz platform_external_arm-trusted-firmware-cedfa04ba58841b5c547b409e435c0bdafa4c912.tar.bz2 platform_external_arm-trusted-firmware-cedfa04ba58841b5c547b409e435c0bdafa4c912.zip |
lib/xlat_tables: Add support for ARMv8.4-TTST
ARMv8.4-TTST (Small Translation tables) relaxes the lower limit on the
size of translation tables by increasing the maximum permitted value
of the T1SZ and T0SZ fields in TCR_EL1, TCR_EL2, TCR_EL3, VTCR_EL2 and
VSTCR_EL2.
This feature is supported in AArch64 state only.
This patch adds support for this feature to both versions of the
translation tables library. It also removes the static build time
checks for virtual address space size checks to runtime assertions.
Change-Id: I4e8cebc197ec1c2092dc7d307486616786e6c093
Signed-off-by: Sathees Balya <sathees.balya@arm.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xlat_tables/aarch32/xlat_tables.c | 5 | ||||
-rw-r--r-- | lib/xlat_tables/aarch64/xlat_tables.c | 23 | ||||
-rw-r--r-- | lib/xlat_tables/xlat_tables_private.h | 3 | ||||
-rw-r--r-- | lib/xlat_tables_v2/aarch32/xlat_tables_arch.c | 15 | ||||
-rw-r--r-- | lib/xlat_tables_v2/aarch64/xlat_tables_arch.c | 21 | ||||
-rw-r--r-- | lib/xlat_tables_v2/xlat_tables_core.c | 5 | ||||
-rw-r--r-- | lib/xlat_tables_v2/xlat_tables_private.h | 5 |
7 files changed, 71 insertions, 6 deletions
diff --git a/lib/xlat_tables/aarch32/xlat_tables.c b/lib/xlat_tables/aarch32/xlat_tables.c index 468a9e7dd..4b01b9b7a 100644 --- a/lib/xlat_tables/aarch32/xlat_tables.c +++ b/lib/xlat_tables/aarch32/xlat_tables.c @@ -55,6 +55,11 @@ void init_xlat_tables(void) { unsigned long long max_pa; uintptr_t max_va; + + assert(PLAT_VIRT_ADDR_SPACE_SIZE >= MIN_VIRT_ADDR_SPACE_SIZE); + assert(PLAT_VIRT_ADDR_SPACE_SIZE <= MAX_VIRT_ADDR_SPACE_SIZE); + assert(IS_POWER_OF_TWO(PLAT_VIRT_ADDR_SPACE_SIZE)); + print_mmap(); init_xlation_table(0U, base_xlation_table, XLAT_TABLE_LEVEL_BASE, &max_va, &max_pa); diff --git a/lib/xlat_tables/aarch64/xlat_tables.c b/lib/xlat_tables/aarch64/xlat_tables.c index 71f491a21..e64fd3ef7 100644 --- a/lib/xlat_tables/aarch64/xlat_tables.c +++ b/lib/xlat_tables/aarch64/xlat_tables.c @@ -10,7 +10,7 @@ #include <platform_def.h> #include <arch.h> -#include <arch_helpers.h> +#include <arch_features.h> #include <common/bl_common.h> #include <lib/utils.h> #include <lib/xlat_tables/xlat_tables.h> @@ -79,6 +79,21 @@ static unsigned long long get_max_supported_pa(void) return (1ULL << pa_range_bits_arr[pa_range]) - 1ULL; } + +/* + * Return minimum virtual address space size supported by the architecture + */ +static uintptr_t xlat_get_min_virt_addr_space_size(void) +{ + uintptr_t ret; + + if (is_armv8_4_ttst_present()) + ret = MIN_VIRT_ADDR_SPACE_SIZE_TTST; + else + ret = MIN_VIRT_ADDR_SPACE_SIZE; + + return ret; +} #endif /* ENABLE_ASSERTIONS */ unsigned int xlat_arch_current_el(void) @@ -104,6 +119,12 @@ void init_xlat_tables(void) { unsigned long long max_pa; uintptr_t max_va; + + assert(PLAT_VIRT_ADDR_SPACE_SIZE >= + (xlat_get_min_virt_addr_space_size() - 1U)); + assert(PLAT_VIRT_ADDR_SPACE_SIZE <= MAX_VIRT_ADDR_SPACE_SIZE); + assert(IS_POWER_OF_TWO(PLAT_VIRT_ADDR_SPACE_SIZE)); + print_mmap(); init_xlation_table(0U, base_xlation_table, XLAT_TABLE_LEVEL_BASE, &max_va, &max_pa); diff --git a/lib/xlat_tables/xlat_tables_private.h b/lib/xlat_tables/xlat_tables_private.h index 4390f34ea..82bc70cd0 100644 --- a/lib/xlat_tables/xlat_tables_private.h +++ b/lib/xlat_tables/xlat_tables_private.h @@ -16,9 +16,6 @@ #error xlat tables v2 must be used with HW_ASSISTED_COHERENCY #endif -CASSERT(CHECK_VIRT_ADDR_SPACE_SIZE(PLAT_VIRT_ADDR_SPACE_SIZE), - assert_valid_virt_addr_space_size); - CASSERT(CHECK_PHY_ADDR_SPACE_SIZE(PLAT_PHY_ADDR_SPACE_SIZE), assert_valid_phy_addr_space_size); diff --git a/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c b/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c index 913c86d39..b69c6702b 100644 --- a/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c +++ b/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c @@ -45,6 +45,14 @@ unsigned long long xlat_arch_get_max_supported_pa(void) /* Physical address space size for long descriptor format. */ return (1ULL << 40) - 1ULL; } + +/* + * Return minimum virtual address space size supported by the architecture + */ +uintptr_t xlat_get_min_virt_addr_space_size(void) +{ + return MIN_VIRT_ADDR_SPACE_SIZE; +} #endif /* ENABLE_ASSERTIONS*/ bool is_mmu_enabled_ctx(const xlat_ctx_t *ctx) @@ -193,7 +201,12 @@ void setup_mmu_cfg(uint64_t *params, unsigned int flags, if (max_va != UINT32_MAX) { uintptr_t virtual_addr_space_size = max_va + 1U; - assert(CHECK_VIRT_ADDR_SPACE_SIZE(virtual_addr_space_size)); + assert(virtual_addr_space_size >= + xlat_get_min_virt_addr_space_size()); + assert(virtual_addr_space_size <= + MAX_VIRT_ADDR_SPACE_SIZE); + assert(IS_POWER_OF_TWO(virtual_addr_space_size)); + /* * __builtin_ctzll(0) is undefined but here we are guaranteed * that virtual_addr_space_size is in the range [1, UINT32_MAX]. diff --git a/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c b/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c index 228f75147..e7593dde7 100644 --- a/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c +++ b/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c @@ -101,6 +101,21 @@ unsigned long long xlat_arch_get_max_supported_pa(void) return (1ULL << pa_range_bits_arr[pa_range]) - 1ULL; } + +/* + * Return minimum virtual address space size supported by the architecture + */ +uintptr_t xlat_get_min_virt_addr_space_size(void) +{ + uintptr_t ret; + + if (is_armv8_4_ttst_present()) + ret = MIN_VIRT_ADDR_SPACE_SIZE_TTST; + else + ret = MIN_VIRT_ADDR_SPACE_SIZE; + + return ret; +} #endif /* ENABLE_ASSERTIONS*/ bool is_mmu_enabled_ctx(const xlat_ctx_t *ctx) @@ -221,7 +236,11 @@ void setup_mmu_cfg(uint64_t *params, unsigned int flags, assert(max_va < ((uint64_t)UINTPTR_MAX)); virtual_addr_space_size = (uintptr_t)max_va + 1U; - assert(CHECK_VIRT_ADDR_SPACE_SIZE(virtual_addr_space_size)); + + assert(virtual_addr_space_size >= + xlat_get_min_virt_addr_space_size()); + assert(virtual_addr_space_size <= MAX_VIRT_ADDR_SPACE_SIZE); + assert(IS_POWER_OF_TWO(virtual_addr_space_size)); /* * __builtin_ctzll(0) is undefined but here we are guaranteed that diff --git a/lib/xlat_tables_v2/xlat_tables_core.c b/lib/xlat_tables_v2/xlat_tables_core.c index c49554f1f..4820b4f80 100644 --- a/lib/xlat_tables_v2/xlat_tables_core.c +++ b/lib/xlat_tables_v2/xlat_tables_core.c @@ -1146,6 +1146,11 @@ void __init init_xlat_tables_ctx(xlat_ctx_t *ctx) mmap_region_t *mm = ctx->mmap; + assert(ctx->va_max_address >= + (xlat_get_min_virt_addr_space_size() - 1U)); + assert(ctx->va_max_address <= (MAX_VIRT_ADDR_SPACE_SIZE - 1U)); + assert(IS_POWER_OF_TWO(ctx->va_max_address + 1U)); + xlat_mmap_print(mm); /* All tables must be zeroed before mapping any region. */ diff --git a/lib/xlat_tables_v2/xlat_tables_private.h b/lib/xlat_tables_v2/xlat_tables_private.h index fc709554b..70ef39523 100644 --- a/lib/xlat_tables_v2/xlat_tables_private.h +++ b/lib/xlat_tables_v2/xlat_tables_private.h @@ -102,4 +102,9 @@ bool is_mmu_enabled_ctx(const xlat_ctx_t *ctx); /* Returns true if the data cache is enabled at the current EL. */ bool is_dcache_enabled(void); +/* + * Returns minimum virtual address space size supported by the architecture + */ +uintptr_t xlat_get_min_virt_addr_space_size(void); + #endif /* XLAT_TABLES_PRIVATE_H */ |