kselftest/arm64: vec-syscfg exit status and VL inheritance coverage
cover kselftest/arm64: vec-syscfg exit status and VL inheritance coverage
From: Abdalla Eldoumani <[email protected]>
Two small changes to the vector length configuration test.
The first makes vec-syscfg report failures through its exit status. It currently always exits 0, so a kernel that fails its checks still shows as passing in the kselftest runner.
The second implements the "Test PR_SVE_VL_INHERIT after a double fork" item from the fp TODO list by also checking the VL in a grandchild, two fork() and exec() generations down.
Tested under QEMU (-cpu max, -cpu max,sme=off and -cpu cortex-a57) on mainline (58161ead2, after v7.3-rc7). To check that the new test can fail, it was also run on a kernel modified to clear the inherit flag on exec(): the existing check passed, the new check failed for SVE and SME, and vec-syscfg exited 1.
Abdalla Eldoumani (2):
kselftest/arm64: Report test failures in vec-syscfg's exit status kselftest/arm64: Check that PR_SVE_VL_INHERIT survives a second exec
tools/testing/selftests/arm64/fp/TODO | 1 - tools/testing/selftests/arm64/fp/vec-syscfg.c | 64 +++++++++++++++++-- 2 files changed, 60 insertions(+), 5 deletions(-)
base-commit: 58161ead29e50d70a317ea26b472e0c7508e69da
Signature · 1 line
2.49.0.windows.1
PATCH 1/2 kselftest/arm64: Report test failures in vec-syscfg's exit status
From: Abdalla Eldoumani <[email protected]>
vec-syscfg ends with ksft_exit_pass() whatever its tests reported, so it exits 0 even when tests fail. The kselftest runner decides whether a program passed from its exit status, so failures in vec-syscfg are only visible in its TAP output and the run as a whole is reported as passing.
Use ksft_finished() so the exit status reflects the results. Unsupported vector types are reported as skips, which ksft_finished() treats as passing, so systems without SVE or SME are unaffected.
--- tools/testing/selftests/arm64/fp/vec-syscfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/arm64/fp/vec-syscfg.c +1 -1
@@ -792,5 +792,5 @@ int main(void)ksft_test_result_skip ("%s\n" , all_types_tests[i].name); } -ksft_exit_pass (); +ksft_finished (); }
Signature · 1 line
2.49.0.windows.1
Re: [PATCH 1/2] kselftest/arm64: Report test failures in vec-syscfg's exit status
Quoted 10 lines · Abdalla Eldoumani
From: Abdalla Eldoumani <[email protected]>
vec-syscfg ends with
ksft_exit_pass()whatever its tests reported, so it exits 0 even when tests fail. The kselftest runner decides whether a program passed from its exit status, so failures in vec-syscfg are only visible in its TAP output and the run as a whole is reported as passing.Use
ksft_finished()so the exit status reflects the results. Unsupported vector types are reported as skips, whichksft_finished()treats as passing, so systems without SVE or SME are unaffected.
PATCH 2/2 kselftest/arm64: Check that PR_SVE_VL_INHERIT survives a second exec
In reply to Abdalla EldoumaniFrom: Abdalla Eldoumani <[email protected]>
The prctl_set_for_child test sets a vector length with PR_SVE_VL_INHERIT and checks that a forked and exec()ed child sees it. That only covers the first exec(). The kernel keeps the inherit flag and the on-exec VL across exec() so that later descendants keep the VL too, and nothing checks that part, which the fp TODO list notes as testing PR_SVE_VL_INHERIT after a double fork.
Extend the test to also read the VL in a grandchild. The child re-executes vec-syscfg in a mode that forks and execs the rdvl helper, so the VL is read after two fork() and exec() generations. Both SVE and SME are covered since the test runs for each vector type.
With a kernel modified to clear the inherit flag on exec() the existing check still passes and the new check fails for both vector types, with the grandchild getting the default VL. Drop the item from the TODO list.
--- tools/testing/selftests/arm64/fp/TODO | 1 - tools/testing/selftests/arm64/fp/vec-syscfg.c | 62 ++++++++++++++++++- 2 files changed, 59 insertions(+), 4 deletions(-)
tools/testing/selftests/arm64/fp/TODO +0 -1
@@ -4,4 +4,3 @@ - Ensure ptraced processes actually see the register state visible through the ptrace interface. - Big endian. -- Test PR_SVE_VL_INHERIT after a double fork.
tools/testing/selftests/arm64/fp/vec-syscfg.c +59 -3
102 lines not on this page · raw message
Signature · 1 line
2.49.0.windows.1
Will Deacon
maintainerRe: [PATCH 2/2] kselftest/arm64: Check that PR_SVE_VL_INHERIT survives a second exec
Quoted 30 lines · Abdalla Eldoumani
From: Abdalla Eldoumani <[email protected]>
The
prctl_set_for_childtest sets a vector length withPR_SVE_VL_INHERITand checks that a forked and exec()ed child sees it. That only covers the firstexec(). The kernel keeps the inherit flag and the on-exec VL acrossexec()so that later descendants keep the VL too, and nothing checks that part, which the fp TODO list notes as testingPR_SVE_VL_INHERITafter a double fork.Extend the test to also read the VL in a grandchild. The child re-executes vec-syscfg in a mode that forks and execs the rdvl helper, so the VL is read after two
fork()andexec()generations. Both SVE and SME are covered since the test runs for each vector type.With a kernel modified to clear the inherit flag on
exec()the existing check still passes and the new check fails for both vector types, with the grandchild getting the default VL. Drop the item from the TODO list.Assisted-by LLMSigned-off-by Abdalla Eldoumani <[email protected]>--- tools/testing/selftests/arm64/fp/TODO | 1 - tools/testing/selftests/arm64/fp/vec-syscfg.c | 62 ++++++++++++++++++- 2 files changed, 59 insertions(+), 4 deletions(-)tools/testing/selftests/arm64/fp/TODO +0
-0
tools/testing/selftests/arm64/fp/TODO line 7
Quoted 4 lines
tools/testing/selftests/arm64/fp/TODO +0
-1@@ -4,4 +4,3 @@ - Ensure ptraced processes actually see the register state visible through the ptrace interface. - Big endian. -- Test PR_SVE_VL_INHERIT after a double fork.
Since this TODO list was authored by Mark (Brown), it would be good for him to assess whether or not your patch implements what he had in mind.
I can't see where the initial parent touches the prctl() and the way you've added the fork() before we even print the selftest header looks a bit weird to me.
Will
Re: [PATCH 2/2] kselftest/arm64: Check that PR_SVE_VL_INHERIT survives a second exec
Quoted 2 lines · Will Deacon
Since this TODO list was authored by Mark (Brown), it would be good for him to assess whether or not your patch implements what he had in mind.
Mark, I took it to mean checking that the flag survives a second exec(), since one fork() and exec() is already tested. Happy to change it if you meant something else.
Quoted 3 lines
I can't see where the initial parent touches the
prctl()and the way you've added thefork()before we even print the selftest header looks a bit weird to me.
It's in the existing part of prctl_set_for_child(), just above the hunk. It sets min_vl | PR_SVE_VL_INHERIT and writes max_vl as the default. The middle process never calls prctl(), so the grandchild only gets min_vl if the setting made it through both exec()s.
The early return in main() is there because the middle process is vec-syscfg run again through /proc/self/exe, and it can't print TAP output. I can move it into a small helper next to rdvl-sve and rdvl-sme in a v2 so main() is left alone. I'll wait for Mark first.
(Resending as plain text, the lists rejected my first copy.)
Thanks,
Abdalla
Will Deacon
maintainerQuoted 11 lines · Abdalla Eldoumani
Two small changes to the vector length configuration test.
The first makes vec-syscfg report failures through its exit status. It currently always exits 0, so a kernel that fails its checks still shows as passing in the kselftest runner.
The second implements the "Test
PR_SVE_VL_INHERITafter a double fork" item from the fp TODO list by also checking the VL in a grandchild, twofork()andexec()generations down.[...]
Applied first patch to arm64 (for-next/selftests), thanks!
[1/2] kselftest/arm64: Report test failures in vec-syscfg's exit status
https://git.kernel.org/arm64/c/e5c438c92dff
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev