Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kselftest/arm64: Don't probe the current VL for unsupported vector types

The vec-syscfg selftest verifies that setting the VL of the currently
tested vector type does not disrupt the VL of the other vector type. To do
this it records the current vector length for each type but neglects to
guard this with a check for that vector type actually being supported. Add
one, using a helper function which we also update all the other instances
of this pattern.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20231218-kselftest-arm64-vec-syscfg-rdvl-v1-1-0ac22d47e81f@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Mark Brown and committed by
Will Deacon
9a802ddb 48f7ab21

+11 -3
+11 -3
tools/testing/selftests/arm64/fp/vec-syscfg.c
··· 66 66 }, 67 67 }; 68 68 69 + static bool vec_type_supported(struct vec_data *data) 70 + { 71 + return getauxval(data->hwcap_type) & data->hwcap; 72 + } 73 + 69 74 static int stdio_read_integer(FILE *f, const char *what, int *val) 70 75 { 71 76 int n = 0; ··· 569 564 return; 570 565 } 571 566 572 - for (i = 0; i < ARRAY_SIZE(vec_data); i++) 567 + for (i = 0; i < ARRAY_SIZE(vec_data); i++) { 568 + if (!vec_type_supported(&vec_data[i])) 569 + continue; 573 570 orig_vls[i] = vec_data[i].rdvl(); 571 + } 574 572 575 573 for (vq = SVE_VQ_MIN; vq <= SVE_VQ_MAX; vq++) { 576 574 vl = sve_vl_from_vq(vq); ··· 602 594 if (&vec_data[i] == data) 603 595 continue; 604 596 605 - if (!(getauxval(vec_data[i].hwcap_type) & vec_data[i].hwcap)) 597 + if (!vec_type_supported(&vec_data[i])) 606 598 continue; 607 599 608 600 if (vec_data[i].rdvl() != orig_vls[i]) { ··· 773 765 struct vec_data *data = &vec_data[i]; 774 766 unsigned long supported; 775 767 776 - supported = getauxval(data->hwcap_type) & data->hwcap; 768 + supported = vec_type_supported(data); 777 769 if (!supported) 778 770 all_supported = false; 779 771