Lines Matching +full:static +full:- +full:config
1 // SPDX-License-Identifier: GPL-2.0-only
32 #include "fp-ptrace.h"
108 static bool got_alarm;
110 static void handle_alarm(int sig, siginfo_t *info, void *context) in handle_alarm()
116 static __uint128_t arm64_cpu_to_le128(__uint128_t x) in arm64_cpu_to_le128()
124 static __uint128_t arm64_cpu_to_le128(__uint128_t x) in arm64_cpu_to_le128()
132 static bool sve_supported(void) in sve_supported()
137 static bool sme_supported(void) in sme_supported()
142 static bool sme2_supported(void) in sme2_supported()
147 static bool fa64_supported(void) in fa64_supported()
152 static bool fpmr_supported(void) in fpmr_supported()
157 static bool compare_buffer(const char *name, void *out, in compare_buffer()
196 bool (*supported)(struct test_config *config);
197 void (*set_expected_values)(struct test_config *config);
201 static int vl_in(struct test_config *config) in vl_in() argument
205 if (config->svcr_in & SVCR_SM) in vl_in()
206 vl = config->sme_vl_in; in vl_in()
208 vl = config->sve_vl_in; in vl_in()
213 static int vl_expected(struct test_config *config) in vl_expected() argument
217 if (config->svcr_expected & SVCR_SM) in vl_expected()
218 vl = config->sme_vl_expected; in vl_expected()
220 vl = config->sve_vl_expected; in vl_expected()
225 static void run_child(struct test_config *config) in run_child() argument
237 ret = prctl(PR_SVE_SET_VL, config->sve_vl_in); in run_child()
238 if (ret != config->sve_vl_in) { in run_child()
240 config->sve_vl_in, ret); in run_child()
245 ret = prctl(PR_SME_SET_VL, config->sme_vl_in); in run_child()
246 if (ret != config->sme_vl_in) { in run_child()
248 config->sme_vl_in, ret); in run_child()
270 static void read_one_child_regs(pid_t child, char *name, in read_one_child_regs()
274 int len = iov_parent->iov_len; in read_one_child_regs()
278 if (ret == -1) in read_one_child_regs()
285 static void read_child_regs(pid_t child) in read_child_regs()
362 static bool continue_breakpoint(pid_t child, in continue_breakpoint()
399 static bool check_ptrace_values_sve(pid_t child, struct test_config *config) in check_ptrace_values_sve() argument
410 vq = __sve_vq_from_vl(config->sve_vl_in); in check_ptrace_values_sve()
430 if (sve->vl != config->sve_vl_in) { in check_ptrace_values_sve()
432 sve->vl, config->sve_vl_in); in check_ptrace_values_sve()
437 if ((config->svcr_in & SVCR_SM) && (sve->flags & SVE_PT_REGS_SVE)) { in check_ptrace_values_sve()
443 if (sve->size != sizeof(sve)) { in check_ptrace_values_sve()
448 if (sve->size != SVE_PT_SIZE(vq, sve->flags)) { in check_ptrace_values_sve()
450 sve->size, SVE_PT_SIZE(vq, sve->flags)); in check_ptrace_values_sve()
456 if (sve->flags & SVE_PT_REGS_SVE) { in check_ptrace_values_sve()
473 if (!compare_buffer("initial V via SVE", &fpsimd->vregs[0], in check_ptrace_values_sve()
483 static bool check_ptrace_values_ssve(pid_t child, struct test_config *config) in check_ptrace_values_ssve() argument
494 vq = __sve_vq_from_vl(config->sme_vl_in); in check_ptrace_values_ssve()
514 if (sve->vl != config->sme_vl_in) { in check_ptrace_values_ssve()
516 sve->vl, config->sme_vl_in); in check_ptrace_values_ssve()
520 if ((config->svcr_in & SVCR_SM) && !(sve->flags & SVE_PT_REGS_SVE)) { in check_ptrace_values_ssve()
526 if (sve->size != sizeof(sve)) { in check_ptrace_values_ssve()
531 if (sve->size != SVE_PT_SIZE(vq, sve->flags)) { in check_ptrace_values_ssve()
533 sve->size, SVE_PT_SIZE(vq, sve->flags)); in check_ptrace_values_ssve()
539 if (sve->flags & SVE_PT_REGS_SVE) { in check_ptrace_values_ssve()
557 &fpsimd->vregs[0], v_in, sizeof(v_in))) in check_ptrace_values_ssve()
566 static bool check_ptrace_values_za(pid_t child, struct test_config *config) in check_ptrace_values_za() argument
576 vq = __sve_vq_from_vl(config->sme_vl_in); in check_ptrace_values_za()
596 if (za->vl != config->sme_vl_in) { in check_ptrace_values_za()
598 za->vl, config->sme_vl_in); in check_ptrace_values_za()
603 if (config->svcr_in & SVCR_ZA) { in check_ptrace_values_za()
604 if (za->size != ZA_PT_SIZE(vq)) { in check_ptrace_values_za()
606 za->size, ZA_PT_SIZE(vq)); in check_ptrace_values_za()
615 if (za->size != sizeof(*za)) { in check_ptrace_values_za()
617 za->size, sizeof(*za)); in check_ptrace_values_za()
627 static bool check_ptrace_values_zt(pid_t child, struct test_config *config) in check_ptrace_values_zt() argument
648 static bool check_ptrace_values_fpmr(pid_t child, struct test_config *config) in check_ptrace_values_fpmr() argument
669 static bool check_ptrace_values(pid_t child, struct test_config *config) in check_ptrace_values() argument
690 if (!check_ptrace_values_sve(child, config)) in check_ptrace_values()
693 if (!check_ptrace_values_ssve(child, config)) in check_ptrace_values()
696 if (!check_ptrace_values_za(child, config)) in check_ptrace_values()
699 if (!check_ptrace_values_zt(child, config)) in check_ptrace_values()
702 if (!check_ptrace_values_fpmr(child, config)) in check_ptrace_values()
708 static bool run_parent(pid_t child, struct test_definition *test, in run_parent()
709 struct test_config *config) in run_parent() argument
744 pass = check_ptrace_values(child, config); in run_parent()
747 if (test->modify_values) in run_parent()
748 test->modify_values(child, config); in run_parent()
860 static void fill_random(void *buf, size_t size) in fill_random()
870 static void fill_random_ffr(void *buf, size_t vq) in fill_random_ffr()
886 lbuf[i] = (1 << (bits % 8)) - 1; in fill_random_ffr()
889 static void fpsimd_to_sve(__uint128_t *v, char *z, int vl) in fpsimd_to_sve()
904 static void set_initial_values(struct test_config *config) in set_initial_values() argument
906 int vq = __sve_vq_from_vl(vl_in(config)); in set_initial_values()
907 int sme_vq = __sve_vq_from_vl(config->sme_vl_in); in set_initial_values()
909 svcr_in = config->svcr_in; in set_initial_values()
910 svcr_expected = config->svcr_expected; in set_initial_values()
918 if (sve_supported() || (config->svcr_in & SVCR_SM)) { in set_initial_values()
921 fpsimd_to_sve(v_in, z_in, vl_in(config)); in set_initial_values()
929 if ((config->svcr_in & SVCR_SM) && !fa64_supported()) in set_initial_values()
937 if (config->svcr_in & SVCR_ZA) in set_initial_values()
941 if (config->svcr_expected & SVCR_ZA) in set_initial_values()
949 if (config->svcr_in & SVCR_ZA) in set_initial_values()
953 if (config->svcr_expected & SVCR_ZA) in set_initial_values()
971 static bool check_memory_values(struct test_config *config) in check_memory_values() argument
979 vq = __sve_vq_from_vl(vl_expected(config)); in check_memory_values()
980 sme_vq = __sve_vq_from_vl(config->sme_vl_expected); in check_memory_values()
988 if (sve_vl_out != config->sve_vl_expected) { in check_memory_values()
990 sve_vl_out, config->sve_vl_expected); in check_memory_values()
994 if (sme_vl_out != config->sme_vl_expected) { in check_memory_values()
996 sme_vl_out, config->sme_vl_expected); in check_memory_values()
1028 static bool sve_sme_same(struct test_config *config) in sve_sme_same() argument
1030 if (config->sve_vl_in != config->sve_vl_expected) in sve_sme_same()
1033 if (config->sme_vl_in != config->sme_vl_expected) in sve_sme_same()
1036 if (config->svcr_in != config->svcr_expected) in sve_sme_same()
1042 static bool sve_write_supported(struct test_config *config) in sve_write_supported() argument
1047 if ((config->svcr_in & SVCR_ZA) != (config->svcr_expected & SVCR_ZA)) in sve_write_supported()
1050 if (config->svcr_expected & SVCR_SM) { in sve_write_supported()
1051 if (config->sve_vl_in != config->sve_vl_expected) { in sve_write_supported()
1056 if ((config->svcr_expected & SVCR_ZA) && in sve_write_supported()
1057 (config->sme_vl_in != config->sme_vl_expected)) { in sve_write_supported()
1061 if (config->sme_vl_in != config->sme_vl_expected) { in sve_write_supported()
1072 static bool sve_write_fpsimd_supported(struct test_config *config) in sve_write_fpsimd_supported() argument
1077 if ((config->svcr_in & SVCR_ZA) != (config->svcr_expected & SVCR_ZA)) in sve_write_fpsimd_supported()
1080 if (config->svcr_expected & SVCR_SM) in sve_write_fpsimd_supported()
1083 if (config->sme_vl_in != config->sme_vl_expected) in sve_write_fpsimd_supported()
1089 static void fpsimd_write_expected(struct test_config *config) in fpsimd_write_expected() argument
1096 vl = vl_expected(config); in fpsimd_write_expected()
1105 static void fpsimd_write(pid_t child, struct test_config *test_config) in fpsimd_write()
1117 if (ret == -1) in fpsimd_write()
1122 static bool fpmr_write_supported(struct test_config *config) in fpmr_write_supported() argument
1127 if (!sve_sme_same(config)) in fpmr_write_supported()
1133 static void fpmr_write_expected(struct test_config *config) in fpmr_write_expected() argument
1139 static void fpmr_write(pid_t child, struct test_config *config) in fpmr_write() argument
1152 static void sve_write_expected(struct test_config *config) in sve_write_expected() argument
1154 int vl = vl_expected(config); in sve_write_expected()
1155 int sme_vq = __sve_vq_from_vl(config->sme_vl_expected); in sve_write_expected()
1172 if (config->sme_vl_in != config->sme_vl_expected) { in sve_write_expected()
1178 static void sve_write_sve(pid_t child, struct test_config *config) in sve_write_sve() argument
1184 vl = vl_expected(config); in sve_write_sve()
1200 sve->size = iov.iov_len; in sve_write_sve()
1201 sve->flags = SVE_PT_REGS_SVE; in sve_write_sve()
1202 sve->vl = vl; in sve_write_sve()
1224 static void sve_write_fpsimd(pid_t child, struct test_config *config) in sve_write_fpsimd() argument
1231 vl = vl_expected(config); in sve_write_fpsimd()
1247 sve->size = iov.iov_len; in sve_write_fpsimd()
1248 sve->flags = SVE_PT_REGS_FPSIMD; in sve_write_fpsimd()
1249 sve->vl = vl; in sve_write_fpsimd()
1252 memcpy(&fpsimd->vregs, v_expected, sizeof(v_expected)); in sve_write_fpsimd()
1262 static bool za_write_supported(struct test_config *config) in za_write_supported() argument
1264 if ((config->svcr_in & SVCR_SM) != (config->svcr_expected & SVCR_SM)) in za_write_supported()
1270 static void za_write_expected(struct test_config *config) in za_write_expected() argument
1274 sme_vq = __sve_vq_from_vl(config->sme_vl_expected); in za_write_expected()
1276 if (config->svcr_expected & SVCR_ZA) { in za_write_expected()
1284 if (config->sme_vl_in != config->sme_vl_expected) { in za_write_expected()
1285 sve_vq = __sve_vq_from_vl(vl_expected(config)); in za_write_expected()
1291 fpsimd_to_sve(v_expected, z_expected, vl_expected(config)); in za_write_expected()
1295 static void za_write(pid_t child, struct test_config *config) in za_write() argument
1301 vq = __sve_vq_from_vl(config->sme_vl_expected); in za_write()
1303 if (config->svcr_expected & SVCR_ZA) in za_write()
1316 za->size = iov.iov_len; in za_write()
1317 za->vl = config->sme_vl_expected; in za_write()
1318 if (config->svcr_expected & SVCR_ZA) in za_write()
1330 static bool zt_write_supported(struct test_config *config) in zt_write_supported() argument
1334 if (config->sme_vl_in != config->sme_vl_expected) in zt_write_supported()
1336 if (!(config->svcr_expected & SVCR_ZA)) in zt_write_supported()
1338 if ((config->svcr_in & SVCR_SM) != (config->svcr_expected & SVCR_SM)) in zt_write_supported()
1344 static void zt_write_expected(struct test_config *config) in zt_write_expected() argument
1348 sme_vq = __sve_vq_from_vl(config->sme_vl_expected); in zt_write_expected()
1350 if (config->svcr_expected & SVCR_ZA) { in zt_write_expected()
1358 static void zt_write(pid_t child, struct test_config *config) in zt_write() argument
1372 static void run_test(struct test_definition *test, struct test_config *config) in run_test() argument
1379 snprintf(name, sizeof(name), "%s, SVE %d->%d, SME %d/%x->%d/%x", in run_test()
1380 test->name, in run_test()
1381 config->sve_vl_in, config->sve_vl_expected, in run_test()
1382 config->sme_vl_in, config->svcr_in, in run_test()
1383 config->sme_vl_expected, config->svcr_expected); in run_test()
1385 snprintf(name, sizeof(name), "%s, SVE %d->%d", test->name, in run_test()
1386 config->sve_vl_in, config->sve_vl_expected); in run_test()
1388 snprintf(name, sizeof(name), "%s, SME %d/%x->%d/%x", in run_test()
1389 test->name, in run_test()
1390 config->sme_vl_in, config->svcr_in, in run_test()
1391 config->sme_vl_expected, config->svcr_expected); in run_test()
1393 snprintf(name, sizeof(name), "%s", test->name); in run_test()
1395 if (test->supported && !test->supported(config)) { in run_test()
1400 set_initial_values(config); in run_test()
1402 if (test->set_expected_values) in run_test()
1403 test->set_expected_values(config); in run_test()
1411 run_child(config); in run_test()
1413 pass = run_parent(child, test, config); in run_test()
1414 if (!check_memory_values(config)) in run_test()
1420 static void run_tests(struct test_definition defs[], int count, in run_tests()
1421 struct test_config *config) in run_tests() argument
1426 run_test(&defs[i], config); in run_tests()
1429 static struct test_definition base_test_defs[] = {
1448 static struct test_definition sve_test_defs[] = {
1463 static struct test_definition za_test_defs[] = {
1472 static struct test_definition zt_test_defs[] = {
1481 static int sve_vls[MAX_NUM_VLS], sme_vls[MAX_NUM_VLS];
1482 static int sve_vl_count, sme_vl_count;
1484 static void probe_vls(const char *name, int vls[], int *vl_count, int set_vl) in probe_vls()
1493 if (vl == -1) in probe_vls()
1499 if (*vl_count && (vl == vls[*vl_count - 1])) in probe_vls()
1510 vls[1] = vls[*vl_count - 1]; in probe_vls()
1519 static struct {
1543 static void run_sve_tests(void) in run_sve_tests()
1573 static void run_sme_tests(void) in run_sme_tests()