Skip to content

Commit 09b5feb

Browse files
brooniewilldeacon
authored andcommitted
kselftest/arm64: Check that unsupported regsets fail in sve-ptrace
Add a test which verifies that NT_ARM_SVE and NT_ARM_SSVE reads and writes are rejected as expected when the relevant architecture feature is not supported. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Will Deacon <will@kernel.org>
1 parent dd68f51 commit 09b5feb

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,38 @@ static int set_sve(pid_t pid, const struct vec_type *type,
174174
return ret;
175175
}
176176

177+
/* A read operation fails */
178+
static void read_fails(pid_t child, const struct vec_type *type)
179+
{
180+
struct user_sve_header *new_sve = NULL;
181+
size_t new_sve_size = 0;
182+
void *ret;
183+
184+
ret = get_sve(child, type, (void **)&new_sve, &new_sve_size);
185+
186+
ksft_test_result(ret == NULL, "%s unsupported read fails\n",
187+
type->name);
188+
189+
free(new_sve);
190+
}
191+
192+
/* A write operation fails */
193+
static void write_fails(pid_t child, const struct vec_type *type)
194+
{
195+
struct user_sve_header sve;
196+
int ret;
197+
198+
/* Just the header, no data */
199+
memset(&sve, 0, sizeof(sve));
200+
sve.size = sizeof(sve);
201+
sve.flags = SVE_PT_REGS_SVE;
202+
sve.vl = SVE_VL_MIN;
203+
ret = set_sve(child, type, &sve);
204+
205+
ksft_test_result(ret != 0, "%s unsupported write fails\n",
206+
type->name);
207+
}
208+
177209
/* Validate setting and getting the inherit flag */
178210
static void ptrace_set_get_inherit(pid_t child, const struct vec_type *type)
179211
{
@@ -718,6 +750,20 @@ static int do_parent(pid_t child)
718750
}
719751

720752
for (i = 0; i < ARRAY_SIZE(vec_types); i++) {
753+
/*
754+
* If the vector type isn't supported reads and writes
755+
* should fail.
756+
*/
757+
if (!(getauxval(vec_types[i].hwcap_type) & vec_types[i].hwcap)) {
758+
read_fails(child, &vec_types[i]);
759+
write_fails(child, &vec_types[i]);
760+
} else {
761+
ksft_test_result_skip("%s unsupported read fails\n",
762+
vec_types[i].name);
763+
ksft_test_result_skip("%s unsupported write fails\n",
764+
vec_types[i].name);
765+
}
766+
721767
/* FPSIMD via SVE regset */
722768
if (getauxval(vec_types[i].hwcap_type) & vec_types[i].hwcap) {
723769
ptrace_sve_fpsimd(child, &vec_types[i]);

0 commit comments

Comments
 (0)