diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2018-11-22 15:46:13 +0100 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2018-11-27 14:27:17 +0100 |
commit | 2f0cd8af66a8b3ee20cd5e4936cbe912e68b69fe (patch) | |
tree | 6ba582851ed65d7cb34d9bd057c786625cab8a05 | |
parent | 9e5923381a5c001594baebfa7975965d42a0f7c1 (diff) |
core: base pseudo_ta_register() on scatter array
The pseudo_ta_register() implementation is now based on scatter array.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
-rw-r--r-- | core/arch/arm/include/kernel/linker.h | 4 | ||||
-rw-r--r-- | core/arch/arm/include/kernel/pseudo_ta.h | 7 | ||||
-rw-r--r-- | core/arch/arm/kernel/kern.ld.S | 18 | ||||
-rw-r--r-- | core/arch/arm/kernel/pseudo_ta.c | 14 |
4 files changed, 13 insertions, 30 deletions
diff --git a/core/arch/arm/include/kernel/linker.h b/core/arch/arm/include/kernel/linker.h index 98b39f23..4e15cc88 100644 --- a/core/arch/arm/include/kernel/linker.h +++ b/core/arch/arm/include/kernel/linker.h @@ -7,7 +7,6 @@ #include <kernel/dt.h> #include <kernel/early_ta.h> -#include <kernel/pseudo_ta.h> #include <mm/core_mmu.h> #include <types_ext.h> @@ -25,9 +24,6 @@ extern const uint8_t __exidx_end[]; extern const uint8_t __extab_start[]; extern const uint8_t __extab_end[]; -extern const struct pseudo_ta_head __start_ta_head_section; -extern const struct pseudo_ta_head __stop_ta_head_section; - extern const struct core_mmu_phys_mem __start_phys_sdp_mem_section; extern const struct core_mmu_phys_mem __end_phys_sdp_mem_section; extern const struct core_mmu_phys_mem __start_phys_mem_map_section; diff --git a/core/arch/arm/include/kernel/pseudo_ta.h b/core/arch/arm/include/kernel/pseudo_ta.h index cfef37ba..c3d69ae7 100644 --- a/core/arch/arm/include/kernel/pseudo_ta.h +++ b/core/arch/arm/include/kernel/pseudo_ta.h @@ -8,6 +8,7 @@ #include <assert.h> #include <compiler.h> #include <kernel/tee_ta_manager.h> +#include <scattered_array.h> #include <tee_api_types.h> #include <user_ta_header.h> #include <util.h> @@ -38,9 +39,9 @@ struct pseudo_ta_head { TEE_Param pParams[TEE_NUM_PARAMS]); }; -#define pseudo_ta_register(...) static const struct pseudo_ta_head __head \ - __used __section("ta_head_section") = { __VA_ARGS__ } - +#define pseudo_ta_register(...) \ + SCATTERED_ARRAY_DEFINE_PG_ITEM(pseudo_tas, struct pseudo_ta_head) = \ + { __VA_ARGS__ } struct pseudo_ta_ctx { const struct pseudo_ta_head *pseudo_ta; diff --git a/core/arch/arm/kernel/kern.ld.S b/core/arch/arm/kernel/kern.ld.S index 083030df..cb872883 100644 --- a/core/arch/arm/kernel/kern.ld.S +++ b/core/arch/arm/kernel/kern.ld.S @@ -128,15 +128,6 @@ SECTIONS *(.rodata .rodata.*) - /* - * 8 to avoid unwanted padding between __start_ta_head_section - * and the first structure in ta_head_section, in 64-bit - * builds - */ - . = ALIGN(8); - __start_ta_head_section = . ; - KEEP(*(ta_head_section)) - __stop_ta_head_section = . ; . = ALIGN(8); __start_phys_mem_map_section = . ; KEEP(*(phys_mem_map_section)) @@ -362,15 +353,6 @@ SECTIONS __rodata_early_ta_end = .; #endif *(.rodata*) - /* - * 8 to avoid unwanted padding between __start_ta_head_section - * and the first structure in ta_head_section, in 64-bit - * builds - */ - . = ALIGN(8); - __start_ta_head_section = . ; - KEEP(*(ta_head_section)) - __stop_ta_head_section = . ; } #ifdef CFG_CORE_RODATA_NOEXEC diff --git a/core/arch/arm/kernel/pseudo_ta.c b/core/arch/arm/kernel/pseudo_ta.c index a6aa06c6..703d1dea 100644 --- a/core/arch/arm/kernel/pseudo_ta.c +++ b/core/arch/arm/kernel/pseudo_ta.c @@ -233,17 +233,20 @@ bool is_pseudo_ta_ctx(struct tee_ta_ctx *ctx) /* Insures declared pseudo TAs conforms with core expectations */ static TEE_Result verify_pseudo_tas_conformance(void) { - const struct pseudo_ta_head *start = &__start_ta_head_section; - const struct pseudo_ta_head *end = &__stop_ta_head_section; + const struct pseudo_ta_head *start = + SCATTERED_ARRAY_BEGIN(pseudo_tas, struct pseudo_ta_head); + const struct pseudo_ta_head *end = + SCATTERED_ARRAY_END(pseudo_tas, struct pseudo_ta_head); const struct pseudo_ta_head *pta; for (pta = start; pta < end; pta++) { const struct pseudo_ta_head *pta2; /* PTAs must all have a specific UUID */ - for (pta2 = pta + 1; pta2 < end; pta2++) + for (pta2 = pta + 1; pta2 < end; pta2++) { if (!memcmp(&pta->uuid, &pta2->uuid, sizeof(TEE_UUID))) goto err; + } if (!pta->name || (pta->flags & PTA_MANDATORY_FLAGS) != PTA_MANDATORY_FLAGS || @@ -272,9 +275,10 @@ TEE_Result tee_ta_init_pseudo_ta_session(const TEE_UUID *uuid, DMSG("Lookup pseudo TA %pUl", (void *)uuid); - ta = &__start_ta_head_section; + ta = SCATTERED_ARRAY_BEGIN(pseudo_tas, struct pseudo_ta_head); while (true) { - if (ta >= &__stop_ta_head_section) + if (ta >= SCATTERED_ARRAY_END(pseudo_tas, + struct pseudo_ta_head)) return TEE_ERROR_ITEM_NOT_FOUND; if (memcmp(&ta->uuid, uuid, sizeof(TEE_UUID)) == 0) break; |