Core: Update the code related with request message type
The patch inlcudes the following changes:
-Create message with type instead of PSA_IPC_CALL in
tfm_svcall_psa_call();
-Change the condition to check whether message handle refers to a
request message instead of PSA_IPC_CALL;
-Move the request message logic into default block in
tfm_svcall_psa_reply().
Change-Id: I0c59b5f55c4a46feb05c674d5cb3bce666779171
Signed-off-by: Summer Qin <summer.qin@arm.com>
diff --git a/interface/include/psa/client.h b/interface/include/psa/client.h
index d040834..4115f93 100644
--- a/interface/include/psa/client.h
+++ b/interface/include/psa/client.h
@@ -127,7 +127,7 @@
*
* \param[in] handle A handle to an established connection.
* \param[in] type The reuqest type.
- * Must be zero( \ ref PSA_IPC_CALL) or positive.
+ * Must be zero( \ref PSA_IPC_CALL) or positive.
* \param[in] in_vec Array of input \ref psa_invec structures.
* \param[in] in_len Number of input \ref psa_invec structures.
* \param[in/out] out_vec Array of output \ref psa_outvec structures.
diff --git a/secure_fw/core/ipc/include/tfm_spm.h b/secure_fw/core/ipc/include/tfm_spm.h
index f11f749..6170386 100644
--- a/secure_fw/core/ipc/include/tfm_spm.h
+++ b/secure_fw/core/ipc/include/tfm_spm.h
@@ -222,8 +222,11 @@
* \param[in] service Target service context pointer, which can be
* obtained by partition management functions
* \prarm[in] handle Connect handle return by psa_connect().
- * \param[in] type Message type, PSA_IPC_CONNECT, PSA_IPC_CALL or
- * PSA_IPC_DISCONNECT
+ * \param[in] type Message type, one of the following values:
+ * \ref PSA_IPC_CONNECT
+ * >= 0
+ * \ref PSA_IPC_DISCONNECT
+ * positive.
* \param[in] ns_caller Whether from NS caller
* \param[in] invec Array of input \ref psa_invec structures
* \param[in] in_len Number of input \ref psa_invec structures
@@ -236,7 +239,7 @@
*/
struct tfm_msg_body_t *tfm_spm_create_msg(struct tfm_spm_service_t *service,
psa_handle_t handle,
- uint32_t type, int32_t ns_caller,
+ int32_t type, int32_t ns_caller,
psa_invec *invec, size_t in_len,
psa_outvec *outvec, size_t out_len,
psa_outvec *caller_outvec);
diff --git a/secure_fw/core/ipc/tfm_spm.c b/secure_fw/core/ipc/tfm_spm.c
index 13b5fcd..55a6518 100644
--- a/secure_fw/core/ipc/tfm_spm.c
+++ b/secure_fw/core/ipc/tfm_spm.c
@@ -323,7 +323,7 @@
struct tfm_msg_body_t *tfm_spm_create_msg(struct tfm_spm_service_t *service,
psa_handle_t handle,
- uint32_t type, int32_t ns_caller,
+ int32_t type, int32_t ns_caller,
psa_invec *invec, size_t in_len,
psa_outvec *outvec, size_t out_len,
psa_outvec *caller_outvec)
diff --git a/secure_fw/core/ipc/tfm_svcalls.c b/secure_fw/core/ipc/tfm_svcalls.c
index 007fa19..8914115 100644
--- a/secure_fw/core/ipc/tfm_svcalls.c
+++ b/secure_fw/core/ipc/tfm_svcalls.c
@@ -263,7 +263,7 @@
* FixMe: Need to check if the message is unrecognized by the RoT
* Service or incorrectly formatted.
*/
- msg = tfm_spm_create_msg(service, handle, PSA_IPC_CALL, ns_caller, invecs,
+ msg = tfm_spm_create_msg(service, handle, type, ns_caller, invecs,
in_num, outvecs, out_num, outptr);
if (!msg) {
/* FixMe: Need to implement one mechanism to resolve this failure. */
@@ -519,8 +519,8 @@
* \retval "Does not return" The call is invalid, one or more of the
* following are true:
* \arg msg_handle is invalid.
- * \arg msg_handle does not refer to a
- * \ref PSA_IPC_CALL message.
+ * \arg msg_handle does not refer to a request
+ * message.
* \arg invec_idx is equal to or greater than
* \ref PSA_MAX_IOVEC.
* \arg the memory reference for buffer is invalid or
@@ -553,10 +553,10 @@
privileged = tfm_spm_partition_get_privileged_mode(partition->index);
/*
- * It is a fatal error if message handle does not refer to a PSA_IPC_CALL
+ * It is a fatal error if message handle does not refer to a request
* message
*/
- if (msg->msg.type != PSA_IPC_CALL) {
+ if (msg->msg.type < PSA_IPC_CALL) {
tfm_panic();
}
@@ -606,8 +606,8 @@
* \retval "Does not return" The call is invalid, one or more of the
* following are true:
* \arg msg_handle is invalid.
- * \arg msg_handle does not refer to a
- * \ref PSA_IPC_CALL message.
+ * \arg msg_handle does not refer to a request
+ * message.
* \arg invec_idx is equal to or greater than
* \ref PSA_MAX_IOVEC.
*/
@@ -630,10 +630,10 @@
}
/*
- * It is a fatal error if message handle does not refer to a PSA_IPC_CALL
+ * It is a fatal error if message handle does not refer to a request
* message
*/
- if (msg->msg.type != PSA_IPC_CALL) {
+ if (msg->msg.type < PSA_IPC_CALL) {
tfm_panic();
}
@@ -675,8 +675,8 @@
* \retval "Does not return" The call is invalid, one or more of the
* following are true:
* \arg msg_handle is invalid.
- * \arg msg_handle does not refer to a
- * \ref PSA_IPC_CALL message.
+ * \arg msg_handle does not refer to a request
+ * message.
* \arg outvec_idx is equal to or greater than
* \ref PSA_MAX_IOVEC.
* \arg The memory reference for buffer is invalid.
@@ -709,10 +709,10 @@
privileged = tfm_spm_partition_get_privileged_mode(partition->index);
/*
- * It is a fatal error if message handle does not refer to a PSA_IPC_CALL
+ * It is a fatal error if message handle does not refer to a request
* message
*/
- if (msg->msg.type != PSA_IPC_CALL) {
+ if (msg->msg.type < PSA_IPC_CALL) {
tfm_panic();
}
@@ -832,28 +832,6 @@
tfm_panic();
}
break;
- case PSA_IPC_CALL:
- /* Reply to PSA_IPC_CALL message. Return values are based on status */
- if (status == PSA_SUCCESS) {
- ret = PSA_SUCCESS;
- } else if ((status >= (INT32_MIN + 1)) &&
- (status <= (INT32_MIN + 127))) {
- tfm_panic();
- } else if ((status >= (INT32_MIN + 128)) && (status <= -1)) {
- ret = status;
- } else if ((status >= 1) && (status <= INT32_MAX)) {
- ret = status;
- } else {
- tfm_panic();
- }
-
- /*
- * The total number of bytes written to a single parameter must be
- * reported to the client by updating the len member of the psa_outvec
- * structure for the parameter before returning from psa_call().
- */
- update_caller_outvec_len(msg);
- break;
case PSA_IPC_DISCONNECT:
/* Service handle is not used anymore */
tfm_spm_free_conn_handle(service, msg->handle);
@@ -864,7 +842,31 @@
*/
break;
default:
- tfm_panic();
+ if (msg->msg.type >= PSA_IPC_CALL) {
+ /* Reply to a request message. Return values are based on status */
+ if (status == PSA_SUCCESS) {
+ ret = PSA_SUCCESS;
+ } else if ((status >= (INT32_MIN + 1)) &&
+ (status <= (INT32_MIN + 127))) {
+ tfm_panic();
+ } else if ((status >= (INT32_MIN + 128)) && (status <= -1)) {
+ ret = status;
+ } else if ((status >= 1) && (status <= INT32_MAX)) {
+ ret = status;
+ } else {
+ tfm_panic();
+ }
+
+ /*
+ * The total number of bytes written to a single parameter must be
+ * reported to the client by updating the len member of the
+ * psa_outvec structure for the parameter before returning from
+ * psa_call().
+ */
+ update_caller_outvec_len(msg);
+ } else {
+ tfm_panic();
+ }
}
tfm_event_wake(&msg->ack_evnt, ret);