aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Bonnici <marc.bonnici@arm.com>2022-02-21 15:02:36 +0000
committerMarc Bonnici <marc.bonnici@arm.com>2022-05-19 15:02:47 +0100
commita8be4cd057bce5f0b4ac6af396c0c870474d1ef4 (patch)
tree0c7f869b78491c7838a5d460e016322e6ed0c757
parent0560b53e71ab6daefa8e75665a718605478746a4 (diff)
downloadtrusted-firmware-a-a8be4cd057bce5f0b4ac6af396c0c870474d1ef4.tar.gz
feat(fvp): add plat hook for memory transactions
Add call to platform hooks upon successful transmission of a memory transaction request and as part of a memory reclaim request. This allows for platform specific functionality to be performed accordingly. Note the hooks must be placed in the initial share request and final reclaim to prevent order dependencies with operations that may take place in the normal world without visibility of the SPMC. Add a dummy implementation to the FVP platform. Signed-off-by: Marc Bonnici <marc.bonnici@arm.com> Change-Id: I0c7441a9fdf953c4db0651512e5e2cdbc6656c79
-rw-r--r--plat/arm/board/fvp/fvp_el3_spmc.c19
-rw-r--r--services/std_svc/spm/el3_spmc/spmc_shared_mem.c13
-rw-r--r--services/std_svc/spm/el3_spmc/spmc_shared_mem.h2
3 files changed, 34 insertions, 0 deletions
diff --git a/plat/arm/board/fvp/fvp_el3_spmc.c b/plat/arm/board/fvp/fvp_el3_spmc.c
index da090c0dc5..2b347ed62e 100644
--- a/plat/arm/board/fvp/fvp_el3_spmc.c
+++ b/plat/arm/board/fvp/fvp_el3_spmc.c
@@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <services/el3_spmc_ffa_memory.h>
#include <platform_def.h>
@@ -26,3 +27,21 @@ int plat_spmc_shmem_datastore_get(uint8_t **datastore, size_t *size)
*size = PLAT_SPMC_SHMEM_DATASTORE_SIZE;
return 0;
}
+
+/*
+ * Add dummy implementations of memory management related platform hooks.
+ * These can be used to implement platform specific functionality to support
+ * a memory sharing/lending operation.
+ *
+ * Note: The hooks must be located as part of the initial share request and
+ * final reclaim to prevent order dependencies with operations that may take
+ * place in the normal world without visibility of the SPMC.
+ */
+int plat_spmc_shmem_begin(struct ffa_mtd *desc)
+{
+ return 0;
+}
+int plat_spmc_shmem_reclaim(struct ffa_mtd *desc)
+{
+ return 0;
+}
diff --git a/services/std_svc/spm/el3_spmc/spmc_shared_mem.c b/services/std_svc/spm/el3_spmc/spmc_shared_mem.c
index 7b9a5265e8..1602981bf3 100644
--- a/services/std_svc/spm/el3_spmc/spmc_shared_mem.c
+++ b/services/std_svc/spm/el3_spmc/spmc_shared_mem.c
@@ -1031,6 +1031,12 @@ static long spmc_ffa_fill_desc(struct mailbox *mbox,
}
}
+ /* Allow for platform specific operations to be performed. */
+ ret = plat_spmc_shmem_begin(&obj->desc);
+ if (ret != 0) {
+ goto err_arg;
+ }
+
SMC_RET8(smc_handle, FFA_SUCCESS_SMC32, 0, handle_low, handle_high, 0,
0, 0, 0);
@@ -1788,6 +1794,13 @@ int spmc_ffa_mem_reclaim(uint32_t smc_fid,
ret = FFA_ERROR_DENIED;
goto err_unlock;
}
+
+ /* Allow for platform specific operations to be performed. */
+ ret = plat_spmc_shmem_reclaim(&obj->desc);
+ if (ret != 0) {
+ goto err_unlock;
+ }
+
spmc_shmem_obj_free(&spmc_shmem_obj_state, obj);
spin_unlock(&spmc_shmem_obj_state.lock);
diff --git a/services/std_svc/spm/el3_spmc/spmc_shared_mem.h b/services/std_svc/spm/el3_spmc/spmc_shared_mem.h
index 8571e9436e..839f7a140b 100644
--- a/services/std_svc/spm/el3_spmc/spmc_shared_mem.h
+++ b/services/std_svc/spm/el3_spmc/spmc_shared_mem.h
@@ -48,6 +48,8 @@ struct spmc_shmem_obj_state {
};
extern struct spmc_shmem_obj_state spmc_shmem_obj_state;
+extern int plat_spmc_shmem_begin(struct ffa_mtd *desc);
+extern int plat_spmc_shmem_reclaim(struct ffa_mtd *desc);
long spmc_ffa_mem_send(uint32_t smc_fid,
bool secure_origin,