[PATCH v3 3/3] platform/x86/intel/ifs: Initialize FPU states for the scan test
From: Chang S. Bae
Date: Thu May 30 2024 - 15:44:46 EST
The In-Field Scan process aborts if AMX state is not in initialized
state. Use fpu_reset_fpregs() to ensure AMX state is initialized before
entering the rendezvous loop.
Suggested-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Signed-off-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>
Tested-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
---
V2 -> V3: Use fpu_reset_user_fpregs().
Thanks to everyone who provided tags on previous versions. Due
to the code change, I felt it necessary to revoke them, but the
high-level logic remains the same.
V1 -> V2: Revised the changelog (Ashok), added a space to the code comment
(Ilpo), and included the header file explicitly (0-day).
---
drivers/platform/x86/intel/ifs/ifs.h | 1 +
drivers/platform/x86/intel/ifs/runtest.c | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h
index 56b9f3e3cf76..5e7ba94b4054 100644
--- a/drivers/platform/x86/intel/ifs/ifs.h
+++ b/drivers/platform/x86/intel/ifs/ifs.h
@@ -129,6 +129,7 @@
*/
#include <linux/device.h>
#include <linux/miscdevice.h>
+#include <asm/fpu/api.h>
#define MSR_ARRAY_BIST 0x00000105
#define MSR_COPY_SCAN_HASHES 0x000002c2
diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c
index 282e4bfe30da..68e128ea57ed 100644
--- a/drivers/platform/x86/intel/ifs/runtest.c
+++ b/drivers/platform/x86/intel/ifs/runtest.c
@@ -191,6 +191,10 @@ static int doscan(void *data)
/* Only the first logical CPU on a core reports result */
first = cpumask_first(cpu_smt_mask(cpu));
+ /* Prepare FPU state before entering the rendezvous loop */
+ kernel_fpu_begin();
+ fpu_reset_fpregs();
+
wait_for_sibling_cpu(&scan_cpus_in, NSEC_PER_SEC);
/*
@@ -202,6 +206,9 @@ static int doscan(void *data)
* are processed in a single pass) before it retires.
*/
wrmsrl(MSR_ACTIVATE_SCAN, params->activate->data);
+
+ kernel_fpu_end();
+
rdmsrl(MSR_SCAN_STATUS, status.data);
trace_ifs_status(ifsd->cur_batch, start, stop, status.data);
--
2.34.1