Introduce XSAVE/XRSTOR self-test
cover Introduce XSAVE/XRSTOR self-test
The XSAVE feature set supports the saving and restoring of state components such as FPU, which is used for process context switching.
In order to ensure that XSAVE works correctly, add XSAVE basic test for XSAVE architecture functionality.
This patch set tests XSAVE/XRSTOR instructions on x86 platforms and verify if the XSAVE/XRSTOR works correctly during signal handling.
Cases such as signal handling, process creation, other xstate(except FPU) tests for XSAVE check, etc. will be added to the Linux kernel self-test. If appropriate, it is even planned to add the [1] mentioned XSAVE issues reproduce and some XSAVE anomaly tests to the kernel self-test.
[1]: https://lore.kernel.org/lkml/[email protected]/
Pengfei Xu (2):
selftests/xsave: test basic XSAVE architecture functionality selftests/xsave: add xsave test during signal handling
tools/testing/selftests/Makefile | 1 + tools/testing/selftests/xsave/.gitignore | 3 + tools/testing/selftests/xsave/Makefile | 6 + tools/testing/selftests/xsave/xsave_common.h | 246 ++++++++++++++++++ .../selftests/xsave/xsave_instruction.c | 83 ++++++ .../selftests/xsave/xsave_signal_handle.c | 184 +++++++++++++ 6 files changed, 523 insertions(+) create mode 100644 tools/testing/selftests/xsave/.gitignore create mode 100644 tools/testing/selftests/xsave/Makefile create mode 100644 tools/testing/selftests/xsave/xsave_common.h create mode 100644 tools/testing/selftests/xsave/xsave_instruction.c create mode 100644 tools/testing/selftests/xsave/xsave_signal_handle.c
Signature · 1 line
2.20.1
RFC PATCH 1/2 selftests/xsave: test basic XSAVE architecture functionality
The XSAVE feature set supports the saving and restoring of state components such as FPU, which is used for process context switching.
In order to ensure that XSAVE feature works correctly, this case tests the execution of xsave/xrstor in user space: show and tests the content change for xsave; the contents of xrstor and xsave should same on x86 platforms. This case is the basis for XSAVE feature testing.
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/xsave/.gitignore | 2 + tools/testing/selftests/xsave/Makefile | 6 + tools/testing/selftests/xsave/xsave_common.h | 246 ++++++++++++++++++ .../selftests/xsave/xsave_instruction.c | 83 ++++++ 5 files changed, 338 insertions(+) create mode 100644 tools/testing/selftests/xsave/.gitignore create mode 100644 tools/testing/selftests/xsave/Makefile create mode 100644 tools/testing/selftests/xsave/xsave_common.h create mode 100644 tools/testing/selftests/xsave/xsave_instruction.c
tools/testing/selftests/Makefile +1 -0
@@ -73,6 +73,7 @@ TARGETS += user TARGETS += vDSO TARGETS += vm TARGETS += x86 +TARGETS += xsave TARGETS += zram #Please keep the TARGETS list alphabetically sorted # Run "make quicktest=1 run_tests" or
tools/testing/selftests/xsave/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +xsave_instruction
tools/testing/selftests/xsave/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +CFLAGS := -g -Wall -mxsave -O2 + +TEST_GEN_PROGS := xsave_instruction + +include ../lib.mk
tools/testing/selftests/xsave/xsave_common.h new file +246 -0
246 lines not on this page · raw message
tools/testing/selftests/xsave/xsave_instruction.c new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.20.1
RFC PATCH 2/2 selftests/xsave: add xsave test during signal handling
In reply to Pengfei XuIn order to ensure that the XSAVE content is not affected by signal handling, this case tests XSAVE content should not change in nested signal handling, and XSAVE content should same before and after signal handling.
--- tools/testing/selftests/xsave/.gitignore | 1 + tools/testing/selftests/xsave/Makefile | 2 +- .../selftests/xsave/xsave_signal_handle.c | 184 ++++++++++++++++++ 3 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/xsave/xsave_signal_handle.c
tools/testing/selftests/xsave/.gitignore +1 -0
@@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only xsave_instruction +xsave_signal_handle
tools/testing/selftests/xsave/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only CFLAGS := -g -Wall -mxsave -O2 -TEST_GEN_PROGS := xsave_instruction +TEST_GEN_PROGS := xsave_instruction xsave_signal_handle include ../lib.mk
tools/testing/selftests/xsave/xsave_signal_handle.c new file +184 -0
184 lines not on this page · raw message
Signature · 1 line
2.20.1
Quoted 2 lines · Pengfei Xu
The XSAVE feature set supports the saving and restoring of state components such as FPU, which is used for process context switching.
This sentence is really awkward. It reads at first as saying that the FPU is used for context switching. Can you rephrase.
Quoted 2 lines
In order to ensure that XSAVE works correctly, add XSAVE basic test for XSAVE architecture functionality.
This sentence needs to be start on the same line as the previous one, *or* be in a new paragraph. Please rewrap it.
Quoted 2 lines
This patch set tests XSAVE/XRSTOR instructions on x86 platforms and verify if the XSAVE/XRSTOR works correctly during signal handling.
This reads to me like you are going to test the XSAVE/XRSTOR instructions *in* a signal handler, instead of testing the XSAVE/XRSTOR instructions that the kernel uses at signal entry/exit.
Also, the kernel does *NOT* *USE* XSAVE/XRSTOR in many cases to save/restore signal state. The changelog could be read as implying that it does.
Quoted 4 lines
Cases such as signal handling, process creation, other xstate(except FPU) tests for XSAVE check, etc. will be added to the Linux kernel self-test. If appropriate, it is even planned to add the [1] mentioned XSAVE issues reproduce and some XSAVE anomaly tests to the kernel self-test.
This is not clear whether it is talking about *this* series int he future tense (will be added) or whether it is talking about future *work*.
Maybe something like this:
This series introduces only the most basic XSAVE tests. In the future, the intention is to continue expanding the scope of these selftests to include more kernel XSAVE-related functionality and XSAVE-managed features like AMX and shadow stacks.
Hi Dave,
Thanks for comments!
Quoted 7 lines · Dave Hansen
Quoted 2 lines · Pengfei Xu
The XSAVE feature set supports the saving and restoring of state components such as FPU, which is used for process context switching.
This sentence is really awkward. It reads at first as saying that the FPU is used for context switching. Can you rephrase.
Thanks for advice, I will update it as below if it's appropriate:
"
The XSAVE feature set supports the saving and restoring of state components, which is used for process context switching. The state components include x87 state for FPU execution environment, SSE state, AVX state and so on. "
Quoted 6 lines
Quoted 2 lines
In order to ensure that XSAVE works correctly, add XSAVE basic test for XSAVE architecture functionality.
This sentence needs to be start on the same line as the previous one, *or* be in a new paragraph. Please rewrap it.
Will rewrap it.
Quoted 11 lines
Quoted 2 lines
This patch set tests XSAVE/XRSTOR instructions on x86 platforms and verify if the XSAVE/XRSTOR works correctly during signal handling.
This reads to me like you are going to test the XSAVE/XRSTOR instructions *in* a signal handler, instead of testing the XSAVE/XRSTOR instructions that the kernel uses at signal entry/exit.
Also, the kernel does *NOT* *USE* XSAVE/XRSTOR in many cases to save/restore signal state. The changelog could be read as implying that it does.
Yes, how about updating it as below:
"
This patch set tests and verifies the basic functions of XSAVE/XRSTOR in user space; during and after signal processing on the x86 platform, the XSAVE contents of the process should not be changed.
"
Quoted 8 lines
Quoted 4 lines
Cases such as signal handling, process creation, other xstate(except FPU) tests for XSAVE check, etc. will be added to the Linux kernel self-test. If appropriate, it is even planned to add the [1] mentioned XSAVE issues reproduce and some XSAVE anomaly tests to the kernel self-test.
This is not clear whether it is talking about *this* series int he future tense (will be added) or whether it is talking about future *work*.
Quoted 7 lines
Maybe something like this:
This series introduces only the most basic XSAVE tests. In the future, the intention is to continue expanding the scope of these selftests to include more kernel XSAVE-related functionality and XSAVE-managed features like AMX and shadow stacks.
Thanks for advice, will update it.
-Pengfei
BR.