mbox series

[RFC,v1,0/2] Introduce XSAVE/XRSTOR self-test

Message ID cover.1627355565.git.pengfei.xu@intel.com (mailing list archive)
Headers show
Series Introduce XSAVE/XRSTOR self-test | expand

Message

Pengfei Xu July 27, 2021, 3:34 a.m. UTC
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/0000000000004c453905c30f8334@google.com/

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

Comments

Dave Hansen July 27, 2021, 5:46 p.m. UTC | #1
On 7/26/21 8:34 PM, Pengfei Xu wrote:
> 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.

> 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.

> 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.

> 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.
Pengfei Xu July 28, 2021, 7:18 a.m. UTC | #2
Hi Dave,
  Thanks for comments!

On 2021-07-27 at 10:46:45 -0700, Dave Hansen wrote:
> On 7/26/21 8:34 PM, Pengfei Xu wrote:
> > 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.
"

> > 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.

> > 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.
"

> > 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.
Thanks for advice, will update it.

-Pengfei
BR.