feat(runtime): handle SVE hint bit passed in RMI SMCs
Extract the SVE hint bit passed in RMI SMC function id and update it
to the NS SIMD context.
This SVE hint bit will be later used while saving or restoring NS SIMD
context.
Signed-off-by: Arunachalam Ganapathy <arunachalam.ganapathy@arm.com>
Change-Id: If4dd5c3c0c8108c48e2bea6ed241e0c0cd51883b
diff --git a/runtime/core/handler.c b/runtime/core/handler.c
index 2d9fa6d..4190060 100644
--- a/runtime/core/handler.c
+++ b/runtime/core/handler.c
@@ -155,7 +155,7 @@
static bool rmi_call_log_enabled = true;
-static inline bool rmi_handler_needs_fpu(unsigned long id)
+static inline bool rmi_handler_needs_fpu(unsigned int id)
{
#ifdef RMM_FPU_USE_AT_REL2
if (id == SMC_RMM_REALM_CREATE || id == SMC_RMM_DATA_CREATE ||
@@ -168,12 +168,12 @@
return false;
}
-static void rmi_log_on_exit(unsigned long handler_id,
+static void rmi_log_on_exit(unsigned int handler_id,
unsigned long args[],
struct smc_result *res)
{
const struct smc_handler *handler = &smc_handlers[handler_id];
- unsigned long function_id = SMC64_RMI_FID(handler_id);
+ unsigned int function_id = SMC64_RMI_FID(handler_id);
return_code_t rc;
unsigned int num;
@@ -235,7 +235,7 @@
}
}
-void handle_ns_smc(unsigned long function_id,
+void handle_ns_smc(unsigned int function_id,
unsigned long arg0,
unsigned long arg1,
unsigned long arg2,
@@ -245,13 +245,17 @@
struct smc_result *res)
{
(void)arg5;
- unsigned long handler_id;
+ unsigned int handler_id;
const struct smc_handler *handler = NULL;
bool restore_ns_simd_state = false;
struct simd_context *ns_simd_ctx;
+ bool sve_hint = false;
- /* Ignore SVE hint bit, until RMM supports SVE hint bit */
- function_id &= ~SMC_SVE_HINT;
+ /* Save the SVE hint bit and clear it from the function ID */
+ if ((function_id & SMC_SVE_HINT) != 0U) {
+ sve_hint = true;
+ function_id &= ~SMC_SVE_HINT;
+ }
if (IS_SMC64_RMI_FID(function_id)) {
handler_id = RMI_HANDLER_ID(function_id);
@@ -265,7 +269,7 @@
* for not implemented 'function_id' calls in SMC RMI range.
*/
if ((handler == NULL) || (handler->fn_dummy == NULL)) {
- VERBOSE("[%s] unknown function_id: %lx\n",
+ VERBOSE("[%s] unknown function_id: %x\n",
__func__, function_id);
res->x[0] = SMC_UNKNOWN;
return;
@@ -279,6 +283,9 @@
/* Get current CPU's NS SIMD context */
ns_simd_ctx = get_cpu_ns_simd_context();
+ /* Set or clear SVE hint bit in the NS SIMD context */
+ simd_update_smc_sve_hint(ns_simd_ctx, sve_hint);
+
/* If the handler needs FPU, actively save NS simd context. */
if (rmi_handler_needs_fpu(function_id) == true) {
simd_context_save(ns_simd_ctx);