Skip to content

Commit fa826c1

Browse files
ChangSeokBaeIngo Molnar
authored andcommitted
selftests/x86/xstate: Clarify supported xstates
The established xstate test code is designed to be generic, but certain xstates require special handling and cannot be tested without additional adjustments. Clarify which xstates are currently supported, and enforce testing only for them. Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20250226010731.2456-9-chang.seok.bae@intel.com
1 parent 10d8a20 commit fa826c1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tools/testing/selftests/x86/xstate.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@
1515
#include "helpers.h"
1616
#include "xstate.h"
1717

18+
/*
19+
* The userspace xstate test suite is designed to be generic and operates
20+
* with randomized xstate data. However, some states require special handling:
21+
*
22+
* - PKRU and XTILECFG need specific adjustments, such as modifying
23+
* randomization behavior or using fixed values.
24+
* - But, PKRU already has a dedicated test suite in /tools/selftests/mm.
25+
* - Legacy states (FP and SSE) are excluded, as they are not considered
26+
* part of extended states (xstates) and their usage is already deeply
27+
* integrated into user-space libraries.
28+
*/
29+
#define XFEATURE_MASK_TEST_SUPPORTED \
30+
((1 << XFEATURE_YMM) | \
31+
(1 << XFEATURE_OPMASK) | \
32+
(1 << XFEATURE_ZMM_Hi256) | \
33+
(1 << XFEATURE_Hi16_ZMM) | \
34+
(1 << XFEATURE_XTILEDATA))
35+
1836
static inline uint64_t xgetbv(uint32_t index)
1937
{
2038
uint32_t eax, edx;
@@ -435,6 +453,12 @@ void test_xstate(uint32_t feature_num)
435453
unsigned long features;
436454
long rc;
437455

456+
if (!(XFEATURE_MASK_TEST_SUPPORTED & (1 << feature_num))) {
457+
ksft_print_msg("The xstate test does not fully support the component %u, yet.\n",
458+
feature_num);
459+
return;
460+
}
461+
438462
rc = syscall(SYS_arch_prctl, ARCH_GET_XCOMP_SUPP, &features);
439463
if (rc || !(features & (1 << feature_num))) {
440464
ksft_print_msg("The kernel does not support feature number: %u\n", feature_num);

0 commit comments

Comments
 (0)