From aeaa225cbe24d63539261210e5aa901454de2a5b Mon Sep 17 00:00:00 2001 From: Paul Beesley Date: Tue, 15 Oct 2019 10:57:42 +0000 Subject: [PATCH] spm-mm: Refactor secure_partition.h and its contents Before adding any new SPM-related components we should first do some cleanup around the existing SPM-MM implementation. The aim is to make sure that any SPM-MM components have names that clearly indicate that they are MM-related. Otherwise, when adding new SPM code, it could quickly become confusing as it would be unclear to which component the code belongs. The secure_partition.h header is a clear example of this, as the name is generic so it could easily apply to any SPM-related code, when it is in fact SPM-MM specific. This patch renames the file and the two structures defined within it, and then modifies any references in files that use the header. Change-Id: I44bd95fab774c358178b3e81262a16da500fda26 Signed-off-by: Paul Beesley --- .../secure-partition-manager-design.rst | 2 +- include/plat/common/platform.h | 4 ++-- ...{secure_partition.h => spm_mm_partition.h} | 22 +++++++---------- plat/arm/board/fvp/fvp_common.c | 10 ++++---- plat/arm/common/arm_common.c | 2 +- plat/arm/css/sgi/sgi_plat.c | 10 ++++---- plat/socionext/synquacer/sq_spm.c | 12 +++++----- services/std_svc/spm_mm/spm_main.c | 2 +- services/std_svc/spm_mm/spm_setup.c | 24 +++++++++---------- services/std_svc/spm_mm/spm_xlat.c | 4 ++-- 10 files changed, 44 insertions(+), 48 deletions(-) rename include/services/{secure_partition.h => spm_mm_partition.h} (70%) diff --git a/docs/components/secure-partition-manager-design.rst b/docs/components/secure-partition-manager-design.rst index de0792d15..5c75bafdc 100644 --- a/docs/components/secure-partition-manager-design.rst +++ b/docs/components/secure-partition-manager-design.rst @@ -160,7 +160,7 @@ are implemented. Partition. - ``plat_get_secure_partition_boot_info()`` returns a - ``secure_partition_boot_info_t`` struct that is populated by the platform + ``spm_mm_boot_info_t`` struct that is populated by the platform with information about the memory map of the Secure Partition. For an example of all the changes in context, you may refer to commit diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h index eeae62141..9efb2fd52 100644 --- a/include/plat/common/platform.h +++ b/include/plat/common/platform.h @@ -22,7 +22,7 @@ struct image_desc; struct bl_load_info; struct bl_params; struct mmap_region; -struct secure_partition_boot_info; +struct spm_mm_boot_info; struct sp_res_desc; /******************************************************************************* @@ -267,7 +267,7 @@ int get_mbedtls_heap_helper(void **heap_addr, size_t *heap_size); * Secure Partitions functions ******************************************************************************/ const struct mmap_region *plat_get_secure_partition_mmap(void *cookie); -const struct secure_partition_boot_info *plat_get_secure_partition_boot_info( +const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( void *cookie); int plat_spm_sp_rd_load(struct sp_res_desc *rd, const void *ptr, size_t size); int plat_spm_sp_get_next_address(void **sp_base, size_t *sp_size, diff --git a/include/services/secure_partition.h b/include/services/spm_mm_partition.h similarity index 70% rename from include/services/secure_partition.h rename to include/services/spm_mm_partition.h index 0510f80ec..ad5ceefbb 100644 --- a/include/services/secure_partition.h +++ b/include/services/spm_mm_partition.h @@ -4,17 +4,15 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef SECURE_PARTITION_H -#define SECURE_PARTITION_H - -#if SPM_MM +#ifndef SPM_MM_PARTITION_H +#define SPM_MM_PARTITION_H #include #include /* - * Flags used by the secure_partition_mp_info structure to describe the + * Flags used by the spm_mm_mp_info structure to describe the * characteristics of a cpu. Only a single flag is defined at the moment to * indicate the primary cpu. */ @@ -24,13 +22,13 @@ * This structure is used to provide information required to initialise a S-EL0 * partition. */ -typedef struct secure_partition_mp_info { +typedef struct spm_mm_mp_info { uint64_t mpidr; uint32_t linear_id; uint32_t flags; -} secure_partition_mp_info_t; +} spm_mm_mp_info_t; -typedef struct secure_partition_boot_info { +typedef struct spm_mm_boot_info { param_header_t h; uint64_t sp_mem_base; uint64_t sp_mem_limit; @@ -46,9 +44,7 @@ typedef struct secure_partition_boot_info { uint64_t sp_shared_buf_size; uint32_t num_sp_mem_regions; uint32_t num_cpus; - secure_partition_mp_info_t *mp_info; -} secure_partition_boot_info_t; + spm_mm_mp_info_t *mp_info; +} spm_mm_boot_info_t; -#endif /* SPM_MM */ - -#endif /* SECURE_PARTITION_H */ +#endif /* SPM_MM_PARTITION_H */ diff --git a/plat/arm/board/fvp/fvp_common.c b/plat/arm/board/fvp/fvp_common.c index 0b1b32102..c36cd6f17 100644 --- a/plat/arm/board/fvp/fvp_common.c +++ b/plat/arm/board/fvp/fvp_common.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include "fvp_private.h" @@ -189,7 +189,7 @@ static unsigned int get_interconnect_master(void) * Boot information passed to a secure partition during initialisation. Linear * indices in MP information will be filled at runtime. */ -static secure_partition_mp_info_t sp_mp_info[] = { +static spm_mm_mp_info_t sp_mp_info[] = { [0] = {0x80000000, 0}, [1] = {0x80000001, 0}, [2] = {0x80000002, 0}, @@ -200,10 +200,10 @@ static secure_partition_mp_info_t sp_mp_info[] = { [7] = {0x80000103, 0}, }; -const secure_partition_boot_info_t plat_arm_secure_partition_boot_info = { +const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = { .h.type = PARAM_SP_IMAGE_BOOT_INFO, .h.version = VERSION_1, - .h.size = sizeof(secure_partition_boot_info_t), + .h.size = sizeof(spm_mm_boot_info_t), .h.attr = 0, .sp_mem_base = ARM_SP_IMAGE_BASE, .sp_mem_limit = ARM_SP_IMAGE_LIMIT, @@ -227,7 +227,7 @@ const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) return plat_arm_secure_partition_mmap; } -const struct secure_partition_boot_info *plat_get_secure_partition_boot_info( +const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( void *cookie) { return &plat_arm_secure_partition_boot_info; diff --git a/plat/arm/common/arm_common.c b/plat/arm/common/arm_common.c index bc0cf9a85..03d842a51 100644 --- a/plat/arm/common/arm_common.c +++ b/plat/arm/common/arm_common.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include /* Weak definitions may be overridden in specific ARM standard platform */ #pragma weak plat_get_ns_image_entrypoint diff --git a/plat/arm/css/sgi/sgi_plat.c b/plat/arm/css/sgi/sgi_plat.c index ef13cdcef..b611eaff5 100644 --- a/plat/arm/css/sgi/sgi_plat.c +++ b/plat/arm/css/sgi/sgi_plat.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\ V2M_FLASH0_SIZE, \ @@ -87,7 +87,7 @@ ARM_CASSERT_MMAP * Boot information passed to a secure partition during initialisation. Linear * indices in MP information will be filled at runtime. */ -static secure_partition_mp_info_t sp_mp_info[] = { +static spm_mm_mp_info_t sp_mp_info[] = { [0] = {0x81000000, 0}, [1] = {0x81000100, 0}, [2] = {0x81000200, 0}, @@ -98,10 +98,10 @@ static secure_partition_mp_info_t sp_mp_info[] = { [7] = {0x81010300, 0}, }; -const secure_partition_boot_info_t plat_arm_secure_partition_boot_info = { +const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = { .h.type = PARAM_SP_IMAGE_BOOT_INFO, .h.version = VERSION_1, - .h.size = sizeof(secure_partition_boot_info_t), + .h.size = sizeof(spm_mm_boot_info_t), .h.attr = 0, .sp_mem_base = ARM_SP_IMAGE_BASE, .sp_mem_limit = ARM_SP_IMAGE_LIMIT, @@ -125,7 +125,7 @@ const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) return plat_arm_secure_partition_mmap; } -const struct secure_partition_boot_info *plat_get_secure_partition_boot_info( +const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( void *cookie) { return &plat_arm_secure_partition_boot_info; diff --git a/plat/socionext/synquacer/sq_spm.c b/plat/socionext/synquacer/sq_spm.c index 01cce1739..7bea1114e 100644 --- a/plat/socionext/synquacer/sq_spm.c +++ b/plat/socionext/synquacer/sq_spm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -10,7 +10,7 @@ #include #include -#include +#include static const mmap_region_t plat_arm_secure_partition_mmap[] = { PLAT_SQ_FLASH_MMAP, @@ -27,7 +27,7 @@ static const mmap_region_t plat_arm_secure_partition_mmap[] = { * Boot information passed to a secure partition during initialisation. Linear * indices in MP information will be filled at runtime. */ -static secure_partition_mp_info_t sp_mp_info[] = { +static spm_mm_mp_info_t sp_mp_info[] = { {0x80000000, 0}, {0x80000001, 0}, {0x80000100, 0}, {0x80000101, 0}, {0x80000200, 0}, {0x80000201, 0}, {0x80000300, 0}, {0x80000301, 0}, {0x80000400, 0}, {0x80000401, 0}, {0x80000500, 0}, {0x80000501, 0}, @@ -36,10 +36,10 @@ static secure_partition_mp_info_t sp_mp_info[] = { {0x80000a00, 0}, {0x80000a01, 0}, {0x80000b00, 0}, {0x80000b01, 0}, }; -const secure_partition_boot_info_t plat_arm_secure_partition_boot_info = { +const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = { .h.type = PARAM_SP_IMAGE_BOOT_INFO, .h.version = VERSION_1, - .h.size = sizeof(secure_partition_boot_info_t), + .h.size = sizeof(spm_mm_boot_info_t), .h.attr = 0, .sp_mem_base = BL32_BASE, .sp_mem_limit = BL32_LIMIT, @@ -63,7 +63,7 @@ const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) return plat_arm_secure_partition_mmap; } -const struct secure_partition_boot_info *plat_get_secure_partition_boot_info( +const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( void *cookie) { return &plat_arm_secure_partition_boot_info; diff --git a/services/std_svc/spm_mm/spm_main.c b/services/std_svc/spm_mm/spm_main.c index 706b69d9f..b2f93a636 100644 --- a/services/std_svc/spm_mm/spm_main.c +++ b/services/std_svc/spm_mm/spm_main.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include diff --git a/services/std_svc/spm_mm/spm_setup.c b/services/std_svc/spm_mm/spm_setup.c index aae6cd5e2..7d03eb588 100644 --- a/services/std_svc/spm_mm/spm_setup.c +++ b/services/std_svc/spm_mm/spm_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include "spm_private.h" #include "spm_shim_private.h" @@ -192,22 +192,22 @@ void spm_sp_setup(sp_context_t *sp_ctx) void *shared_buf_ptr = (void *) PLAT_SPM_BUF_BASE; /* Copy the boot information into the shared buffer with the SP. */ - assert((uintptr_t)shared_buf_ptr + sizeof(secure_partition_boot_info_t) + assert((uintptr_t)shared_buf_ptr + sizeof(spm_mm_boot_info_t) <= (PLAT_SPM_BUF_BASE + PLAT_SPM_BUF_SIZE)); assert(PLAT_SPM_BUF_BASE <= (UINTPTR_MAX - PLAT_SPM_BUF_SIZE + 1)); - const secure_partition_boot_info_t *sp_boot_info = + const spm_mm_boot_info_t *sp_boot_info = plat_get_secure_partition_boot_info(NULL); assert(sp_boot_info != NULL); memcpy((void *) shared_buf_ptr, (const void *) sp_boot_info, - sizeof(secure_partition_boot_info_t)); + sizeof(spm_mm_boot_info_t)); /* Pointer to the MP information from the platform port. */ - secure_partition_mp_info_t *sp_mp_info = - ((secure_partition_boot_info_t *) shared_buf_ptr)->mp_info; + spm_mm_mp_info_t *sp_mp_info = + ((spm_mm_boot_info_t *) shared_buf_ptr)->mp_info; assert(sp_mp_info != NULL); @@ -215,15 +215,15 @@ void spm_sp_setup(sp_context_t *sp_ctx) * Point the shared buffer MP information pointer to where the info will * be populated, just after the boot info. */ - ((secure_partition_boot_info_t *) shared_buf_ptr)->mp_info = - (secure_partition_mp_info_t *) ((uintptr_t)shared_buf_ptr - + sizeof(secure_partition_boot_info_t)); + ((spm_mm_boot_info_t *) shared_buf_ptr)->mp_info = + (spm_mm_mp_info_t *) ((uintptr_t)shared_buf_ptr + + sizeof(spm_mm_boot_info_t)); /* * Update the shared buffer pointer to where the MP information for the * payload will be populated */ - shared_buf_ptr = ((secure_partition_boot_info_t *) shared_buf_ptr)->mp_info; + shared_buf_ptr = ((spm_mm_boot_info_t *) shared_buf_ptr)->mp_info; /* * Copy the cpu information into the shared buffer area after the boot @@ -242,7 +242,7 @@ void spm_sp_setup(sp_context_t *sp_ctx) * Calculate the linear indices of cores in boot information for the * secure partition and flag the primary CPU */ - sp_mp_info = (secure_partition_mp_info_t *) shared_buf_ptr; + sp_mp_info = (spm_mm_mp_info_t *) shared_buf_ptr; for (unsigned int index = 0; index < sp_boot_info->num_cpus; index++) { u_register_t mpidr = sp_mp_info[index].mpidr; diff --git a/services/std_svc/spm_mm/spm_xlat.c b/services/std_svc/spm_mm/spm_xlat.c index f54168e33..a2df1afb0 100644 --- a/services/std_svc/spm_mm/spm_xlat.c +++ b/services/std_svc/spm_mm/spm_xlat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include "spm_private.h"