fix(sve): discover the SVE vector length

Currently the (SPM) test that the SVE vectors are preserved
assumes that the SVE vector length is whatever the hard
coded maximum vector length we have at build time is,
currently 512 bits. The tests fill a buffer that can
hold the full set of maximally sized vectors, load it
into the registers, do a call and then read the values
back into a separate buffer and compare with the original
buffer. If the VL is less than the maximum then this
comparison will fail since only the subset of the read
buffer used by the actual vector length will be filled.

Fix this by reading the SVE vector length at runtime and
using that when verifying the read data rather than the
hard coded maximum value.

Increase the SVE test buffers to the maximum permitted by
the architecture. Configure ZCR_EL2.LEN to the maximum
permitted value (to the limit of the implementation and
EL3 constraint).

Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I1d96327d3423f2f8a3d7289ae02ab06a4bf9fde3
diff --git a/include/runtime_services/spm_common.h b/include/runtime_services/spm_common.h
index cb4fb4d..7a81e9c 100644
--- a/include/runtime_services/spm_common.h
+++ b/include/runtime_services/spm_common.h
@@ -14,6 +14,8 @@
 
 #include <ffa_helpers.h>
 
+#include <lib/extensions/sve.h>
+
 /* Hypervisor ID at physical FFA instance */
 #define HYP_ID          (0)
 /* SPMC ID */
@@ -94,17 +96,14 @@
 void dump_ffa_value(struct ffa_value ret);
 
 /*
- * Vector length:
+ * Max. vector length:
  * SIMD: 128 bits = 16 bytes
- * SVE:	 512 bits = 64 bytes
  */
 #define SIMD_VECTOR_LEN_BYTES		16
-#define SVE_VECTOR_LEN_BYTES		64
 
 #define SIMD_NUM_VECTORS		32
-#define SVE_NUM_VECTORS			32
+
 typedef uint8_t simd_vector_t[SIMD_VECTOR_LEN_BYTES];
-typedef uint8_t sve_vector_t[SVE_VECTOR_LEN_BYTES];
 
 /*
  * Fills SIMD/SVE registers with the content of the container v.