<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/tools/testing/selftests/x86/amx.c, branch linux-rolling-stable</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-rolling-stable</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-rolling-stable'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2025-02-26T12:05:29Z</updated>
<entry>
<title>selftests/x86/xstate: Consolidate test invocations into a single entry</title>
<updated>2025-02-26T12:05:29Z</updated>
<author>
<name>Chang S. Bae</name>
<email>chang.seok.bae@intel.com</email>
</author>
<published>2025-02-26T01:07:27Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=10d8a204c5009fb8a6cb2790d17b5611b795c349'/>
<id>urn:sha1:10d8a204c5009fb8a6cb2790d17b5611b795c349</id>
<content type='text'>
Currently, each of the three xstate tests runs as a separate invocation,
requiring the xstate number to be passed and state information to be
reconstructed repeatedly. This approach arose from their individual and
isolated development, but now it makes sense to unify them.

Introduce a wrapper function that first verifies feature availability
from the kernel and constructs the necessary state information once. The
wrapper then sequentially invokes all tests to ensure consistent
execution.

Update the AMX test to use this unified invocation.

Signed-off-by: Chang S. Bae &lt;chang.seok.bae@intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20250226010731.2456-8-chang.seok.bae@intel.com
</content>
</entry>
<entry>
<title>selftests/x86/xstate: Introduce signal ABI test</title>
<updated>2025-02-26T12:05:29Z</updated>
<author>
<name>Chang S. Bae</name>
<email>chang.seok.bae@intel.com</email>
</author>
<published>2025-02-26T01:07:26Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e075d9fa16b3681b8a375cb47f4b5a1901e93530'/>
<id>urn:sha1:e075d9fa16b3681b8a375cb47f4b5a1901e93530</id>
<content type='text'>
With the refactored test cases, another xstate exposure to userspace is
through signal delivery. While amx.c includes signal-related scenarios,
its primary focus is on xstate permission management, which is largely
specific to dynamic states.

The remaining gap is testing xstate preservation and restoration across
signal delivery. The kernel defines an ABI for presenting xstate in the
signal frame, closely resembling the hardware XSAVE format, where xstate
modification is also possible.

Introduce a new test case to verify xstate preservation across signal
delivery and return, that is ensuring ABI compatibility by:

 - Loading xstate before raising a signal.

 - Verifying correct exposure in the signal frame

 - Modifying xstate in the signal frame before returning.

 - Checking the state restoration upon signal return.

Integrate this test into the AMX test suite as an initial usage site.

  Expected output:
  $ amx_64
  ...
  [RUN]   AMX Tile data: load xstate and raise SIGUSR1
  [OK]    'magic1' is valid
  [OK]    'xfeatures' in SW reserved area is valid
  [OK]    'xfeatures' in XSAVE header is valid
  [OK]    xstate delivery was successful
  [OK]    'magic2' is valid
  [RUN]   AMX Tile data: load new xstate from sighandler and check it after sigreturn
  [OK]    xstate was restored correctly

Signed-off-by: Chang S. Bae &lt;chang.seok.bae@intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20250226010731.2456-7-chang.seok.bae@intel.com
</content>
</entry>
<entry>
<title>selftests/x86/xstate: Refactor ptrace ABI test</title>
<updated>2025-02-26T12:05:29Z</updated>
<author>
<name>Chang S. Bae</name>
<email>chang.seok.bae@intel.com</email>
</author>
<published>2025-02-26T01:07:25Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7cb2fbe41949caa35ef1805323b8fc011fac2537'/>
<id>urn:sha1:7cb2fbe41949caa35ef1805323b8fc011fac2537</id>
<content type='text'>
Following the refactoring of the context switching test, the ptrace test is
another component reusable for other xstate features. As part of this
restructuring, add a missing check to validate the
user_xstateregs-&gt;xstate_fx_sw field in the ABI.

Also, replace err() and fatal_error() with ksft_exit_fail_msg() for
consistency in error handling.

  Expected output:
  $ amx_64
  ...
  [RUN]   AMX Tile data: inject xstate via ptrace().
  [OK]    'xfeatures' in SW reserved area was correctly written
  [OK]    xstate was correctly updated.

