summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorOlivier Deprez <olivier.deprez@arm.com>2022-07-08 10:24:39 +0200
committerOlivier Deprez <olivier.deprez@arm.com>2022-08-04 14:13:26 +0200
commit569be40971323c2de87f798bc7da3bee142c2009 (patch)
treea9c35323d71a9164e8a4f1972116713d5581a267 /include
parentf70e2912afc18f4f8e6697e36c2d9e9b7341ac5b (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/lib/extensions/sve.h32
-rw-r--r--include/runtime_services/spm_common.h9
2 files changed, 34 insertions, 7 deletions
diff --git a/include/lib/extensions/sve.h b/include/lib/extensions/sve.h
index 278dcf3..45481d7 100644
--- a/include/lib/extensions/sve.h
+++ b/include/lib/extensions/sve.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -10,4 +10,32 @@
#define fill_sve_helper(num) "ldr z"#num", [%0, #"#num", MUL VL];"
#define read_sve_helper(num) "str z"#num", [%0, #"#num", MUL VL];"
-#endif /* SVE_H */ \ No newline at end of file
+/*
+ * Max. vector length permitted by the architecture:
+ * SVE: 2048 bits = 256 bytes
+ */
+#define SVE_VECTOR_LEN_BYTES 256
+#define SVE_NUM_VECTORS 32
+
+typedef uint8_t sve_vector_t[SVE_VECTOR_LEN_BYTES];
+
+#ifdef __aarch64__
+
+/* Returns the SVE implemented VL in bytes (constrained by ZCR_EL3.LEN) */
+static inline uint64_t sve_vector_length_get(void)
+{
+ uint64_t vl;
+
+ __asm__ volatile(
+ ".arch_extension sve\n"
+ "rdvl %0, #1;"
+ ".arch_extension nosve\n"
+ : "=r" (vl)
+ );
+
+ return vl;
+}
+
+#endif /* __aarch64__ */
+
+#endif /* SVE_H */
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 @@ bool is_expected_cactus_response(struct ffa_value ret, uint32_t expected_resp,
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.