Revert "SPM: Remove tfm_spm_get_msg_buffer_from_conn_handle"
This reverts commit ae8965e14264973890a9a03c061264c750703d06.
Revert because it was merged by accident without enough review.
Change-Id: I454513b4a157312b658473a6c79ee9ef410245ce
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index e05cb8d..b1ec03f 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -485,6 +485,14 @@
return p_msg;
}
+struct tfm_msg_body_t *
+ tfm_spm_get_msg_buffer_from_conn_handle(struct tfm_conn_handle_t *conn_handle)
+{
+ TFM_CORE_ASSERT(conn_handle != NULL);
+
+ return &(conn_handle->internal_msg);
+}
+
void tfm_spm_fill_msg(struct tfm_msg_body_t *msg,
struct tfm_spm_service_t *service,
psa_handle_t handle,
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h
index ac37b56..ed04f05 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.h
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.h
@@ -276,6 +276,17 @@
struct tfm_msg_body_t *tfm_spm_get_msg_from_handle(psa_handle_t msg_handle);
/**
+ * \brief Get message context by connect handle.
+ *
+ * \param[in] conn_handle Service connect handle.
+ *
+ * \return The message body context pointer
+ * \ref msg_body_t structures
+ */
+struct tfm_msg_body_t *
+ tfm_spm_get_msg_buffer_from_conn_handle(struct tfm_conn_handle_t *conn_handle);
+
+/**
* \brief Fill the message for PSA client call.
*
* \param[in] msg Service Message Queue buffer pointer
diff --git a/secure_fw/spm/ffm/spm_psa_client_call.c b/secure_fw/spm/ffm/spm_psa_client_call.c
index a840241..c37913e 100644
--- a/secure_fw/spm/ffm/spm_psa_client_call.c
+++ b/secure_fw/spm/ffm/spm_psa_client_call.c
@@ -90,7 +90,11 @@
TFM_PROGRAMMER_ERROR(ns_caller, PSA_ERROR_CONNECTION_REFUSED);
}
- msg = &(connect_handle->internal_msg);
+ msg = tfm_spm_get_msg_buffer_from_conn_handle(connect_handle);
+ if (!msg) {
+ /* Have no enough resource to create message */
+ return PSA_ERROR_CONNECTION_BUSY;
+ }
handle = tfm_spm_to_user_handle(connect_handle);
/* No input or output needed for connect message */
@@ -226,7 +230,11 @@
* FixMe: Need to check if the message is unrecognized by the RoT
* Service or incorrectly formatted.
*/
- msg = &(conn_handle->internal_msg);
+ msg = tfm_spm_get_msg_buffer_from_conn_handle(conn_handle);
+ if (!msg) {
+ /* FixMe: Need to implement one mechanism to resolve this failure. */
+ TFM_PROGRAMMER_ERROR(ns_caller, PSA_ERROR_PROGRAMMER_ERROR);
+ }
tfm_spm_fill_msg(msg, service, handle, type, client_id,
invecs, in_num, outvecs, out_num, outptr);
@@ -275,7 +283,11 @@
tfm_core_panic();
}
- msg = &(conn_handle->internal_msg);
+ msg = tfm_spm_get_msg_buffer_from_conn_handle(conn_handle);
+ if (!msg) {
+ /* FixMe: Need to implement one mechanism to resolve this failure. */
+ tfm_core_panic();
+ }
/*
* It is a PROGRAMMER ERROR if the connection is currently handling a