Signed-off-by: Chang S. Bae &lt;chang.seok.bae@intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20250226010731.2456-6-chang.seok.bae@intel.com
</content>
</entry>
<entry>
<title>selftests/x86/xstate: Refactor context switching test</title>
<updated>2025-02-26T12:05:29Z</updated>
<author>
<name>Chang S. Bae</name>
<email>chang.seok.bae@intel.com</email>
</author>
<published>2025-02-26T01:07:24Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=40f6852ef2bffcd6fb3634cf71e6fbc2d1d6b768'/>
<id>urn:sha1:40f6852ef2bffcd6fb3634cf71e6fbc2d1d6b768</id>
<content type='text'>
The existing context switching and ptrace tests in amx.c are not specific
to dynamic states, making them reusable for general xstate testing.

As a first step, move the context switching test to xstate.c. Refactor
the test code to allow specifying which xstate component being tested.

To decouple the test from dynamic states, remove the permission request
code. In fact, The permission request inside the test wrapper was
redundant.

Additionally, replace fatal_error() with ksft_exit_fail_msg() for
consistency in error handling.

  Expected output:
  $ amx_64
  ...
  [RUN]   AMX Tile data: check context switches, 10 iterations, 5 threads.
  [OK]    No incorrect case was found.

Signed-off-by: Chang S. Bae &lt;chang.seok.bae@intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20250226010731.2456-5-chang.seok.bae@intel.com
</content>
</entry>
<entry>
<title>selftests/x86/xstate: Enumerate and name xstate components</title>
<updated>2025-02-26T12:05:28Z</updated>
<author>
<name>Chang S. Bae</name>
<email>chang.seok.bae@intel.com</email>
</author>
<published>2025-02-26T01:07:23Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=3fcb4d61465613aee76ebd5d86b488778657dda7'/>
<id>urn:sha1:3fcb4d61465613aee76ebd5d86b488778657dda7</id>
<content type='text'>
After moving essential helpers from amx.c, the code remains neutral
regarding which xstate components it handles. However, explicitly listing
known components helps users identify which features are ready for
testing.

Enumerate xstate components to facilitate identification. Extend struct
xstate_info to include a name field, providing a human-readable
identifier.

Signed-off-by: Chang S. Bae &lt;chang.seok.bae@intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20250226010731.2456-4-chang.seok.bae@intel.com
</content>
</entry>
<entry>
<title>selftests/x86/xstate: Refactor XSAVE helpers for general use</title>
<updated>2025-02-26T12:05:28Z</updated>
<author>
<name>Chang S. Bae</name>
<email>chang.seok.bae@intel.com</email>
</author>
<published>2025-02-26T01:07:22Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=0f6d91a327db4a36d6febb74d833cdc668c8661b'/>
<id>urn:sha1:0f6d91a327db4a36d6febb74d833cdc668c8661b</id>
<content type='text'>
The AMX test introduced several XSAVE-related helper functions, but so
far, it has been the only user of them. These helpers can be generalized
for broader test of multiple xstate features.

Move most XSAVE-related code into xsave.h, making it shareable. The
restructuring includes:

 * Establishing low-level XSAVE helpers for saving and restoring register
  states, as well as handling XSAVE buffers.

 * Generalizing state data manipuldations: set_rand_data()

 * Introducing a generic feature query helper: get_xstate_info()

While doing so, remove unused defines in amx.c.

Signed-off-by: Chang S. Bae &lt;chang.seok.bae@intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20250226010731.2456-3-chang.seok.bae@intel.com
</content>
</entry>
<entry>
<title>selftests/x86: Consolidate redundant signal helper functions</title>
<updated>2025-02-26T12:05:28Z</updated>
<author>
<name>Chang S. Bae</name>
<email>chang.seok.bae@intel.com</email>
</author>
<published>2025-02-26T01:07:21Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=dbd6b649e7d5b66c7fa95a65d67b59cf5b45f0ac'/>
<id>urn:sha1:dbd6b649e7d5b66c7fa95a65d67b59cf5b45f0ac</id>
<content type='text'>
The x86 selftests frequently register and clean up signal handlers, but
the sethandler() and clearhandler() functions have been redundantly
copied across multiple .c files.

Move these functions to helpers.h to enable reuse across tests,
eliminating around 250 lines of duplicate code.

