lib: arm_ffa: Downgrade our FF-A version if lower am: 3125f55536

Original change: https://android-review.googlesource.com/c/trusty/lk/trusty/+/3525257

Change-Id: I1c742ccfc328356e1c0e549d71fa589ba304f089
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/lib/arm_ffa/arm_ffa.c b/lib/arm_ffa/arm_ffa.c
index 033d51a..dd38f84 100644
--- a/lib/arm_ffa/arm_ffa.c
+++ b/lib/arm_ffa/arm_ffa.c
@@ -1186,8 +1186,13 @@
     }
 
     ffa_version = FFA_VERSION(ver_major_ret, ver_minor_ret);
-    LTRACEF("Negotiated FF-A version %" PRIu16 ".%" PRIu16 "\n", ver_major_ret,
-            ver_minor_ret);
+    if (ffa_version > FFA_CURRENT_VERSION) {
+        /* The SPMC supports a newer version, downgrade us */
+        ffa_version = FFA_CURRENT_VERSION;
+    }
+    LTRACEF("Negotiated FF-A version %" PRIu16 ".%" PRIu16 "\n",
+            FFA_VERSION_TO_MAJOR(ffa_version),
+            FFA_VERSION_TO_MINOR(ffa_version));
 
     res = arm_ffa_call_id_get(&ffa_local_id);
     if (res != NO_ERROR) {