aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2019-03-27 13:04:46 +0000
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2019-04-03 10:51:31 +0100
commit014df18b8e6cc2e6accb8230b950d7f3263f497a (patch)
tree32475a0885408b8b688d7a5987ffc011c782394c /services
parent6de6965b2fcaffec01b2679118d16eabfde4d9c9 (diff)
downloadtrusted-firmware-a-014df18b8e6cc2e6accb8230b950d7f3263f497a.tar.gz
SPM: Refactor xlat context creation
Right now the virtual address space is fixed to PLAT_VIRT_ADDR_SPACE_SIZE, so all base translation tables are the same size and need the same alignment. The current code allocates the exact space needed by this initial table. However, a following patch is going to allow each partition to choose the size of its address space based on the memory regions defined in their resource description, so it isn't possible to determine this at build time. As this optimization no longer applies, it has to be removed. Change-Id: Ia8d19f4981e1017e4ffe0ba136de73d701044cb0 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'services')
-rw-r--r--services/std_svc/spm/spm_main.c3
-rw-r--r--services/std_svc/spm/spm_private.h2
-rw-r--r--services/std_svc/spm/spm_setup.c3
-rw-r--r--services/std_svc/spm/spm_xlat.c17
4 files changed, 7 insertions, 18 deletions
diff --git a/services/std_svc/spm/spm_main.c b/services/std_svc/spm/spm_main.c
index d740a8dc99..aa7bd04b02 100644
--- a/services/std_svc/spm/spm_main.c
+++ b/services/std_svc/spm/spm_main.c
@@ -328,9 +328,6 @@ int32_t spm_setup(void)
/* Initialize context of the SP */
INFO("Secure Partition %u context setup start...\n", i);
- /* Assign translation tables context. */
- ctx->xlat_ctx_handle = spm_sp_xlat_context_alloc();
-
/* Save location of the image in physical memory */
ctx->image_base = (uintptr_t)sp_base;
ctx->image_size = sp_size;
diff --git a/services/std_svc/spm/spm_private.h b/services/std_svc/spm/spm_private.h
index 8b98e8c0d3..740fee58b0 100644
--- a/services/std_svc/spm/spm_private.h
+++ b/services/std_svc/spm/spm_private.h
@@ -100,7 +100,7 @@ void spm_exceptions_xlat_init_context(void);
uint64_t *spm_exceptions_xlat_get_base_table(void);
/* Functions related to the translation tables management */
-xlat_ctx_t *spm_sp_xlat_context_alloc(void);
+void spm_sp_xlat_context_alloc(sp_context_t *sp_ctx);
void sp_map_memory_regions(sp_context_t *sp_ctx);
/* Functions to handle Secure Partition contexts */
diff --git a/services/std_svc/spm/spm_setup.c b/services/std_svc/spm/spm_setup.c
index 6cbbc5b22e..2ed44d134b 100644
--- a/services/std_svc/spm/spm_setup.c
+++ b/services/std_svc/spm/spm_setup.c
@@ -60,6 +60,9 @@ void spm_sp_setup(sp_context_t *sp_ctx)
* ------------------------
*/
+ /* Assign translation tables context. */
+ spm_sp_xlat_context_alloc(sp_ctx);
+
sp_map_memory_regions(sp_ctx);
/*
diff --git a/services/std_svc/spm/spm_xlat.c b/services/std_svc/spm/spm_xlat.c
index 58d61fc347..1619f9720a 100644
--- a/services/std_svc/spm/spm_xlat.c
+++ b/services/std_svc/spm/spm_xlat.c
@@ -50,17 +50,6 @@ static OBJECT_POOL(sp_xlat_tables_pool, sp_xlat_tables,
XLAT_TABLE_ENTRIES * sizeof(uint64_t),
(PLAT_SP_IMAGE_MAX_XLAT_TABLES + 1) * PLAT_SPM_MAX_PARTITIONS);
-/* Allocate base translation tables. */
-static uint64_t sp_xlat_base_tables
- [GET_NUM_BASE_LEVEL_ENTRIES(PLAT_VIRT_ADDR_SPACE_SIZE)]
- [PLAT_SPM_MAX_PARTITIONS]
- __aligned(GET_NUM_BASE_LEVEL_ENTRIES(PLAT_VIRT_ADDR_SPACE_SIZE)
- * sizeof(uint64_t))
- __section(PLAT_SP_IMAGE_XLAT_SECTION_NAME);
-static OBJECT_POOL(sp_xlat_base_tables_pool, sp_xlat_base_tables,
- GET_NUM_BASE_LEVEL_ENTRIES(PLAT_VIRT_ADDR_SPACE_SIZE) * sizeof(uint64_t),
- PLAT_SPM_MAX_PARTITIONS);
-
/* Allocate arrays. */
static int sp_xlat_mapped_regions[PLAT_SP_IMAGE_MAX_XLAT_TABLES]
[PLAT_SPM_MAX_PARTITIONS];
@@ -73,13 +62,13 @@ static OBJECT_POOL(sp_xlat_ctx_pool, sp_xlat_ctx, sizeof(xlat_ctx_t),
PLAT_SPM_MAX_PARTITIONS);
/* Get handle of Secure Partition translation context */
-xlat_ctx_t *spm_sp_xlat_context_alloc(void)
+void spm_sp_xlat_context_alloc(sp_context_t *sp_ctx)
{
xlat_ctx_t *ctx = pool_alloc(&sp_xlat_ctx_pool);
struct mmap_region *mmap = pool_alloc(&sp_mmap_regions_pool);
- uint64_t *base_table = pool_alloc(&sp_xlat_base_tables_pool);
+ uint64_t *base_table = pool_alloc(&sp_xlat_tables_pool);
uint64_t **tables = pool_alloc_n(&sp_xlat_tables_pool,
PLAT_SP_IMAGE_MAX_XLAT_TABLES);
@@ -91,7 +80,7 @@ xlat_ctx_t *spm_sp_xlat_context_alloc(void)
PLAT_SP_IMAGE_MAX_XLAT_TABLES, base_table,
EL1_EL0_REGIME, mapped_regions);
- return ctx;
+ sp_ctx->xlat_ctx_handle = ctx;
};
/*******************************************************************************