diff options
author | Nishant Sharma <nishant.sharma@arm.com> | 2022-04-28 00:13:50 +0100 |
---|---|---|
committer | Nishant Sharma <nishant.sharma@arm.com> | 2023-10-12 11:40:24 +0100 |
commit | 549bc04f148f3b42ea0808b9ab0794a48d67007d (patch) | |
tree | fee1d6994e9b0598c59829455cab8f419c6b5abd | |
parent | b4bed4b769e907c8431b07f698da24660dfe0059 (diff) |
feat(spm): separate StMM SP specifics to add support for a S-EL0 SP
This patch separates the code from SPM_MM to get xlat table context and
move it to a common location. In addition, only APIs required from both
SPM_MM and FF-A EL3 SPMC are moved to the common location.
This allows understanding better what is required to support a S-EL0 SP
instead of trying to retrofit what already exists.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
Change-Id: I142d7fbef5239869176d0de93842c66051d7ed78
-rw-r--r-- | services/std_svc/spm/common/include/spm_common.h | 6 | ||||
-rw-r--r-- | services/std_svc/spm/common/spm.mk | 5 | ||||
-rw-r--r-- | services/std_svc/spm/common/spm_xlat_common.c | 30 | ||||
-rw-r--r-- | services/std_svc/spm/spm_mm/spm_mm_private.h | 4 | ||||
-rw-r--r-- | services/std_svc/spm/spm_mm/spm_mm_xlat.c | 22 |
5 files changed, 41 insertions, 26 deletions
diff --git a/services/std_svc/spm/common/include/spm_common.h b/services/std_svc/spm/common/include/spm_common.h index 68805fc4d..c73691953 100644 --- a/services/std_svc/spm/common/include/spm_common.h +++ b/services/std_svc/spm/common/include/spm_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2023, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -32,11 +32,15 @@ #ifndef __ASSEMBLER__ #include <stdint.h> +#include <lib/xlat_tables/xlat_tables_v2.h> /* Assembly helpers */ uint64_t spm_secure_partition_enter(uint64_t *c_rt_ctx); void __dead2 spm_secure_partition_exit(uint64_t c_rt_ctx, uint64_t ret); +/* Helper to obtain a reference to the SP's translation table context */ +xlat_ctx_t *spm_get_sp_xlat_context(void); + #endif /* __ASSEMBLER__ */ #endif /* SPM_COMMON_H */ diff --git a/services/std_svc/spm/common/spm.mk b/services/std_svc/spm/common/spm.mk index 94912407e..65fd72aa4 100644 --- a/services/std_svc/spm/common/spm.mk +++ b/services/std_svc/spm/common/spm.mk @@ -14,5 +14,10 @@ SPM_SOURCES := $(addprefix services/std_svc/spm/common/, \ ${ARCH}/spm_helpers.S \ ${ARCH}/spm_shim_exceptions.S) +ifeq (1, $(filter 1, ${SPM_MM} ${SPMC_AT_EL3_SEL0_SP})) +SPM_SOURCES += $(addprefix services/std_svc/spm/common/, \ + spm_xlat_common.c) +endif + # Let the top-level Makefile know that we intend to include a BL32 image NEED_BL32 := yes diff --git a/services/std_svc/spm/common/spm_xlat_common.c b/services/std_svc/spm/common/spm_xlat_common.c new file mode 100644 index 000000000..a463c8b49 --- /dev/null +++ b/services/std_svc/spm/common/spm_xlat_common.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <lib/xlat_tables/xlat_tables_v2.h> +#include <platform_def.h> + +/* Place translation tables by default along with the ones used by BL31. */ +#ifndef PLAT_SP_IMAGE_XLAT_SECTION_NAME +#define PLAT_SP_IMAGE_XLAT_SECTION_NAME ".xlat_table" +#endif +#ifndef PLAT_SP_IMAGE_BASE_XLAT_SECTION_NAME +#define PLAT_SP_IMAGE_BASE_XLAT_SECTION_NAME ".bss" +#endif + +/* Allocate and initialise the translation context for the secure partitions. */ +REGISTER_XLAT_CONTEXT2(sp, + PLAT_SP_IMAGE_MMAP_REGIONS, + PLAT_SP_IMAGE_MAX_XLAT_TABLES, + PLAT_VIRT_ADDR_SPACE_SIZE, PLAT_PHY_ADDR_SPACE_SIZE, + EL1_EL0_REGIME, PLAT_SP_IMAGE_XLAT_SECTION_NAME, + PLAT_SP_IMAGE_BASE_XLAT_SECTION_NAME); + +/* Get handle of Secure Partition translation context */ +xlat_ctx_t *spm_get_sp_xlat_context(void) +{ + return &sp_xlat_ctx; +}; diff --git a/services/std_svc/spm/spm_mm/spm_mm_private.h b/services/std_svc/spm/spm_mm/spm_mm_private.h index 0eff1c071..3a52a3ee8 100644 --- a/services/std_svc/spm/spm_mm/spm_mm_private.h +++ b/services/std_svc/spm/spm_mm/spm_mm_private.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2023, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -55,8 +55,6 @@ typedef struct sp_context { void spm_sp_setup(sp_context_t *sp_ctx); -xlat_ctx_t *spm_get_sp_xlat_context(void); - int32_t spm_memory_attributes_get_smc_handler(sp_context_t *sp_ctx, uintptr_t base_va); int spm_memory_attributes_set_smc_handler(sp_context_t *sp_ctx, diff --git a/services/std_svc/spm/spm_mm/spm_mm_xlat.c b/services/std_svc/spm/spm_mm/spm_mm_xlat.c index 858ca1b00..01d95c77c 100644 --- a/services/std_svc/spm/spm_mm/spm_mm_xlat.c +++ b/services/std_svc/spm/spm_mm/spm_mm_xlat.c @@ -17,31 +17,9 @@ #include "spm_mm_private.h" #include "spm_shim_private.h" -/* Place translation tables by default along with the ones used by BL31. */ -#ifndef PLAT_SP_IMAGE_XLAT_SECTION_NAME -#define PLAT_SP_IMAGE_XLAT_SECTION_NAME ".xlat_table" -#endif -#ifndef PLAT_SP_IMAGE_BASE_XLAT_SECTION_NAME -#define PLAT_SP_IMAGE_BASE_XLAT_SECTION_NAME ".bss" -#endif - -/* Allocate and initialise the translation context for the secure partitions. */ -REGISTER_XLAT_CONTEXT2(sp, - PLAT_SP_IMAGE_MMAP_REGIONS, - PLAT_SP_IMAGE_MAX_XLAT_TABLES, - PLAT_VIRT_ADDR_SPACE_SIZE, PLAT_PHY_ADDR_SPACE_SIZE, - EL1_EL0_REGIME, PLAT_SP_IMAGE_XLAT_SECTION_NAME, - PLAT_SP_IMAGE_BASE_XLAT_SECTION_NAME); - /* Lock used for SP_MEMORY_ATTRIBUTES_GET and SP_MEMORY_ATTRIBUTES_SET */ static spinlock_t mem_attr_smc_lock; -/* Get handle of Secure Partition translation context */ -xlat_ctx_t *spm_get_sp_xlat_context(void) -{ - return &sp_xlat_ctx; -}; - /* * Attributes are encoded using a different format in the SMC interface than in * the Trusted Firmware, where the mmap_attr_t enum type is used. This function |