Core: Save iovec in SPM database
For each secure service call save the iovec parameters in the
partition's runtime context.
When the secure function is called, the saved iovec arguments are
passed to it on the called partition's stack.
Change-Id: I754dc330db907ce8c16d425ac9c017b53301a6b9
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index f0034af..e1a024f 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -9,6 +9,7 @@
#define __SPM_API_H__
/* This file contains the apis exported by the SPM to tfm core */
+#include "tfm_api.h"
#include "spm_partition_defs.h"
#include "secure_fw/core/tfm_secure_api.h"
@@ -37,6 +38,20 @@
};
/**
+ * \brief Holds the iovec parameters that are passed to a service
+ *
+ * \note The size of the structure is (and have to be) multiple of 8 bytes
+ */
+struct iovec_args_t {
+ psa_invec in_vec[PSA_MAX_IOVEC]; /*!< Array of psa_invec objects */
+ size_t in_len; /*!< Number psa_invec objects in in_vec
+ */
+ psa_outvec out_vec[PSA_MAX_IOVEC]; /*!< Array of psa_outvec objects */
+ size_t out_len; /*!< Number psa_outvec objects in out_vec
+ */
+};
+
+/**
* \brief Runtime context information of a partition
*/
struct spm_partition_runtime_data_t {
@@ -46,6 +61,8 @@
uint32_t share;
uint32_t stack_ptr;
uint32_t lr;
+ struct iovec_args_t iovec_args;
+ psa_outvec *orig_outvec;
};
@@ -59,6 +76,7 @@
*/
uint32_t get_partition_idx(uint32_t partition_id);
+#if TFM_LVL != 1
/**
* \brief Configure isolated sandbox for a partition
*
@@ -104,28 +122,6 @@
uint32_t tfm_spm_partition_get_stack_top(uint32_t partition_idx);
/**
- * \brief Get the id of the partition for its index from the db
- *
- * \param[in] partition_idx Partition index
- *
- * \return Partition ID for that partition
- *
- * \note This function doesn't check if partition_idx is valid.
- */
-uint32_t tfm_spm_partition_get_partition_id(uint32_t partition_idx);
-
-/**
- * \brief Get the flags associated with a partition
- *
- * \param[in] partition_idx Partition index
- *
- * \return Flags associated with the partition
- *
- * \note This function doesn't check if partition_idx is valid.
- */
-uint32_t tfm_spm_partition_get_flags(uint32_t partition_idx);
-
-/**
* \brief Get the start of the zero-initialised region for a partition
*
* \param[in] partition_idx Partition idx
@@ -172,6 +168,28 @@
uint32_t tfm_spm_partition_get_rw_limit(uint32_t partition_idx);
/**
+ * \brief Save stack pointer for partition in database
+ *
+ * \param[in] partition_idx Partition index
+ * \param[in] stack_ptr Stack pointer to be stored
+ *
+ * \note This function doesn't check if partition_idx is valid.
+ */
+void tfm_spm_partition_set_stack(uint32_t partition_id, uint32_t stack_ptr);
+#endif
+
+/**
+ * \brief Get the flags associated with a partition
+ *
+ * \param[in] partition_idx Partition index
+ *
+ * \return Flags associated with the partition
+ *
+ * \note This function doesn't check if partition_idx is valid.
+ */
+uint32_t tfm_spm_partition_get_flags(uint32_t partition_idx);
+
+/**
* \brief Get the current runtime data of a partition
*
* \param[in] partition_idx Partition index
@@ -192,16 +210,6 @@
uint32_t tfm_spm_partition_get_running_partition_idx(void);
/**
- * \brief Save stack pointer for partition in database
- *
- * \param[in] partition_idx Partition index
- * \param[in] stack_ptr Stack pointer to be stored
- *
- * \note This function doesn't check if partition_idx is valid.
- */
-void tfm_spm_partition_set_stack(uint32_t partition_id, uint32_t stack_ptr);
-
-/**
* \brief Save stack pointer and link register for partition in database
*
* \param[in] partition_idx Partition index
@@ -214,6 +222,17 @@
uint32_t stack_ptr, uint32_t lr);
/**
+ * \brief Get the id of the partition for its index from the db
+ *
+ * \param[in] partition_idx Partition index
+ *
+ * \return Partition ID for that partition
+ *
+ * \note This function doesn't check if partition_idx is valid.
+ */
+uint32_t tfm_spm_partition_get_partition_id(uint32_t partition_idx);
+
+/**
* \brief Set the current state of a partition
*
* \param[in] partition_idx Partition index
@@ -261,6 +280,24 @@
uint32_t share);
/**
+ * \brief Set the iovec parameters for the partition
+ *
+ * \param[in] partition_idx Partition index
+ * \param[in] args The arguments of the secure function
+ *
+ * args is expected to be of type int32_t[4] where:
+ * args[0] is in_vec
+ * args[1] is in_len
+ * args[2] is out_vec
+ * args[3] is out_len
+ *
+ * \note This function doesn't check if partition_idx is valid.
+ * \note This function assumes that the iovecs that are passed in args are
+ * valid, and does no sanity check on them at all.
+ */
+void tfm_spm_partition_set_iovec(uint32_t partition_idx, int32_t *args);
+
+/**
* \brief Initialize partition database
*
* \return Error code \ref spm_err_t