Skip to contentSkip to conversation

Introduce XSAVE/XRSTOR self-test

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

v2 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Pengfei Xu

author
#0 lore raw

v2 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 processing 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 v2 1/2 selftests/xsave: test basic XSAVE architecture functionality

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.

In order to ensure that XSAVE feature works correctly, this case tests and verifies the basic functions of XSAVE/XRSTOR in user space: shows and tests the content change for XSAVE; when the xstate is not changed on the x86 platform, the contents of XRSTOR and XSAVE should be the same. 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
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 v2 2/2 selftests/xsave: add xsave test during and after signal handling

In reply to Pengfei Xu

In order to ensure that process XSAVE content is not affected by signal handling, this case tests process XSAVE content should not change in nested signal handling, and the 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
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