Commit a43c85db authored by Antonio Nino Diaz's avatar Antonio Nino Diaz
Browse files

SPM: Allow secondary CPUs to use the Secure Partition



The Secure Partition should be able to be used from any CPU, not just
the lead one. This patch point the secure contexts of all secondary
CPUs to the same one used by the lead CPU for the Secure Partition. This
way, they can also use it.

In order to prevent more than one CPU from using the Secure Partition at
the same time, a lock has been added.

Change-Id: Ica76373127c3626498b06c558a4874ce72201ff7
Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
parent 26bd5f82
...@@ -124,6 +124,13 @@ int32_t spm_init(void) ...@@ -124,6 +124,13 @@ int32_t spm_init(void)
cm_init_my_context(secure_partition_ep_info); cm_init_my_context(secure_partition_ep_info);
secure_partition_setup(); secure_partition_setup();
/*
* Make all CPUs use the same secure context.
*/
for (unsigned int i = 0; i < PLATFORM_CORE_COUNT; i++) {
cm_set_context_by_index(i, &sp_ctx.cpu_ctx, SECURE);
}
/* /*
* Arrange for an entry into the secure partition. * Arrange for an entry into the secure partition.
*/ */
...@@ -369,6 +376,9 @@ uint64_t spm_smc_handler(uint32_t smc_fid, ...@@ -369,6 +376,9 @@ uint64_t spm_smc_handler(uint32_t smc_fid,
assert(0); assert(0);
} }
/* Release the Secure Partition context */
spin_unlock(&sp_ctx.lock);
/* /*
* This is the result from the Secure partition of an * This is the result from the Secure partition of an
* earlier request. Copy the result into the non-secure * earlier request. Copy the result into the non-secure
...@@ -442,6 +452,9 @@ uint64_t spm_smc_handler(uint32_t smc_fid, ...@@ -442,6 +452,9 @@ uint64_t spm_smc_handler(uint32_t smc_fid,
/* Save the Normal world context */ /* Save the Normal world context */
cm_el1_sysregs_context_save(NON_SECURE); cm_el1_sysregs_context_save(NON_SECURE);
/* Lock the Secure Partition context. */
spin_lock(&sp_ctx.lock);
/* /*
* Restore the secure world context and prepare for * Restore the secure world context and prepare for
* entry in S-EL0 * entry in S-EL0
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <spinlock.h>
#include <stdint.h> #include <stdint.h>
#include <xlat_tables_v2.h> #include <xlat_tables_v2.h>
...@@ -44,6 +45,7 @@ typedef struct secure_partition_context { ...@@ -44,6 +45,7 @@ typedef struct secure_partition_context {
uint64_t c_rt_ctx; uint64_t c_rt_ctx;
cpu_context_t cpu_ctx; cpu_context_t cpu_ctx;
unsigned int sp_init_in_progress; unsigned int sp_init_in_progress;
spinlock_t lock;
} secure_partition_context_t; } secure_partition_context_t;
uint64_t spm_secure_partition_enter(uint64_t *c_rt_ctx); uint64_t spm_secure_partition_enter(uint64_t *c_rt_ctx);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment