Merge pull request #1100 from ajs-sun/master
trusty: save/restore FPU registers in world switch
diff --git a/services/spd/trusty/trusty.c b/services/spd/trusty/trusty.c
index e386f71..ecbcfae 100644
--- a/services/spd/trusty/trusty.c
+++ b/services/spd/trusty/trusty.c
@@ -99,6 +99,16 @@
ret.r1 = r1;
ret.r0 = r0;
+ /*
+ * To avoid the additional overhead in PSCI flow, skip FP context
+ * saving/restoring in case of CPU suspend and resume, asssuming that
+ * when it's needed the PSCI caller has preserved FP context before
+ * going here.
+ */
+#if CTX_INCLUDE_FPREGS
+ if (r0 != SMC_FC_CPU_SUSPEND && r0 != SMC_FC_CPU_RESUME)
+ fpregs_context_save(get_fpregs_ctx(cm_get_context(security_state)));
+#endif
cm_el1_sysregs_context_save(security_state);
ctx->saved_security_state = security_state;
@@ -107,6 +117,11 @@
assert(ctx->saved_security_state == !security_state);
cm_el1_sysregs_context_restore(security_state);
+#if CTX_INCLUDE_FPREGS
+ if (r0 != SMC_FC_CPU_SUSPEND && r0 != SMC_FC_CPU_RESUME)
+ fpregs_context_restore(get_fpregs_ctx(cm_get_context(security_state)));
+#endif
+
cm_set_next_eret_context(security_state);
return ret;