Skip to content

Commit 358b763

Browse files
brooniewilldeacon
authored andcommitted
kselftest/arm64: Size sycall-abi buffers for the actual maximum VL
Our ABI opts to provide future proofing by defining a much larger SVE_VQ_MAX than the architecture actually supports. Since we use this define to control the size of our vector data buffers this results in a lot of overhead when we initialise which can be a very noticable problem in emulation, we fill buffers that are orders of magnitude larger than we will ever actually use even with virtual platforms that provide the full range of architecturally supported vector lengths. Define and use the actual architecture maximum to mitigate this. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 82e7882 commit 358b763

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

tools/testing/selftests/arm64/abi/syscall-abi.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,20 @@
2020

2121
#include "syscall-abi.h"
2222

23+
/*
24+
* The kernel defines a much larger SVE_VQ_MAX than is expressable in
25+
* the architecture, this creates a *lot* of overhead filling the
26+
* buffers (especially ZA) on emulated platforms so use the actual
27+
* architectural maximum instead.
28+
*/
29+
#define ARCH_SVE_VQ_MAX 16
30+
2331
static int default_sme_vl;
2432

2533
static int sve_vl_count;
26-
static unsigned int sve_vls[SVE_VQ_MAX];
34+
static unsigned int sve_vls[ARCH_SVE_VQ_MAX];
2735
static int sme_vl_count;
28-
static unsigned int sme_vls[SVE_VQ_MAX];
36+
static unsigned int sme_vls[ARCH_SVE_VQ_MAX];
2937

3038
extern void do_syscall(int sve_vl, int sme_vl);
3139

@@ -130,9 +138,9 @@ static int check_fpr(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
130138

131139
#define SVE_Z_SHARED_BYTES (128 / 8)
132140

133-
static uint8_t z_zero[__SVE_ZREG_SIZE(SVE_VQ_MAX)];
134-
uint8_t z_in[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)];
135-
uint8_t z_out[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)];
141+
static uint8_t z_zero[__SVE_ZREG_SIZE(ARCH_SVE_VQ_MAX)];
142+
uint8_t z_in[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(ARCH_SVE_VQ_MAX)];
143+
uint8_t z_out[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(ARCH_SVE_VQ_MAX)];
136144

137145
static void setup_z(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
138146
uint64_t svcr)
@@ -190,8 +198,8 @@ static int check_z(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
190198
return errors;
191199
}
192200

193-
uint8_t p_in[SVE_NUM_PREGS * __SVE_PREG_SIZE(SVE_VQ_MAX)];
194-
uint8_t p_out[SVE_NUM_PREGS * __SVE_PREG_SIZE(SVE_VQ_MAX)];
201+
uint8_t p_in[SVE_NUM_PREGS * __SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)];
202+
uint8_t p_out[SVE_NUM_PREGS * __SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)];
195203

196204
static void setup_p(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
197205
uint64_t svcr)
@@ -222,8 +230,8 @@ static int check_p(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
222230
return errors;
223231
}
224232

225-
uint8_t ffr_in[__SVE_PREG_SIZE(SVE_VQ_MAX)];
226-
uint8_t ffr_out[__SVE_PREG_SIZE(SVE_VQ_MAX)];
233+
uint8_t ffr_in[__SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)];
234+
uint8_t ffr_out[__SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)];
227235

228236
static void setup_ffr(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
229237
uint64_t svcr)
@@ -300,8 +308,8 @@ static int check_svcr(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
300308
return errors;
301309
}
302310

303-
uint8_t za_in[ZA_SIG_REGS_SIZE(SVE_VQ_MAX)];
304-
uint8_t za_out[ZA_SIG_REGS_SIZE(SVE_VQ_MAX)];
311+
uint8_t za_in[ZA_SIG_REGS_SIZE(ARCH_SVE_VQ_MAX)];
312+
uint8_t za_out[ZA_SIG_REGS_SIZE(ARCH_SVE_VQ_MAX)];
305313

306314
static void setup_za(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
307315
uint64_t svcr)
@@ -470,9 +478,9 @@ void sve_count_vls(void)
470478
return;
471479

472480
/*
473-
* Enumerate up to SVE_VQ_MAX vector lengths
481+
* Enumerate up to ARCH_SVE_VQ_MAX vector lengths
474482
*/
475-
for (vq = SVE_VQ_MAX; vq > 0; vq /= 2) {
483+
for (vq = ARCH_SVE_VQ_MAX; vq > 0; vq /= 2) {
476484
vl = prctl(PR_SVE_SET_VL, vq * 16);
477485
if (vl == -1)
478486
ksft_exit_fail_msg("PR_SVE_SET_VL failed: %s (%d)\n",
@@ -496,9 +504,9 @@ void sme_count_vls(void)
496504
return;
497505

498506
/*
499-
* Enumerate up to SVE_VQ_MAX vector lengths
507+
* Enumerate up to ARCH_SVE_VQ_MAX vector lengths
500508
*/
501-
for (vq = SVE_VQ_MAX; vq > 0; vq /= 2) {
509+
for (vq = ARCH_SVE_VQ_MAX; vq > 0; vq /= 2) {
502510
vl = prctl(PR_SME_SET_VL, vq * 16);
503511
if (vl == -1)
504512
ksft_exit_fail_msg("PR_SME_SET_VL failed: %s (%d)\n",

0 commit comments

Comments
 (0)