Skip to content

Commit dd68f51

Browse files
brooniewilldeacon
authored andcommitted
kselftest/arm64: Verify that we reject out of bounds VLs in sve-ptrace
We do not currently have a test that asserts that we reject attempts to set a vector length smaller than SVE_VL_MIN or larger than SVE_VL_MAX, add one since that is our current behaviour. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Will Deacon <will@kernel.org>
1 parent 5b7bdc4 commit dd68f51

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

tools/testing/selftests/arm64/fp/sve-ptrace.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static const struct vec_type vec_types[] = {
6666
};
6767

6868
#define VL_TESTS (((TEST_VQ_MAX - SVE_VQ_MIN) + 1) * 4)
69-
#define FLAG_TESTS 2
69+
#define FLAG_TESTS 4
7070
#define FPSIMD_TESTS 2
7171

7272
#define EXPECTED_TESTS ((VL_TESTS + FLAG_TESTS + FPSIMD_TESTS) * ARRAY_SIZE(vec_types))
@@ -286,6 +286,25 @@ static void check_u32(unsigned int vl, const char *reg,
286286
}
287287
}
288288

289+
/* Set out of range VLs */
290+
static void ptrace_set_vl_ranges(pid_t child, const struct vec_type *type)
291+
{
292+
struct user_sve_header sve;
293+
int ret;
294+
295+
memset(&sve, 0, sizeof(sve));
296+
sve.flags = SVE_PT_REGS_SVE;
297+
sve.size = sizeof(sve);
298+
299+
ret = set_sve(child, type, &sve);
300+
ksft_test_result(ret != 0, "%s Set invalid VL 0\n", type->name);
301+
302+
sve.vl = SVE_VL_MAX + SVE_VQ_BYTES;
303+
ret = set_sve(child, type, &sve);
304+
ksft_test_result(ret != 0, "%s Set invalid VL %d\n", type->name,
305+
SVE_VL_MAX + SVE_VQ_BYTES);
306+
}
307+
289308
/* Access the FPSIMD registers via the SVE regset */
290309
static void ptrace_sve_fpsimd(pid_t child, const struct vec_type *type)
291310
{
@@ -719,6 +738,17 @@ static int do_parent(pid_t child)
719738
vec_types[i].name);
720739
}
721740

741+
/* Setting out of bounds VLs should fail */
742+
if (getauxval(vec_types[i].hwcap_type) & vec_types[i].hwcap) {
743+
ptrace_set_vl_ranges(child, &vec_types[i]);
744+
} else {
745+
ksft_test_result_skip("%s Set invalid VL 0\n",
746+
vec_types[i].name);
747+
ksft_test_result_skip("%s Set invalid VL %d\n",
748+
vec_types[i].name,
749+
SVE_VL_MAX + SVE_VQ_BYTES);
750+
}
751+
722752
/* Step through every possible VQ */
723753
for (vq = SVE_VQ_MIN; vq <= TEST_VQ_MAX; vq++) {
724754
vl = sve_vl_from_vq(vq);

0 commit comments

Comments
 (0)