From 55a296387b9720855df429a08c886f47a4a45057 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Mon, 13 Dec 2021 11:08:59 +0000 Subject: [PATCH] feat(spmc): add FFA_FEATURES handler Enable the spmc to report the features that it currently supports. Populated with the currently implemented functionality. Signed-off-by: Marc Bonnici Change-Id: I00e51ded284efd87cd50a0e9416dbc33f22ced85 --- services/std_svc/spm/el3_spmc/spmc.h | 3 + services/std_svc/spm/el3_spmc/spmc_main.c | 74 +++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/services/std_svc/spm/el3_spmc/spmc.h b/services/std_svc/spm/el3_spmc/spmc.h index 1afd6880a..d383a65c4 100644 --- a/services/std_svc/spm/el3_spmc/spmc.h +++ b/services/std_svc/spm/el3_spmc/spmc.h @@ -37,6 +37,9 @@ #define FFA_WB_TYPE_S2RAM 0 #define FFA_WB_TYPE_NOTS2RAM 1 +/* FF-A Related helper macros. */ +#define FFA_FEATURES_BIT31_MASK U(0x1u << 31) + #define FFA_PAGE_SIZE (4096) #define FFA_RXTX_PAGE_COUNT_MASK 0x1F diff --git a/services/std_svc/spm/el3_spmc/spmc_main.c b/services/std_svc/spm/el3_spmc/spmc_main.c index ece4df951..dd08f8d7e 100644 --- a/services/std_svc/spm/el3_spmc/spmc_main.c +++ b/services/std_svc/spm/el3_spmc/spmc_main.c @@ -976,6 +976,76 @@ err: return spmc_ffa_error_return(handle, ret); } +static uint64_t ffa_features_handler(uint32_t smc_fid, + bool secure_origin, + uint64_t x1, + uint64_t x2, + uint64_t x3, + uint64_t x4, + void *cookie, + void *handle, + uint64_t flags) +{ + uint32_t function_id = (uint32_t) x1; + uint32_t input_properties = (uint32_t) x2; + + /* + * We don't currently support any additional input properties + * for any ABI therefore ensure this value is always set to 0. + */ + if (input_properties != 0) { + return spmc_ffa_error_return(handle, FFA_ERROR_NOT_SUPPORTED); + } + + /* Check if a Feature ID was requested. */ + if ((function_id & FFA_FEATURES_BIT31_MASK) == 0U) { + /* We currently don't support any additional features. */ + return spmc_ffa_error_return(handle, FFA_ERROR_NOT_SUPPORTED); + } + + /* Report if an FF-A ABI is supported. */ + switch (function_id) { + /* Supported features from both worlds. */ + case FFA_ERROR: + case FFA_SUCCESS_SMC32: + case FFA_FEATURES: + case FFA_VERSION: + case FFA_MSG_SEND_DIRECT_REQ_SMC32: + case FFA_MSG_SEND_DIRECT_REQ_SMC64: + case FFA_PARTITION_INFO_GET: + case FFA_RXTX_MAP_SMC32: + case FFA_RXTX_MAP_SMC64: + case FFA_RXTX_UNMAP: + + /* + * We are relying on the fact that the other registers + * will be set to 0 as these values align with the + * currently implemented features of the SPMC. If this + * changes this function must be extended to handle + * reporting the additional functionality. + */ + + SMC_RET1(handle, FFA_SUCCESS_SMC32); + /* Execution stops here. */ + + /* Supported ABIs only from the secure world. */ + case FFA_MSG_SEND_DIRECT_RESP_SMC32: + case FFA_MSG_SEND_DIRECT_RESP_SMC64: + case FFA_MSG_WAIT: + + if (!secure_origin) { + return spmc_ffa_error_return(handle, + FFA_ERROR_NOT_SUPPORTED); + } + SMC_RET1(handle, FFA_SUCCESS_SMC32); + /* Execution stops here. */ + + default: + return spmc_ffa_error_return(handle, + FFA_ERROR_NOT_SUPPORTED); + } +} + /******************************************************************************* * This function will parse the Secure Partition Manifest. From manifest, it * will fetch details for preparing Secure partition image context and secure @@ -1372,6 +1442,10 @@ uint64_t spmc_smc_handler(uint32_t smc_fid, return ffa_version_handler(smc_fid, secure_origin, x1, x2, x3, x4, cookie, handle, flags); + case FFA_FEATURES: + return ffa_features_handler(smc_fid, secure_origin, x1, x2, x3, + x4, cookie, handle, flags); + case FFA_MSG_SEND_DIRECT_REQ_SMC32: case FFA_MSG_SEND_DIRECT_REQ_SMC64: return direct_req_smc_handler(smc_fid, secure_origin, x1, x2,