From a8be4cd057bce5f0b4ac6af396c0c870474d1ef4 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Mon, 21 Feb 2022 15:02:36 +0000 Subject: [PATCH] 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 Change-Id: I0c7441a9fdf953c4db0651512e5e2cdbc6656c79 --- plat/arm/board/fvp/fvp_el3_spmc.c | 19 +++++++++++++++++++ .../std_svc/spm/el3_spmc/spmc_shared_mem.c | 13 +++++++++++++ .../std_svc/spm/el3_spmc/spmc_shared_mem.h | 2 ++ 3 files changed, 34 insertions(+) diff --git a/plat/arm/board/fvp/fvp_el3_spmc.c b/plat/arm/board/fvp/fvp_el3_spmc.c index da090c0dc..2b347ed62 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 #include @@ -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 7b9a5265e..1602981bf 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 8571e9436..839f7a140 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,