lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue,  7 May 2024 16:53:44 -0700
From: "Chang S. Bae" <chang.seok.bae@...el.com>
To: linux-kernel@...r.kernel.org
Cc: x86@...nel.org,
	platform-driver-x86@...r.kernel.org,
	tglx@...utronix.de,
	mingo@...hat.com,
	bp@...en8.de,
	dave.hansen@...ux.intel.com,
	hdegoede@...hat.com,
	ilpo.jarvinen@...ux.intel.com,
	tony.luck@...el.com,
	ashok.raj@...el.com,
	jithu.joseph@...el.com,
	chang.seok.bae@...el.com
Subject: [PATCH v2 2/2] platform/x86/intel/ifs: Initialize AMX state for the scan test

In-Field Scan aborts if AMX state is not in initialized state. Use
kernel_fpu_begin_mask(KFPU_AMX) to ensure AMX state is initialized.

Introduce custom FPU handling wrappers to ensure compliance with the
established FPU API semantics. This change follows the EFI case from
commit b0dc553cfc9d ("x86/fpu: Make the EFI FPU calling convention
explicit").

Then, use these wrappers to surround the MSR_ACTIVATE_SCAN write to
minimize the critical section. To prevent unnecessary delays, invoke
ifs_fpu_begin() before entering the rendezvous loop.

Signed-off-by: Chang S. Bae <chang.seok.bae@...el.com>
Reviewed-by: Jithu Joseph <jithu.joseph@...el.com>
Tested-by: Jithu Joseph <jithu.joseph@...el.com>
Acked-by: Hans de Goede <hdegoede@...hat.com>
---
V1 -> V2: Massage the changelog (Ashok), add a space to the code comment
          (Ilpo), and include the header file explicitly (0-day).
---
 drivers/platform/x86/intel/ifs/ifs.h     | 15 +++++++++++++++
 drivers/platform/x86/intel/ifs/runtest.c |  6 ++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h
index 56b9f3e3cf76..a2ec0dab809b 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
@@ -325,4 +326,18 @@ int do_core_test(int cpu, struct device *dev);
 extern struct attribute *plat_ifs_attrs[];
 extern struct attribute *plat_ifs_array_attrs[];
 
+static inline void ifs_fpu_begin(void)
+{
+	/*
+	 * The AMX state must be initialized prior to executing In-Field
+	 * Scan tests, according to Intel SDM.
+	 */
+	kernel_fpu_begin_mask(KFPU_AMX);
+}
+
+static inline void ifs_fpu_end(void)
+{
+	kernel_fpu_end();
+}
+
 #endif
diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c
index 95b4b71fab53..ca2b496a6b01 100644
--- a/drivers/platform/x86/intel/ifs/runtest.c
+++ b/drivers/platform/x86/intel/ifs/runtest.c
@@ -188,6 +188,9 @@ 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 */
+	ifs_fpu_begin();
+
 	wait_for_sibling_cpu(&scan_cpus_in, NSEC_PER_SEC);
 
 	/*
@@ -199,6 +202,9 @@ static int doscan(void *data)
 	 * are processed in a single pass) before it retires.
 	 */
 	wrmsrl(MSR_ACTIVATE_SCAN, params->activate->data);
+
+	ifs_fpu_end();
+
 	rdmsrl(MSR_SCAN_STATUS, status.data);
 
 	trace_ifs_status(ifsd->cur_batch, start, stop, status.data);
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