From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, hdegoede@redhat.com,
ilpo.jarvinen@linux.intel.com, tony.luck@intel.com,
ashok.raj@intel.com, jithu.joseph@intel.com,
sathyanarayanan.kuppuswamy@linux.intel.com,
chang.seok.bae@intel.com
Subject: [PATCH v3 2/3] x86/fpu: Allow FPU users to initialize FPU state
Date: Thu, 30 May 2024 12:27:38 -0700 [thread overview]
Message-ID: <20240530192739.172566-3-chang.seok.bae@intel.com> (raw)
In-Reply-To: <20240530192739.172566-1-chang.seok.bae@intel.com>
The In-Field Scan (IFS) test [1] is a destructive process that overwrites
the existing state to test the logic on the fly. As part of this test,
the architectural state should be saved before the test begins and then
restored upon completion.
Unfortunately, AMX state is excluded from the scope of state recovery.
This exclusion prohibits the IFS process from supporting any software
context when running the test. The kernel generally runs with live user
FPU states, including AMX.
Provide fpu_reset_fpregs() for the IFS driver to reset FPU states, which
is much simpler than specifying state components and is affordable in the
non-critical path. This, along with kernel_fpu_begin(), can allow the IFS
test to proceed.
Alternatively, system administrators may attempt to mitigate this IFS
issue by arranging some workloads not to run on CPUs selected for the
tests. But, this approach is disruptive for managing large-scaled
systems.
[1]: https://docs.kernel.org/arch/x86/ifs.html
Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
---
V2 -> V3: Switch to a simpler solution and clarify the hardware
problem (Dave Hansen).
V1 -> V2: Revise the changelog (Dave and Ashok)
The IFS Tech Paper [2] elaborates its purpose and the requirements of the
context restoration after the scan test. Additionally, the necessity for
AMX initialization is emphasized in the Intel Software Development Manual
as of March 2024, in Section 18.2 of Vol.1.
[2]: https://www.intel.com/content/www/us/en/content-details/822279/finding-faulty-components-in-a-live-fleet-environment.html
---
arch/x86/include/asm/fpu/api.h | 2 ++
arch/x86/kernel/fpu/core.c | 11 +++++++++++
2 files changed, 13 insertions(+)
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index f86ad3335529..284304171003 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -179,4 +179,6 @@ extern long fpu_xstate_prctl(int option, unsigned long arg2);
extern void fpu_idle_fpregs(void);
+extern void fpu_reset_fpregs(void);
+
#endif /* _ASM_X86_FPU_API_H */
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 2e6f43dfe98b..51d7689147f4 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -915,3 +915,14 @@ noinstr void fpu_idle_fpregs(void)
__this_cpu_write(fpu_fpregs_owner_ctx, NULL);
}
}
+
+/*
+ * Allow FPU users to initialize the entire user FPU register state. The
+ * caller must invoke kernel_fpu_begin() beforehand.
+ */
+void fpu_reset_fpregs(void)
+{
+ WARN_ON_FPU(!this_cpu_read(in_kernel_fpu));
+ restore_fpregs_from_fpstate(&init_fpstate, XFEATURE_MASK_USER_SUPPORTED);
+}
+EXPORT_SYMBOL_GPL(fpu_reset_fpregs);
--
2.34.1
next prev parent reply other threads:[~2024-05-30 19:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-30 19:27 [PATCH v3 0/3] x86/fpu: Allow the In-Field Scan driver " Chang S. Bae
2024-05-30 19:27 ` [PATCH v3 1/3] x86/fpu: Rename fpu_reset_fpregs() to fpu_reset_fpstate_regs() Chang S. Bae
2024-05-30 19:27 ` Chang S. Bae [this message]
2024-05-30 19:27 ` [PATCH v3 3/3] platform/x86/intel/ifs: Initialize FPU states for the scan test Chang S. Bae
2024-06-03 10:11 ` [PATCH v3 0/3] x86/fpu: Allow the In-Field Scan driver to initialize FPU state Ilpo Järvinen
2024-06-03 12:10 ` Dave Hansen
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=20240530192739.172566-3-chang.seok.bae@intel.com \
--to=chang.seok.bae@intel.com \
--cc=ashok.raj@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jithu.joseph@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--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®