Skip to content

Commit 9a802dd

Browse files
brooniewilldeacon
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/20231218-kselftest-arm64-vec-syscfg-rdvl-v1-1-0ac22d47e81f@kernel.org Signed-off-by: Will Deacon <[email protected]>
1 parent 48f7ab2 commit 9a802dd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tools/testing/selftests/arm64/fp/vec-syscfg.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ static struct vec_data vec_data[] = {
6666
},
6767
};
6868

69+
static bool vec_type_supported(struct vec_data *data)
70+
{
71+
return getauxval(data->hwcap_type) & data->hwcap;
72+
}
73+
6974
static int stdio_read_integer(FILE *f, const char *what, int *val)
7075
{
7176
int n = 0;
@@ -564,8 +569,11 @@ static void prctl_set_all_vqs(struct vec_data *data)
564569
return;
565570
}
566571

567-
for (i = 0; i < ARRAY_SIZE(vec_data); i++)
572+
for (i = 0; i < ARRAY_SIZE(vec_data); i++) {
573+
if (!vec_type_supported(&vec_data[i]))
574+
continue;
568575
orig_vls[i] = vec_data[i].rdvl();
576+
}
569577

570578
for (vq = SVE_VQ_MIN; vq <= SVE_VQ_MAX; vq++) {
571579
vl = sve_vl_from_vq(vq);
@@ -594,7 +602,7 @@ static void prctl_set_all_vqs(struct vec_data *data)
594602
if (&vec_data[i] == data)
595603
continue;
596604

597-
if (!(getauxval(vec_data[i].hwcap_type) & vec_data[i].hwcap))
605+
if (!vec_type_supported(&vec_data[i]))
598606
continue;
599607

600608
if (vec_data[i].rdvl() != orig_vls[i]) {
@@ -765,7 +773,7 @@ int main(void)
765773
struct vec_data *data = &vec_data[i];
766774
unsigned long supported;
767775

768-
supported = getauxval(data->hwcap_type) & data->hwcap;
776+
supported = vec_type_supported(data);
769777
if (!supported)
770778
all_supported = false;
771779

0 commit comments

Comments
 (0)