4 * Test the SVE width setting ioctls work and provide a base for
7 * Copyright (c) 2019 Linaro Ltd
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 #include <sys/prctl.h>
12 #include <asm/hwcap.h>
19 #define HWCAP_CPUID (1 << 11)
22 #define SVE_MAX_QUADS (2048 / 128)
23 #define BYTES_PER_QUAD (128 / 8)
25 #define get_cpu_reg(id) ({ \
26 unsigned long __val; \
27 asm("mrs %0, "#id : "=r" (__val)); \
31 static int do_sve_ioctl_test(void)
35 res
= prctl(PR_SVE_GET_VL
, 0, 0, 0, 0);
37 printf("FAILED to PR_SVE_GET_VL (%d)", res
);
40 init_vq
= res
& PR_SVE_VL_LEN_MASK
;
42 for (i
= init_vq
; i
> 15; i
/= 2) {
43 printf("Checking PR_SVE_SET_VL=%d\n", i
);
44 res
= prctl(PR_SVE_SET_VL
, i
, 0, 0, 0, 0);
46 printf("FAILED to PR_SVE_SET_VL (%d)", res
);
49 asm("index z0.b, #0, #1\n"
50 ".global __sve_ld_done\n"
53 : /* no outputs kept */
61 int main(int argc
, char **argv
)
63 /* we also need to probe for the ioctl support */
64 if (getauxval(AT_HWCAP
) & HWCAP_SVE
) {
65 return do_sve_ioctl_test();
67 printf("SKIP: no HWCAP_SVE on this system\n");