Skip to content

Commit 0ba1ce1

Browse files
brooniewilldeacon
authored andcommitted
selftests: arm64: Add coverage of ptrace flags for SVE VL inheritance
Add a test that covers enabling and disabling of SVE vector length inheritance via the ptrace interface. Signed-off-by: Mark Brown <[email protected]> Acked-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 8694e5e commit 0ba1ce1

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

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

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "../../kselftest.h"
2323

2424
#define VL_TESTS (((SVE_VQ_MAX - SVE_VQ_MIN) + 1) * 3)
25-
#define FPSIMD_TESTS 3
25+
#define FPSIMD_TESTS 5
2626

2727
#define EXPECTED_TESTS (VL_TESTS + FPSIMD_TESTS)
2828

@@ -105,6 +105,56 @@ static int set_sve(pid_t pid, const struct user_sve_header *sve)
105105
return ptrace(PTRACE_SETREGSET, pid, NT_ARM_SVE, &iov);
106106
}
107107

108+
/* Validate setting and getting the inherit flag */
109+
static void ptrace_set_get_inherit(pid_t child)
110+
{
111+
struct user_sve_header sve;
112+
struct user_sve_header *new_sve = NULL;
113+
size_t new_sve_size = 0;
114+
int ret;
115+
116+
/* First set the flag */
117+
memset(&sve, 0, sizeof(sve));
118+
sve.size = sizeof(sve);
119+
sve.vl = sve_vl_from_vq(SVE_VQ_MIN);
120+
sve.flags = SVE_PT_VL_INHERIT;
121+
ret = set_sve(child, &sve);
122+
if (ret != 0) {
123+
ksft_test_result_fail("Failed to set SVE_PT_VL_INHERIT\n");
124+
return;
125+
}
126+
127+
/*
128+
* Read back the new register state and verify that we have
129+
* set the flags we expected.
130+
*/
131+
if (!get_sve(child, (void **)&new_sve, &new_sve_size)) {
132+
ksft_test_result_fail("Failed to read SVE flags\n");
133+
return;
134+
}
135+
136+
ksft_test_result(new_sve->flags & SVE_PT_VL_INHERIT,
137+
"SVE_PT_VL_INHERIT set\n");
138+
139+
/* Now clear */
140+
sve.flags &= ~SVE_PT_VL_INHERIT;
141+
ret = set_sve(child, &sve);
142+
if (ret != 0) {
143+
ksft_test_result_fail("Failed to clear SVE_PT_VL_INHERIT\n");
144+
return;
145+
}
146+
147+
if (!get_sve(child, (void **)&new_sve, &new_sve_size)) {
148+
ksft_test_result_fail("Failed to read SVE flags\n");
149+
return;
150+
}
151+
152+
ksft_test_result(!(new_sve->flags & SVE_PT_VL_INHERIT),
153+
"SVE_PT_VL_INHERIT cleared\n");
154+
155+
free(new_sve);
156+
}
157+
108158
/* Validate attempting to set the specfied VL via ptrace */
109159
static void ptrace_set_get_vl(pid_t child, unsigned int vl, bool *supported)
110160
{
@@ -452,6 +502,9 @@ static int do_parent(pid_t child)
452502
/* FPSIMD via SVE regset */
453503
ptrace_sve_fpsimd(child);
454504

505+
/* prctl() flags */
506+
ptrace_set_get_inherit(child);
507+
455508
/* Step through every possible VQ */
456509
for (vq = SVE_VQ_MIN; vq <= SVE_VQ_MAX; vq++) {
457510
vl = sve_vl_from_vq(vq);

0 commit comments

Comments
 (0)