Skip to contentSkip to conversation

Introduce XSAVE/XRSTOR self-test

RFC PATCH Superseded Pengfei Xu 1 participant 3 messages Aug 4, 2021 Kselftest

v3 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Pengfei Xu

author
#0 lore raw

v3 cover Introduce XSAVE/XRSTOR self-test

The XSAVE feature set supports the saving and restoring of state components, and XSAVE feature is used for process context switching. The XSAVE state components include x87 state for FPU execution environment, SSE state, AVX state and so on. In order to ensure that XSAVE works correctly, add XSAVE basic test for XSAVE architecture functionality.

This patch set tests and verifies the basic functions of XSAVE/XRSTOR in user space; during and after signal handling on the x86 platform, the XSAVE contents of the process should not be changed.

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.

Pengfei Xu (2):
selftests/xsave: test basic XSAVE architecture functionality selftests/xsave: add xsave test during and after 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
author
#1 lore raw

RFC PATCH v3 1/2 selftests/xsave: test basic XSAVE architecture functionality

The XSAVE feature set supports the saving and restoring of state components, and XSAVE feature is used for process context switching. XSAVE state components include FPU-related x87 state, SSE state, AVX state, etc.

This case tests and verifies the basic functions of XSAVE/XRSTOR in user
space: display and test the content changes of XSAVE; when the xstate in the same process on the x86 platform is unchanged, the contents of XRSTOR and XSAVE should be the same. This case is the most basic test of XSAVE function.

---
 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
index fb010a35d61a..4c0ddb8228e1 100644
@@ -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
new file mode 100644
index 000000000000..00b9970360c4
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+xsave_instruction
tools/testing/selftests/xsave/Makefile new file +6 -0
new file mode 100644
index 000000000000..dafdb0abdeb3
@@ -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
author
#2 lore raw

RFC PATCH v3 2/2 selftests/xsave: add xsave test during and after signal handling

In reply to Pengfei Xu

In order to ensure that the XSAVE content in the same process is not affected by signal handling, this case tests that the XSAVE content of the process should not change during and after the nested 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
index 00b9970360c4..b448d36186f3 100644
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
 xsave_instruction
+xsave_signal_handle
tools/testing/selftests/xsave/Makefile +1 -1
index dafdb0abdeb3..fedae2778297 100644
@@ -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