mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Cc: x86@kernel.org, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, shuah@kernel.org,
	chang.seok.bae@intel.com
Subject: [PATCH 8/9] selftests/x86/xstate: Clarify supported xstates
Date: Tue, 25 Feb 2025 17:07:28 -0800	[thread overview]
Message-ID: <20250226010731.2456-9-chang.seok.bae@intel.com> (raw)
In-Reply-To: <20250226010731.2456-1-chang.seok.bae@intel.com>

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>
---
 tools/testing/selftests/x86/xstate.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tools/testing/selftests/x86/xstate.c b/tools/testing/selftests/x86/xstate.c
index fd8451e55f3f..875777911d82 100644
--- a/tools/testing/selftests/x86/xstate.c
+++ b/tools/testing/selftests/x86/xstate.c
@@ -15,6 +15,24 @@
 #include "helpers.h"
 #include "xstate.h"
 
+/*
+ * The userspace xstate test suite is designed to be generic and operates
+ * with randomized xstate data. However, some states require special handling:
+ *
+ * - PKRU and XTILECFG need specific adjustments, such as modifying
+ *   randomization behavior or using fixed values.
+ * - But, PKRU already has a dedicated test suite in /tools/selftests/mm.
+ * - Legacy states (FP and SSE) are excluded, as they are not considered
+ *   part of extended states (xstates) and their usage is already deeply
+ *   integrated into user-space libraries.
+ */
+#define XFEATURE_MASK_TEST_SUPPORTED	\
+	((1 << XFEATURE_YMM) |		\
+	 (1 << XFEATURE_OPMASK)	|	\
+	 (1 << XFEATURE_ZMM_Hi256) |	\
+	 (1 << XFEATURE_Hi16_ZMM) |	\
+	 (1 << XFEATURE_XTILEDATA))
+
 static inline uint64_t xgetbv(uint32_t index)
 {
 	uint32_t eax, edx;
@@ -435,6 +453,12 @@ void test_xstate(uint32_t feature_num)
 	unsigned long features;
 	long rc;
 
+	if (!(XFEATURE_MASK_TEST_SUPPORTED & (1 << feature_num))) {
+		ksft_print_msg("The xstate test does not fully support the component %u, yet.\n",
+			       feature_num);
+		return;
+	}
+
 	rc = syscall(SYS_arch_prctl, ARCH_GET_XCOMP_SUPP, &features);
 	if (rc || !(features & (1 << feature_num))) {
 		ksft_print_msg("The kernel does not support feature number: %u\n", feature_num);
-- 
2.45.2


  parent reply	other threads:[~2025-02-26  1:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26  1:07 [PATCH 0/9] selftests/x86/xstate: Introduce common code for testing extended states Chang S. Bae
2025-02-26  1:07 ` [PATCH 1/9] selftests/x86: Consolidate redundant signal helper functions Chang S. Bae
2025-02-26 12:15   ` [tip: x86/fpu] " tip-bot2 for Chang S. Bae
2025-02-26  1:07 ` [PATCH 2/9] selftests/x86/xstate: Refactor XSAVE helpers for general use Chang S. Bae
2025-02-26 12:15   ` [tip: x86/fpu] " tip-bot2 for Chang S. Bae
2025-02-26  1:07 ` [PATCH 3/9] selftests/x86/xstate: Enumerate and name xstate components Chang S. Bae
2025-02-26 12:15   ` [tip: x86/fpu] " tip-bot2 for Chang S. Bae
2025-02-26  1:07 ` [PATCH 4/9] selftests/x86/xstate: Refactor context switching test Chang S. Bae
2025-02-26 12:15   ` [tip: x86/fpu] " tip-bot2 for Chang S. Bae
2025-02-26  1:07 ` [PATCH 5/9] selftests/x86/xstate: Refactor ptrace ABI test Chang S. Bae
2025-02-26 12:15   ` [tip: x86/fpu] " tip-bot2 for Chang S. Bae
2025-02-26  1:07 ` [PATCH 6/9] selftests/x86/xstate: Introduce signal " Chang S. Bae
2025-02-26 12:15   ` [tip: x86/fpu] " tip-bot2 for Chang S. Bae
2025-02-26  1:07 ` [PATCH 7/9] selftests/x86/xstate: Consolidate test invocations into a single entry Chang S. Bae
2025-02-26 12:15   ` [tip: x86/fpu] " tip-bot2 for Chang S. Bae
2025-02-26  1:07 ` Chang S. Bae [this message]
2025-02-26 12:15   ` [tip: x86/fpu] selftests/x86/xstate: Clarify supported xstates tip-bot2 for Chang S. Bae
2025-02-26  1:07 ` [PATCH 9/9] selftests/x86/avx: Add AVX test Chang S. Bae
2025-02-26 12:15   ` [tip: x86/fpu] selftests/x86/avx: Add AVX tests tip-bot2 for Chang S. Bae
2025-02-26 12:07 ` [PATCH 0/9] selftests/x86/xstate: Introduce common code for testing extended states Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250226010731.2456-9-chang.seok.bae@intel.com \
    --to=chang.seok.bae@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®