Skip to contentSkip to conversation

x86/selftests/xsave: Introduce XSAVE tests

PATCH In review Yu-cheng Yu 2 participants 4 messages Feb 27, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/selftests/xsave: Introduce XSAVE tests

In the past there were some issues resulting from additions to XSAVE/XSAVES. Introduce a few tests to help detect issues early.

Cc Andy Lutomirski <luto at kernel.org>
Cc Borislav Petkov <bp at alien8.de>
Cc Dave Hansen <dave.hansen at linux.intel.com>
Cc Ingo Molnar <mingo at kernel.org>
Cc Shuah Khan <shuah at kernel.org>
Signed-off-by Yu-cheng Yu <yu-cheng.yu at intel.com>
---
 tools/testing/selftests/x86/Makefile          |   4 +-
 .../testing/selftests/x86/xsave_check_exec.c  | 117 +++++++++++++++
 .../testing/selftests/x86/xsave_check_fork.c  |  68 +++++++++
 .../selftests/x86/xsave_check_ptrace.c        |  88 +++++++++++
 .../selftests/x86/xsave_check_signal.c        | 116 +++++++++++++++
 .../x86/xsave_check_signal_handler.c          | 140 ++++++++++++++++++
 tools/testing/selftests/x86/xsave_test.h      |  63 ++++++++
 7 files changed, 595 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/x86/xsave_check_exec.c
 create mode 100644 tools/testing/selftests/x86/xsave_check_fork.c
 create mode 100644 tools/testing/selftests/x86/xsave_check_ptrace.c
 create mode 100644 tools/testing/selftests/x86/xsave_check_signal.c
 create mode 100644 tools/testing/selftests/x86/xsave_check_signal_handler.c
 create mode 100644 tools/testing/selftests/x86/xsave_test.h
tools/testing/selftests/x86/Makefile +3 -1
index 186520198de7..f2b422d9809d 100644
@@ -12,7 +12,9 @@ CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh $(CC) trivial_program.c -no-pie)
 
 TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \
 			check_initial_reg_state sigreturn iopl mpx-mini-test ioperm \
-			protection_keys test_vdso test_vsyscall mov_ss_trap
+			protection_keys test_vdso test_vsyscall mov_ss_trap \
+			xsave_check_exec xsave_check_fork xsave_check_ptrace \
+			xsave_check_signal xsave_check_signal_handler
 TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault test_syscall_vdso unwind_vdso \
 			test_FCMOV test_FCOMI test_FISTTP \
 			vdso_restorer
tools/testing/selftests/x86/xsave_check_exec.c new file +117 -0

117 lines not on this page · raw message

tools/testing/selftests/x86/xsave_check_fork.c new file +68 -0

68 lines not on this page · raw message

tools/testing/selftests/x86/xsave_check_ptrace.c new file +88 -0

88 lines not on this page · raw message

tools/testing/selftests/x86/xsave_check_signal.c new file +116 -0

116 lines not on this page · raw message

tools/testing/selftests/x86/xsave_check_signal_handler.c new file +140 -0

140 lines not on this page · raw message

tools/testing/selftests/x86/xsave_test.h new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw
Quoted 2 lines · Yu-cheng Yu

In the past there were some issues resulting from additions to XSAVE/XSAVES. Introduce a few tests to help detect issues early.

Thanks for doing this!

I wonder, though, if you can spend a little more time on these. They look a little "raw". They're virtually free of comments and there is no explanation of what the tests do or why they do them. I honestly forget things like what XSAVE has to do with fork() failing, for instance.

I'd question why we need 5 different .c files. It also seems like things like set_ymm() could be trivially factored into a .h rather than making 5 copies of them.

selftests don't need to be perfect, but I think these could use a _bit_ more polish before merging.

#2 lore raw
Quoted 4 lines · Dave Hansen

I wonder, though, if you can spend a little more time on these. They look a little "raw". They're virtually free of comments and there is no explanation of what the tests do or why they do them. I honestly forget things like what XSAVE has to do with fork() failing, for instance.

I will add comments of what problems each test detects.

Quoted 3 lines

I'd question why we need 5 different .c files. It also seems like things like set_ymm() could be trivially factored into a .h rather than making 5 copies of them.

Each C file contains only one single test and can be built with one command, e.g. "gcc xsave_check_exec.c", or as part of the whole selftest.

I am hoping that, should any test fail, one can easily modify the test to find out why.

Yes, I will move set_ymm() to a header file.

Yu-cheng

#3 lore raw
Quoted 2 lines · Yu-cheng Yu

I am hoping that, should any test fail, one can easily modify the test to find out why.

Yeah, but that's what error messages are for. If we did this for protection_keys, we would have about 30 .c files. :)