Converge the error handling by using ksft_exit_fail_msg(), which is
functionally equivalent with err() within the selftest framework.

This change is a prerequisite for the upcoming xstate selftest, which
requires signal handling for registering and cleaning up handlers.

Signed-off-by: Chang S. Bae &lt;chang.seok.bae@intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20250226010731.2456-2-chang.seok.bae@intel.com
</content>
</entry>
<entry>
<title>selftests/x86: remove (or use) unused variables and functions</title>
<updated>2024-07-11T17:23:55Z</updated>
<author>
<name>John Hubbard</name>
<email>jhubbard@nvidia.com</email>
</author>
<published>2024-07-04T07:24:30Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7d17b29b0e4b9a97426873f72e9cc6d35cfaf88f'/>
<id>urn:sha1:7d17b29b0e4b9a97426873f72e9cc6d35cfaf88f</id>
<content type='text'>
When building with clang, via:

    make LLVM=1 -C tools/testing/selftests

...quite a few functions are variables are generating "unused" warnings.
Fix the warnings by deleting the unused items.

One item, the "nerrs" variable in vsdo_restorer.c's main(), is unused
but probably wants to be returned from main(), as a non-zero result.
That result is also unused right now, so another option would be to
delete it entirely, but this way, main() also gets fixed. It was missing
a return value.

Acked-by: Muhammad Usama Anjum &lt;usama.anjum@collabora.com&gt;
Signed-off-by: John Hubbard &lt;jhubbard@nvidia.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>x86/selftests: Skip the tests if prerequisites aren't fulfilled</title>
<updated>2024-03-29T07:33:40Z</updated>
<author>
<name>Muhammad Usama Anjum</name>
<email>usama.anjum@collabora.com</email>
</author>
<published>2024-03-27T11:17:17Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=99c84311e35f9399bdce666f6306a048e2a5b404'/>
<id>urn:sha1:99c84311e35f9399bdce666f6306a048e2a5b404</id>
<content type='text'>
Skip instead of failing when prerequisite conditions aren't fulfilled,
such as invalid xstate values etc.

Make the tests show as 'SKIP' when run:

  make -C tools/testing/selftests/ TARGETS=x86 run_tests

  ...
  # timeout set to 45
  # selftests: x86: amx_64
  # # xstate cpuid: invalid tile data size/offset: 0/0
  ok 42 selftests: x86: amx_64 # SKIP
  # timeout set to 45
  # selftests: x86: lam_64
  # # Unsupported LAM feature!
  ok 43 selftests: x86: lam_64 # SKIP
  ...

In the AMX test, Move away from check_cpuid_xsave() and start using
arch_prctl() to find out if AMX support is present or not. In the
kernels where AMX isn't present, arch_prctl() returns -EINVAL, hence it is
backward compatible.

Signed-off-by: Muhammad Usama Anjum &lt;usama.anjum@collabora.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Reviewed-by: Chang S. Bae &lt;chang.seok.bae@intel.com&gt;
Reviewed-by: Binbin Wu &lt;binbin.wu@linux.intel.com&gt;
Acked-by: Kirill A. Shutemov &lt;kirill.shutemov@linux.intel.com&gt;
Link: https://lore.kernel.org/r/20240327111720.3509180-1-usama.anjum@collabora.com
</content>
</entry>
<entry>
<title>selftests/x86/amx: Add a ptrace test</title>
<updated>2023-03-22T18:00:49Z</updated>
<author>
<name>Chang S. Bae</name>
<email>chang.seok.bae@intel.com</email>
</author>
<published>2023-02-27T21:05:04Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=62faca1ca10cc84e99ae7f38aa28df2bc945369b'/>
<id>urn:sha1:62faca1ca10cc84e99ae7f38aa28df2bc945369b</id>
<content type='text'>
Include a test case to validate the XTILEDATA injection to the target.

Also, it ensures the kernel's ability to copy states between different
XSAVE formats.

Refactor the memcmp() code to be usable for the state validation.

Signed-off-by: Chang S. Bae &lt;chang.seok.bae@intel.com&gt;
Signed-off-by: Dave Hansen &lt;dave.hansen@linux.intel.com&gt;
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20230227210504.18520-3-chang.seok.bae%40intel.com
</content>
</entry>
</feed>
