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()
442 if (sve->size != SVE_PT_SIZE(vq, sve->flags)) { in check_ptrace_values_sve()
444 sve->size, SVE_PT_SIZE(vq, sve->flags)); in check_ptrace_values_sve()
449 if (sve->flags & SVE_PT_REGS_SVE) { in check_ptrace_values_sve()
466 if (!compare_buffer("initial V via SVE", &fpsimd->vregs[0], in check_ptrace_values_sve()
476 static bool check_ptrace_values_ssve(pid_t child, struct test_config *config) in check_ptrace_values_ssve() argument
487 vq = __sve_vq_from_vl(config->sme_vl_in); in check_ptrace_values_ssve()
507 if (sve->vl != config->sme_vl_in) { in check_ptrace_values_ssve()
509 sve->vl, config->sme_vl_in); in check_ptrace_values_ssve()
513 if ((config->svcr_in & SVCR_SM) && !(sve->flags & SVE_PT_REGS_SVE)) { in check_ptrace_values_ssve()
518 if (sve->size != SVE_PT_SIZE(vq, sve->flags)) { in check_ptrace_values_ssve()
520 sve->size, SVE_PT_SIZE(vq, sve->flags)); in check_ptrace_values_ssve()
525 if (sve->flags & SVE_PT_REGS_SVE) { in check_ptrace_values_ssve()
543 &fpsimd->vregs[0], v_in, sizeof(v_in))) in check_ptrace_values_ssve()
552 static bool check_ptrace_values_za(pid_t child, struct test_config *config) in check_ptrace_values_za() argument
562 vq = __sve_vq_from_vl(config->sme_vl_in); in check_ptrace_values_za()
582 if (za->vl != config->sme_vl_in) { in check_ptrace_values_za()
584 za->vl, config->sme_vl_in); in check_ptrace_values_za()
589 if (config->svcr_in & SVCR_ZA) { in check_ptrace_values_za()
590 if (za->size != ZA_PT_SIZE(vq)) { in check_ptrace_values_za()
592 za->size, ZA_PT_SIZE(vq)); in check_ptrace_values_za()
601 if (za->size != sizeof(*za)) { in check_ptrace_values_za()
603 za->size, sizeof(*za)); in check_ptrace_values_za()
613 static bool check_ptrace_values_zt(pid_t child, struct test_config *config) in check_ptrace_values_zt() argument
634 static bool check_ptrace_values_fpmr(pid_t child, struct test_config *config) in check_ptrace_values_fpmr() argument
655 static bool check_ptrace_values(pid_t child, struct test_config *config) in check_ptrace_values() argument
676 if (!check_ptrace_values_sve(child, config)) in check_ptrace_values()
679 if (!check_ptrace_values_ssve(child, config)) in check_ptrace_values()
682 if (!check_ptrace_values_za(child, config)) in check_ptrace_values()
685 if (!check_ptrace_values_zt(child, config)) in check_ptrace_values()
688 if (!check_ptrace_values_fpmr(child, config)) in check_ptrace_values()
694 static bool run_parent(pid_t child, struct test_definition *test, in run_parent()
695 struct test_config *config) in run_parent() argument
730 pass = check_ptrace_values(child, config); in run_parent()
733 if (test->modify_values) in run_parent()
734 test->modify_values(child, config); in run_parent()
846 static void fill_random(void *buf, size_t size) in fill_random()
856 static void fill_random_ffr(void *buf, size_t vq) in fill_random_ffr()
872 lbuf[i] = (1 << (bits % 8)) - 1; in fill_random_ffr()
875 static void fpsimd_to_sve(__uint128_t *v, char *z, int vl) in fpsimd_to_sve()
890 static void set_initial_values(struct test_config *config) in set_initial_values() argument
892 int vq = __sve_vq_from_vl(vl_in(config)); in set_initial_values()
893 int sme_vq = __sve_vq_from_vl(config->sme_vl_in); in set_initial_values()
896 svcr_in = config->svcr_in; in set_initial_values()
897 svcr_expected = config->svcr_expected; in set_initial_values()
911 if (sve_supported() || (config->svcr_in & SVCR_SM)) { in set_initial_values()
914 fpsimd_to_sve(v_in, z_in, vl_in(config)); in set_initial_values()
922 if ((config->svcr_in & SVCR_SM) && !fa64_supported()) in set_initial_values()
930 if (config->svcr_in & SVCR_ZA) in set_initial_values()
934 if (config->svcr_expected & SVCR_ZA) in set_initial_values()
942 if (config->svcr_in & SVCR_ZA) in set_initial_values()
946 if (config->svcr_expected & SVCR_ZA) in set_initial_values()
969 static bool check_memory_values(struct test_config *config) in check_memory_values() argument
977 vq = __sve_vq_from_vl(vl_expected(config)); in check_memory_values()
978 sme_vq = __sve_vq_from_vl(config->sme_vl_expected); in check_memory_values()
986 if (sve_vl_out != config->sve_vl_expected) { in check_memory_values()
988 sve_vl_out, config->sve_vl_expected); in check_memory_values()
992 if (sme_vl_out != config->sme_vl_expected) { in check_memory_values()
994 sme_vl_out, config->sme_vl_expected); in check_memory_values()
1026 static bool sve_sme_same(struct test_config *config) in sve_sme_same() argument
1028 if (config->sve_vl_in != config->sve_vl_expected) in sve_sme_same()
1031 if (config->sme_vl_in != config->sme_vl_expected) in sve_sme_same()
1034 if (config->svcr_in != config->svcr_expected) in sve_sme_same()
1040 static bool sve_write_supported(struct test_config *config) in sve_write_supported() argument
1045 if ((config->svcr_in & SVCR_ZA) != (config->svcr_expected & SVCR_ZA)) in sve_write_supported()
1048 if (config->svcr_expected & SVCR_SM) { in sve_write_supported()
1049 if (config->sve_vl_in != config->sve_vl_expected) { in sve_write_supported()
1054 if ((config->svcr_expected & SVCR_ZA) && in sve_write_supported()
1055 (config->sme_vl_in != config->sme_vl_expected)) { in sve_write_supported()
1059 if (config->sme_vl_in != config->sme_vl_expected) { in sve_write_supported()
1067 static void fpsimd_write_expected(struct test_config *config) in fpsimd_write_expected() argument
1074 vl = vl_expected(config); in fpsimd_write_expected()
1083 static void fpsimd_write(pid_t child, struct test_config *test_config) in fpsimd_write()
1095 if (ret == -1) in fpsimd_write()
1100 static bool fpmr_write_supported(struct test_config *config) in fpmr_write_supported() argument
1105 if (!sve_sme_same(config)) in fpmr_write_supported()
1111 static void fpmr_write_expected(struct test_config *config) in fpmr_write_expected() argument
1117 static void fpmr_write(pid_t child, struct test_config *config) in fpmr_write() argument
1130 static void sve_write_expected(struct test_config *config) in sve_write_expected() argument
1132 int vl = vl_expected(config); in sve_write_expected()
1133 int sme_vq = __sve_vq_from_vl(config->sme_vl_expected); in sve_write_expected()
1147 if (config->sme_vl_in != config->sme_vl_expected) { in sve_write_expected()
1153 static void sve_write(pid_t child, struct test_config *config) in sve_write() argument
1159 vl = vl_expected(config); in sve_write()
1172 sve->size = iov.iov_len; in sve_write()
1173 sve->flags = SVE_PT_REGS_SVE; in sve_write()
1174 sve->vl = vl; in sve_write()
1196 static bool za_write_supported(struct test_config *config) in za_write_supported() argument
1198 if (config->sme_vl_in != config->sme_vl_expected) { in za_write_supported()
1200 if (config->svcr_expected & SVCR_SM) { in za_write_supported()
1205 if ((config->svcr_in & SVCR_SM) != in za_write_supported()
1206 (config->svcr_expected & SVCR_SM)) { in za_write_supported()
1214 static void za_write_expected(struct test_config *config) in za_write_expected() argument
1218 sme_vq = __sve_vq_from_vl(config->sme_vl_expected); in za_write_expected()
1220 if (config->svcr_expected & SVCR_ZA) { in za_write_expected()
1228 if (config->sme_vl_in != config->sme_vl_expected) { in za_write_expected()
1231 sve_vq = __sve_vq_from_vl(vl_expected(config)); in za_write_expected()
1237 fpsimd_to_sve(v_expected, z_expected, vl_expected(config)); in za_write_expected()
1241 static void za_write(pid_t child, struct test_config *config) in za_write() argument
1247 vq = __sve_vq_from_vl(config->sme_vl_expected); in za_write()
1249 if (config->svcr_expected & SVCR_ZA) in za_write()
1262 za->size = iov.iov_len; in za_write()
1263 za->vl = config->sme_vl_expected; in za_write()
1264 if (config->svcr_expected & SVCR_ZA) in za_write()
1276 static bool zt_write_supported(struct test_config *config) in zt_write_supported() argument
1280 if (config->sme_vl_in != config->sme_vl_expected) in zt_write_supported()
1282 if (!(config->svcr_expected & SVCR_ZA)) in zt_write_supported()
1284 if ((config->svcr_in & SVCR_SM) != (config->svcr_expected & SVCR_SM)) in zt_write_supported()
1290 static void zt_write_expected(struct test_config *config) in zt_write_expected() argument
1294 sme_vq = __sve_vq_from_vl(config->sme_vl_expected); in zt_write_expected()
1296 if (config->svcr_expected & SVCR_ZA) { in zt_write_expected()
1304 static void zt_write(pid_t child, struct test_config *config) in zt_write() argument
1318 static void run_test(struct test_definition *test, struct test_config *config) in run_test() argument
1325 snprintf(name, sizeof(name), "%s, SVE %d->%d, SME %d/%x->%d/%x", in run_test()
1326 test->name, in run_test()
1327 config->sve_vl_in, config->sve_vl_expected, in run_test()
1328 config->sme_vl_in, config->svcr_in, in run_test()
1329 config->sme_vl_expected, config->svcr_expected); in run_test()
1331 snprintf(name, sizeof(name), "%s, SVE %d->%d", test->name, in run_test()
1332 config->sve_vl_in, config->sve_vl_expected); in run_test()
1334 snprintf(name, sizeof(name), "%s, SME %d/%x->%d/%x", in run_test()
1335 test->name, in run_test()
1336 config->sme_vl_in, config->svcr_in, in run_test()
1337 config->sme_vl_expected, config->svcr_expected); in run_test()
1339 snprintf(name, sizeof(name), "%s", test->name); in run_test()
1341 if (test->supported && !test->supported(config)) { in run_test()
1346 set_initial_values(config); in run_test()
1348 if (test->set_expected_values) in run_test()
1349 test->set_expected_values(config); in run_test()
1357 run_child(config); in run_test()
1359 pass = run_parent(child, test, config); in run_test()
1360 if (!check_memory_values(config)) in run_test()
1366 static void run_tests(struct test_definition defs[], int count, in run_tests()
1367 struct test_config *config) in run_tests() argument
1372 run_test(&defs[i], config); in run_tests()
1375 static struct test_definition base_test_defs[] = {
1394 static struct test_definition sve_test_defs[] = {
1403 static struct test_definition za_test_defs[] = {
1412 static struct test_definition zt_test_defs[] = {
1421 static int sve_vls[MAX_NUM_VLS], sme_vls[MAX_NUM_VLS];
1422 static int sve_vl_count, sme_vl_count;
1424 static void probe_vls(const char *name, int vls[], int *vl_count, int set_vl) in probe_vls()
1433 if (vl == -1) in probe_vls()
1439 if (*vl_count && (vl == vls[*vl_count - 1])) in probe_vls()
1450 vls[1] = vls[*vl_count - 1]; in probe_vls()
1459 static struct {
1483 static void run_sve_tests(void) in run_sve_tests()
1514 static void run_sme_tests(void) in run_sme_tests()