From 9576fa93a2effc23a533b80dce41d7104a8d200b Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Wed, 8 Dec 2021 14:27:40 +0000 Subject: [PATCH] feat(spmd): enable SPMD to forward FFA_VERSION to EL3 SPMC In order to allow the EL3 SPMC to know the FF-A version of the entity running in the normal world, allow the SPMD to forward the call rather than replying on its behalf. This solution works as the EL3 can ERET directly back to the calling partition however this is not an option when the SPMC resides in a lower exception level. A new approach will be required to support such scenario. Signed-off-by: Marc Bonnici Change-Id: Ic2d6e49c06340167eadefe893c6e1e20b67ab498 --- services/std_svc/spmd/spmd_main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/services/std_svc/spmd/spmd_main.c b/services/std_svc/spmd/spmd_main.c index 5b131cd5e..777a96203 100644 --- a/services/std_svc/spmd/spmd_main.c +++ b/services/std_svc/spmd/spmd_main.c @@ -626,7 +626,8 @@ uint64_t spmd_smc_handler(uint32_t smc_fid, * If caller is secure and SPMC was initialized, * return FFA_VERSION of SPMD. * If caller is non secure and SPMC was initialized, - * return SPMC's version. + * forward to the EL3 SPMC if enabled, otherwise return + * the SPMC version if implemented at a lower EL. * Sanity check to "input_version". * If the EL3 SPMC is enabled, ignore the SPMC state as * this is not used. @@ -635,6 +636,17 @@ uint64_t spmd_smc_handler(uint32_t smc_fid, (!is_spmc_at_el3() && (ctx->state == SPMC_STATE_RESET))) { ret = FFA_ERROR_NOT_SUPPORTED; } else if (!secure_origin) { + if (is_spmc_at_el3()) { + /* + * Forward the call directly to the EL3 SPMC, if + * enabled, as we don't need to wrap the call in + * a direct request. + */ + return spmd_smc_forward(smc_fid, secure_origin, + x1, x2, x3, x4, cookie, + handle, flags); + } + gp_regs_t *gpregs = get_gpregs_ctx(&ctx->cpu_ctx); uint64_t rc;