aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Shan <shawn.shan@arm.com>2019-10-22 13:43:07 +0800
committerKen Liu <ken.liu@arm.com>2019-11-18 02:41:22 +0000
commit9b0e0c7048854e14be6e98f3e1997239988c04d2 (patch)
tree76726ebad5d4ac69c0760a5a31e7e71a2acf2b93
parentf94204e62dd8194c90fe66a229c911bcdac481d1 (diff)
downloadtrusted-firmware-m-9b0e0c7048854e14be6e98f3e1997239988c04d2.tar.gz
Core: Align psa_wait() to PSA FF 1.0.0
If the signal_mask does not include any assigned signals, it is a PROGRAMMER ERROR, trigger the tfm_panic. Change-Id: Ib3699800e540a758b79a0a79f55f6c6ba2285187 Signed-off-by: Shawn Shan <shawn.shan@arm.com>
-rw-r--r--secure_fw/core/ipc/tfm_svcalls.c8
-rw-r--r--secure_fw/spm/spm_api.h1
-rw-r--r--secure_fw/spm/spm_api_ipc.c16
3 files changed, 24 insertions, 1 deletions
diff --git a/secure_fw/core/ipc/tfm_svcalls.c b/secure_fw/core/ipc/tfm_svcalls.c
index 8d70c873b6..3721ba2300 100644
--- a/secure_fw/core/ipc/tfm_svcalls.c
+++ b/secure_fw/core/ipc/tfm_svcalls.c
@@ -188,6 +188,14 @@ static psa_signal_t tfm_svcall_psa_wait(uint32_t *args)
}
/*
+ * It is a PROGRAMMER ERROR if the signal_mask does not include any assigned
+ * signals.
+ */
+ if ((partition->runtime_data.assigned_signals & signal_mask) == 0) {
+ tfm_panic();
+ }
+
+ /*
* Expected signals are included in signal wait mask, ignored signals
* should not be set and affect caller thread status. Save this mask for
* further checking while signals are ready to be set.
diff --git a/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index ce042f70f6..e1de88d311 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -88,6 +88,7 @@ struct spm_partition_runtime_data_t {
uint32_t signals; /* Service signals had been triggered*/
struct tfm_list_node_t service_list;/* Service list */
struct tfm_thrd_ctx sp_thrd; /* Thread context */
+ uint32_t assigned_signals; /* All assigned signals */
#else /* TFM_PSA_API */
uint32_t partition_state;
uint32_t caller_partition_idx;
diff --git a/secure_fw/spm/spm_api_ipc.c b/secure_fw/spm/spm_api_ipc.c
index e42c5a16a1..987002f4e7 100644
--- a/secure_fw/spm/spm_api_ipc.c
+++ b/secure_fw/spm/spm_api_ipc.c
@@ -29,6 +29,7 @@
#include "tfm_memory_utils.h"
#include "tfm_core_utils.h"
#include "tfm_rpc.h"
+#include "tfm_irq_list.h"
#include "secure_fw/services/tfm_service_list.inc"
@@ -476,7 +477,7 @@ uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags)
void tfm_spm_init(void)
{
- uint32_t i, num;
+ uint32_t i, j, num;
struct spm_partition_desc_t *partition;
struct tfm_thrd_ctx *pth, this_thrd;
@@ -493,6 +494,17 @@ void tfm_spm_init(void)
continue;
}
+ /* TODO: This can be optimized by generating the assigned signal
+ * in code generation time.
+ */
+ for (j = 0; j < tfm_core_irq_signals_count; ++j) {
+ if (tfm_core_irq_signals[j].partition_id ==
+ partition->static_data->partition_id) {
+ partition->runtime_data.assigned_signals |=
+ tfm_core_irq_signals[j].signal_value;
+ }
+ }
+
tfm_event_init(&partition->runtime_data.signal_evnt);
tfm_list_init(&partition->runtime_data.service_list);
@@ -525,6 +537,8 @@ void tfm_spm_init(void)
tfm_panic();
}
service[i].partition = partition;
+ partition->runtime_data.assigned_signals |= service->service_db->signal;
+
tfm_list_init(&service[i].handle_list);
tfm_list_add_tail(&partition->runtime_data.service_list,
&service[i].list);