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, Jim Mattson <jmattson@google.com>
Subject: [PATCH v2 4/6] selftests/x86/xstate: Validate state reset in ptrace test
Date: Wed, 2 Dec 2026 21:24:26 +0000 [thread overview]
Message-ID: <20261202212428.1341014-5-chang.seok.bae@intel.com> (raw)
In-Reply-To: <20261202212428.1341014-1-chang.seok.bae@intel.com>
Clearing a feature bit in XSTATE_BV should cause the state component to
be initialized when the ptracer retrieves the state. Validate this
behavior.
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Cc: Jim Mattson <jmattson@google.com>
---
V1 -> V2: Highlight subtleness with the init-tracking
---
tools/testing/selftests/x86/xstate.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/x86/xstate.c b/tools/testing/selftests/x86/xstate.c
index 61cb3327fc4f4..e0a8c9550c729 100644
--- a/tools/testing/selftests/x86/xstate.c
+++ b/tools/testing/selftests/x86/xstate.c
@@ -335,6 +335,22 @@ static void ptracer_inject_xstate(pid_t target)
else
ksft_test_result_fail("%s for %s\n", __func__, xstate.name);
+ ksft_print_msg("[RUN]\t%s: reset xstate via ptrace().\n", xstate.name);
+
+ /* Reset the feature bit in XSTATE_BV only, expecting init-state back */
+ set_xstatebv(xbuf1, get_xstatebv(xbuf1) & ~xstate.mask);
+
+ /* Prepare reference data */
+ load_init_xstate(&xstate, xbuf2);
+ xsave(xbuf2, xstate.mask);
+ /* Not every XSAVE implementation resets XSTATE_BV when in init-state */
+ set_xstatebv(xbuf2, get_xstatebv(xbuf2) & ~xstate.mask);
+
+ if (validate_ptracer_xstate(target, iov, xbuf1, xbuf2))
+ ksft_test_result_pass("%s (reset) for %s\n", __func__, xstate.name);
+ else
+ ksft_test_result_fail("%s (reset) for %s\n", __func__, xstate.name);
+
free(xbuf1);
free(xbuf2);
}
@@ -496,7 +512,7 @@ static struct test_info {
unsigned int nr;
} tests[] = {
{ .nr = 1, .fn = test_context_switch, },
- { .nr = 1, .fn = test_ptrace, },
+ { .nr = 2, .fn = test_ptrace, },
{ .nr = 2, .fn = test_signal, },
};
--
2.53.0
next prev parent reply other threads:[~2026-12-02 21:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 21:24 [PATCH v2 0/6] selftests/x86/xstate: more test cases for coredump and ptrace Chang S. Bae
2026-12-02 21:24 ` [PATCH v2 1/6] selftests/x86/xstate: Track testing status by kselftest API Chang S. Bae
2026-12-02 21:24 ` [PATCH v2 2/6] selftests/x86/xstate: Pre-allocate ptracee XSAVE buffer Chang S. Bae
2026-12-02 21:24 ` [PATCH v2 3/6] selftests/x86/xstate: Validate XSTATE_BV in ptrace test Chang S. Bae
2026-12-02 21:24 ` Chang S. Bae [this message]
2026-12-02 21:24 ` [PATCH v2 5/6] selftests/x86/xstate: Add coredump test Chang S. Bae
2026-12-02 21:24 ` [PATCH v2 6/6] selftests/mm: Add PKRU " Chang S. Bae
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=20261202212428.1341014-5-chang.seok.bae@intel.com \
--to=chang.seok.bae@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=jmattson@google.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®