Skip to contentSkip to conversation

platform/x86/intel/ifs: Support group-based In-Field Scan and Diamond Rapids

PATCH New Ehab Ababneh 1 participant 18 messages Nov 20

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover platform/x86/intel/ifs: Support group-based In-Field Scan and Diamond Rapids

Some Intel Xeon processors, starting with Diamond Rapids (DMR), share one SCAN test engine between multiple CPU cores in a module (Dual-Core Module, DCM), instead of only between the threads of a single core. All logical processors that share an engine must start the In-Field Scan (IFS) test at the same time. The current driver assumes the sharing domain is cpu_smt_mask(), which does not hold on these systems. Also, although the cores in a module are tested together, each core gets its own result: on a DCM, one core can pass while the other fails.

This series:

- Patch 1 removes the SBAF test, which is not planned for any CPU and whose test images were never published.

- Patches 2-6 are cleanups and preparatory refactoring (comment fixes, clearer MSR bit names, u64 MSR bitfields, early return on image errors, a generic Array BIST parameter struct). Patches 2-4 have no functional change.

- Patch 7 adds stop_cluster_cpuslocked(), the cluster-level counterpart of stop_core_cpuslocked(), so that all threads of a cluster can rendezvous and issue WRMSR at the same time.

- Patches 8-10 enumerate ALL_LP_JOIN_NEEDED, select the CPUs to test together from topology_cluster_cpumask(), and warn when a group test does not pass while some of the logical processors sharing the scan engine (per TID_BIT_SHIFT) were not in the group.

- Patches 11-13 record per-CPU results for group tests and expose them through new sysfs files (status_list, details_list, cpus_ran_list, addnl_details_list). The existing status and details files remain and report the result of the whole group: status is "pass" only if every CPU in the group passed.

- Patch 14 adds Diamond Rapids to the CPU match table.

- Patch 15 removes the 256 limit on the batch file number.

- Patches 16-17 update the IFS documentation and ABI document.

Most of this series was developed by Jithu Joseph and Qiuxu Zhuo, who have both since left Intel. I have taken over upstreaming it, so please send questions and review comments to me. The patches keep their original authorship and Signed-off-by tags, except patch 10, which I rewrote for v2 (Qiuxu is credited as co-developer). I have added my Signed-off-by to every patch.

Thanks to Ilpo Järvinen for taking the time to review v2.

Changes in v3:
- Patch 11: the status and details files now report the result of the whole group instead of only the CPU written to run_test: status is "pass" only if all CPUs in the group passed, otherwise "fail" if any CPU failed or "untested" if any CPU was not fully tested, and details are those of the first such CPU. Patches 12, 16 and 17 describe this.
- Patch 11: when a group test times out or stops making progress, a CPU that completed all chunks is now reported as passed instead of untested; details now always match the per-CPU result (Sashiko).

From Ilpo's review:
- Patches 8, 9, 12, 13, 14, 15: dropped the "[ Qiuxu: ... ]" notes. Qiuxu reworded those commit messages while carrying the patches internally.
- Patch 7: rewrote the first paragraph of the commit message so that it stands on its own and names Diamond Rapids; dropped the extra ':' in the stop_cluster_cpuslocked() kernel-doc.
- Patch 9: add an ifs_stop_cpus() helper that picks stop_cluster_cpuslocked() or stop_core_cpuslocked(); passive voice in the commit message; reference [2] moved to a Link: tag.
- Patch 10: use BIT(); include <linux/bits.h> and <linux/processor.h>; braces around the multi-line if.
- Patch 11: trailing comma in the ifs_devices[] initializer; local pointer and sizeof(*ptr) in the memset() loops; get_scan_status() is now a static function; a for_each_group_scan_status() iterator replaces the repeated per-CPU loops. Added my Co-developed-by.
- Patch 12: cpus_ran_list_show() returns sysfs_emit() directly.
- Patches 15, 16, 17: wrap documentation and ABI text to 80 columns.

v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Rebased onto v7.4-rc1.
- Tested on Emerald Rapids, Granite Rapids, Clearwater Forest and Diamond Rapids (Tested-by: Yi Lai on all patches).
- Patch 9: build the CPU group mask only after the CPU online and image loaded checks pass, so a rejected run_test write no longer changes the group reported by the *_list files (Sashiko).
- Patch 10: reworked, with a new title (was "Validate TID_BIT_SHIFT matches topology_cluster_cpumask()"). The check at driver init is
gone: it failed driver load on Sapphire Rapids and Emerald Rapids, which don't enumerate TID_BIT_SHIFT, when a CPU in the group was offline, and on parts that expose only one core per module. Now TID_BIT_SHIFT is read at init and, if a test does not pass, the driver warns when not all logical processors in the TID_BIT_SHIFT range were in the group. The test always runs (Sashiko, suggested by Tony Luck). Author changed to me, with Qiuxu as Co-developed-by.
- Patch 11:
- clear the per-CPU results of the group at the start of each test, and clear them in ifs_init() before the devices are registered (Sashiko);
- restart an interrupted test from the lowest chunk reached by any

    CPU in the group (Sashiko);

- don't overwrite error codes reported by the hardware with the driver's timeout or partial-completion code; report a CPU that stopped early without an error code as partially completed (Sashiko);
- the patch 10 warning checks the results of all CPUs in the group;
- commit message: explain that cores in a group can report different results.
- Patches 12, 13: read the CPU group mask only once in the *_list show functions (Sashiko).
- Patch 16: fix typos; say "group" instead of "core"; use the real attribute name addnl_details in the commit message; describe what happens with offline CPUs instead of requiring all CPUs in a group to be online (Sashiko).

v1: https://lore.kernel.org/all/[email protected]/

Ehab Ababneh (1):
platform/x86/intel/ifs: Warn if a group test fails with CPUs missing

Jithu Joseph (7):
platform/x86/intel/ifs: Refactor Array BIST function interface platform/x86/intel/ifs: Enumerate the bit to determine if CPUs need to
join for IFS tests
platform/x86/intel/ifs: Select CPUs from topology_cluster_cpumask()
for simultaneous IFS tests
platform/x86/intel/ifs: Track and report scan results on a per-CPU
basis
platform/x86/intel/ifs: Add new sysfs interfaces {status, details,
cpus_ran}_list
platform/x86/intel/ifs: Add additional details sysfs interface platform/x86/intel/ifs: Add Intel Diamond Rapids server support

Qiuxu Zhuo (8):
platform/x86/intel/ifs: Revert SBAF feature platform/x86/intel/ifs: Fix IFS sysfs interfaces in the comments platform/x86/intel/ifs: Clarify In-Field Scan MSR bit macro
definitions
platform/x86/intel/ifs: Use u64 to define the bits of IFS MSR
registers
platform/x86/intel/ifs: Early return on the IFS image hash/chunk error
stop_machine: Add stop_cluster_cpuslocked() for per-cluster operations platform/x86/intel/ifs: Update IFS documentation Documentation/ABI: Update IFS ABI doc

Tony Luck (1):
platform/x86/intel/ifs: Remove limit on number of batch files

 .../ABI/testing/sysfs-platform-intel-ifs      |  44 +-
 arch/x86/include/asm/msr-index.h              |  17 +-
 drivers/platform/x86/intel/ifs/core.c         |  62 ++-
 drivers/platform/x86/intel/ifs/ifs.h          | 236 ++++-----
 drivers/platform/x86/intel/ifs/load.c         |  52 +-
 drivers/platform/x86/intel/ifs/runtest.c      | 479 ++++++++----------
 drivers/platform/x86/intel/ifs/sysfs.c        | 107 +++-
 include/linux/stop_machine.h                  |  15 +
 include/trace/events/intel_ifs.h              |  27 -
 kernel/stop_machine.c                         |  35 +-
 tools/arch/x86/include/asm/msr-index.h        |  14 +-
 11 files changed, 557 insertions(+), 531 deletions(-)

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/17 platform/x86/intel/ifs: Revert SBAF feature

From: Qiuxu Zhuo <[email protected]>

Structural Based Functional Test at Field (SBAF) test was initially expected to be supported in Granite Rapids (GNR) CPUs. However, due to recent roadmap changes, the SBAF test support will not be included in GNR and is unlikely to be included in future CPUs.

Additionally, Intel has never published the SBAF scan files, and the SBAF feature and its interface [1] are not utilized. Therefore, it's safe to remove them. Given this, remove the SBAF test from the In-Field Scan (IFS) driver by reverting the following commits:

commit 1e701372d7ac ("platform/x86/intel/ifs: Fix SBAF title underline length") commit 61b74964536e ("trace: platform/x86/intel/ifs: Add SBAF trace support") commit 3c4d06bd6e37 ("platform/x86/intel/ifs: Add SBAF test support") commit 0a3e4e94d137 ("platform/x86/intel/ifs: Add SBAF test image loading support") commit 744a6a1f2a83 ("tools arch x86: Sync the msr-index.h copy with the kernel sources")

[1] /sys/devices/virtual/misc/intel_ifs_2

---
 arch/x86/include/asm/msr-index.h         |   2 -
 drivers/platform/x86/intel/ifs/core.c    |  24 ---
 drivers/platform/x86/intel/ifs/ifs.h     |  65 +------
 drivers/platform/x86/intel/ifs/load.c    |  16 +-
 drivers/platform/x86/intel/ifs/runtest.c | 233 -----------------------
 include/trace/events/intel_ifs.h         |  27 ---
 tools/arch/x86/include/asm/msr-index.h   |   2 -
 7 files changed, 5 insertions(+), 364 deletions(-)
arch/x86/include/asm/msr-index.h +0 -2
index c0914829a925..addbcdd02b9b 100644
@@ -282,8 +282,6 @@
 #define MSR_INTEGRITY_CAPS_ARRAY_BIST          BIT(MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT)
 #define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT	4
 #define MSR_INTEGRITY_CAPS_PERIODIC_BIST	BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT)
-#define MSR_INTEGRITY_CAPS_SBAF_BIT		8
-#define MSR_INTEGRITY_CAPS_SBAF			BIT(MSR_INTEGRITY_CAPS_SBAF_BIT)
 #define MSR_INTEGRITY_CAPS_SAF_GEN_MASK	GENMASK_ULL(10, 9)
 
 #define MSR_LBR_NHM_FROM		0x00000680
drivers/platform/x86/intel/ifs/core.c +0 -24
index 3dafa28a1010..574f2a366d06 100644
@@ -34,7 +34,6 @@ bool *ifs_pkg_auth;
 static const struct ifs_test_caps scan_test = {
 	.integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
 	.test_num = IFS_TYPE_SAF,
-	.image_suffix = "scan",
 };
 
 static const struct ifs_test_caps array_test = {
@@ -50,20 +49,6 @@ static const struct ifs_test_msrs scan_msrs = {
 	.test_ctrl = MSR_SAF_CTRL,
 };
 
-static const struct ifs_test_msrs sbaf_msrs = {
-	.copy_hashes = MSR_COPY_SBAF_HASHES,
-	.copy_hashes_status = MSR_SBAF_HASHES_STATUS,
-	.copy_chunks = MSR_AUTHENTICATE_AND_COPY_SBAF_CHUNK,
-	.copy_chunks_status = MSR_SBAF_CHUNKS_AUTHENTICATION_STATUS,
-	.test_ctrl = MSR_SBAF_CTRL,
-};
-
-static const struct ifs_test_caps sbaf_test = {
-	.integrity_cap_bit = MSR_INTEGRITY_CAPS_SBAF_BIT,
-	.test_num = IFS_TYPE_SBAF,
-	.image_suffix = "sbft",
-};
-
 static struct ifs_device ifs_devices[] = {
 	[IFS_TYPE_SAF] = {
 		.test_caps = &scan_test,
@@ -82,15 +67,6 @@ static struct ifs_device ifs_devices[] = {
 			.groups = plat_ifs_array_groups,
 		},
 	},
-	[IFS_TYPE_SBAF] = {
-		.test_caps = &sbaf_test,
-		.test_msrs = &sbaf_msrs,
-		.misc = {
-			.name = "intel_ifs_2",
-			.minor = MISC_DYNAMIC_MINOR,
-			.groups = plat_ifs_groups,
-		},
-	},
 };
 
 #define IFS_NUMTESTS ARRAY_SIZE(ifs_devices)
drivers/platform/x86/intel/ifs/ifs.h +1 -64

121 lines not on this page · raw message

drivers/platform/x86/intel/ifs/load.c +4 -12
index 50f1fdf7dfed..329400908cb2 100644
@@ -262,22 +262,20 @@ static int copy_hashes_authenticate_chunks_gen2(struct device *dev)
 		return -EIO;
 	}
 	ifsd->valid_chunks = valid_chunks;
-	ifsd->max_bundle = chunk_status.max_bundle;
 
 	return 0;
 }
 
 static int validate_ifs_metadata(struct device *dev)
 {
-	const struct ifs_test_caps *test = ifs_get_test_caps(dev);
 	struct ifs_data *ifsd = ifs_get_data(dev);
 	union meta_data *ifs_meta;
 	char test_file[64];
 	int ret = -EINVAL;
 
-	snprintf(test_file, sizeof(test_file), "%02x-%02x-%02x-%02x.%s",
+	snprintf(test_file, sizeof(test_file), "%02x-%02x-%02x-%02x.scan",
 		 boot_cpu_data.x86, boot_cpu_data.x86_model,
-		 boot_cpu_data.x86_stepping, ifsd->cur_batch, test->image_suffix);
+		 boot_cpu_data.x86_stepping, ifsd->cur_batch);
 
 	ifs_meta = (union meta_data *)find_meta_data(ifs_header_ptr, META_TYPE_IFS);
 	if (!ifs_meta) {
@@ -307,12 +305,6 @@ static int validate_ifs_metadata(struct device *dev)
 		return ret;
 	}
 
-	if (ifs_meta->test_type != test->test_num) {
-		dev_warn(dev, "Metadata test_type %d mismatches with device type\n",
-			 ifs_meta->test_type);
-		return ret;
-	}
-
 	return 0;
 }
 
@@ -400,9 +392,9 @@ int ifs_load_firmware(struct device *dev)
 	char scan_path[64];
 	int ret;
 
-	snprintf(scan_path, sizeof(scan_path), "intel/ifs_%d/%02x-%02x-%02x-%02x.%s",
+	snprintf(scan_path, sizeof(scan_path), "intel/ifs_%d/%02x-%02x-%02x-%02x.scan",
 		 test->test_num, boot_cpu_data.x86, boot_cpu_data.x86_model,
-		 boot_cpu_data.x86_stepping, ifsd->cur_batch, test->image_suffix);
+		 boot_cpu_data.x86_stepping, ifsd->cur_batch);
 
 	ret = request_firmware_direct(&fw, scan_path, dev);
 	if (ret) {
drivers/platform/x86/intel/ifs/runtest.c +0 -233

257 lines not on this page · raw message

include/trace/events/intel_ifs.h +0 -27
index 70323acde1de..0d88ebf2c980 100644
@@ -35,33 +35,6 @@ TRACE_EVENT(ifs_status,
 		__entry->status)
 );
 
-TRACE_EVENT(ifs_sbaf,
-
-	TP_PROTO(int batch, union ifs_sbaf activate, union ifs_sbaf_status status),
-
-	TP_ARGS(batch, activate, status),
-
-	TP_STRUCT__entry(
-		__field(	u64,	status	)
-		__field(	int,	batch	)
-		__field(	u16,	bundle	)
-		__field(	u16,	pgm	)
-	),
-
-	TP_fast_assign(
-		__entry->status	= status.data;
-		__entry->batch	= batch;
-		__entry->bundle	= activate.bundle_idx;
-		__entry->pgm	= activate.pgm_idx;
-	),
-
-	TP_printk("batch: 0x%.2x, bundle_idx: 0x%.4x, pgm_idx: 0x%.4x, status: 0x%.16llx",
-		__entry->batch,
-		__entry->bundle,
-		__entry->pgm,
-		__entry->status)
-);
-
 #endif /* _TRACE_IFS_H */
 
 /* This part must be outside protection */
tools/arch/x86/include/asm/msr-index.h +0 -2
index 9c26d4075c5f..a65cfa7a10e4 100644
@@ -280,8 +280,6 @@
 #define MSR_INTEGRITY_CAPS_ARRAY_BIST          BIT(MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT)
 #define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT	4
 #define MSR_INTEGRITY_CAPS_PERIODIC_BIST	BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT)
-#define MSR_INTEGRITY_CAPS_SBAF_BIT		8
-#define MSR_INTEGRITY_CAPS_SBAF			BIT(MSR_INTEGRITY_CAPS_SBAF_BIT)
 #define MSR_INTEGRITY_CAPS_SAF_GEN_MASK	GENMASK_ULL(10, 9)
 
 #define MSR_LBR_NHM_FROM		0x00000680
Signature · 1 line
2.43.0
#2 lore raw

PATCH v3 2/17 platform/x86/intel/ifs: Fix IFS sysfs interfaces in the comments

In reply to Ehab Ababneh

From: Qiuxu Zhuo <[email protected]>

The sysfs interfaces in the comments in sysfs.c are incorrect. Fix them. Additionally, improve some IFS comments and fix some typos in the comments such as: s/cpu/CPU, s/intel/Intel, s/ifs/IFS.

No functional changes.

---
 drivers/platform/x86/intel/ifs/ifs.h     | 16 ++++++++--------
 drivers/platform/x86/intel/ifs/load.c    |  2 +-
 drivers/platform/x86/intel/ifs/runtest.c |  8 ++++----
 drivers/platform/x86/intel/ifs/sysfs.c   | 23 +++++++++++------------
 4 files changed, 24 insertions(+), 25 deletions(-)
drivers/platform/x86/intel/ifs/ifs.h +8 -8
index f55528ac517b..0f5cdc1ad14d 100644
@@ -35,10 +35,10 @@
  * IFS Image Loading
  * -----------------
  *
- * The driver loads the tests into memory reserved BIOS local to each CPU
- * socket in a two step process using writes to MSRs to first load the
- * SHA hashes for the test. Then the tests themselves. Status MSRs provide
- * feedback on the success/failure of these steps.
+ * The driver loads the tests into memory reserved by BIOS, local to each CPU
+ * socket in a two-step process. It first writes to MSRs to load the SHA hashes
+ * for the test, followed by the tests themselves. Status MSRs provide feedback
+ * on the success or failure of these steps.
  *
  * The test files are kept in a fixed location: /lib/firmware/intel/ifs_<n>/
  * For e.g if there are 3 test files, they would be named in the following
@@ -83,14 +83,14 @@
  *
  * Test a specific core::
  *
- *   # echo <cpu#> > /sys/devices/virtual/misc/intel_ifs_<n>/run_test
+ *   # echo <CPU#> > /sys/devices/virtual/misc/intel_ifs_<n>/run_test
  *
- * when HT is enabled any of the sibling cpu# can be specified to test
+ * when HT is enabled any of the sibling CPU# can be specified to test
  * its corresponding physical core. Since the tests are per physical core,
  * the result of testing any thread is same. All siblings must be online
  * to run a core test. It is only necessary to test one thread.
  *
- * For e.g. to test core corresponding to cpu5
+ * For e.g. to test core corresponding to CPU5
  *
  *   # echo 5 > /sys/devices/virtual/misc/intel_ifs_<n>/run_test
  *
@@ -284,7 +284,7 @@ struct ifs_test_msrs {
 };
 
 /**
- * struct ifs_data - attributes related to intel IFS driver
+ * struct ifs_data - attributes related to Intel IFS driver
  * @loaded_version: stores the currently loaded ifs image version.
  * @loaded: If a valid test binary has been loaded into the memory
  * @loading_error: Error occurred on another CPU while loading image
drivers/platform/x86/intel/ifs/load.c +1 -1
index 329400908cb2..dde3f5eb379f 100644
@@ -108,7 +108,7 @@ static void auth_err_message(struct device *dev, u32 err_code)
 }
 
 /*
- * To copy scan hashes and authenticate test chunks, the initiating cpu must point
+ * To copy scan hashes and authenticate test chunks, the initiating CPU must point
  * to the EDX:EAX to the test image in linear address.
  * Run wrmsr(MSR_COPY_SCAN_HASHES) for scan hash copy and run wrmsr(MSR_AUTHENTICATE_AND_COPY_CHUNK)
  * for scan hash copy and test chunk authentication.
drivers/platform/x86/intel/ifs/runtest.c +4 -4
index 1762eab7fe5c..96b538c665f4 100644
@@ -149,7 +149,7 @@ static atomic_t array_cpus_in;
 static atomic_t scan_cpus_in;
 
 /*
- * Simplified cpu sibling rendezvous loop based on microcode loader __wait_for_cpus()
+ * Simplified CPU sibling rendezvous loop based on microcode loader wait_for_cpus()
  */
 static void wait_for_sibling_cpu(atomic_t *t, long long timeout)
 {
@@ -389,8 +389,8 @@ static void ifs_array_test_gen1(int cpu, struct device *dev)
 }
 
 /*
- * Initiate per core test. It wakes up work queue threads on the target cpu and
- * its sibling cpu. Once all sibling threads wake up, the scan test gets executed and
+ * Initiate per core test. It wakes up work queue threads on the target CPU and
+ * its sibling CPU. Once all sibling threads wake up, the scan test gets executed and
  * wait for all sibling threads to finish the scan test.
  */
 int do_core_test(int cpu, struct device *dev)
@@ -403,7 +403,7 @@ int do_core_test(int cpu, struct device *dev)
 	cpus_read_lock();
 
 	if (!cpu_online(cpu)) {
-		dev_info(dev, "cannot test on the offline cpu %d\n", cpu);
+		dev_info(dev, "cannot test on the offline CPU %d\n", cpu);
 		ret = -EINVAL;
 		goto out;
 	}
drivers/platform/x86/intel/ifs/sysfs.c +11 -12
index 01b7502f46b0..287f96bb033e 100644
@@ -10,14 +10,14 @@
 #include "ifs.h"
 
 /*
- * Protects against simultaneous tests on multiple cores, or
- * reloading can file while a test is in progress
+ * Protect against simultaneous tests on multiple cores and prevent
+ * the reloading of IFS image file while a test is in progress.
  */
 static DEFINE_SEMAPHORE(ifs_sem, 1);
 
 /*
- * The sysfs interface to check additional details of last test
- * cat /sys/devices/system/platform/ifs/details
+ * The sysfs interface to check additional details of the last test:
+ * cat /sys/devices/virtual/misc/intel_ifs_<n>/details
  */
 static ssize_t details_show(struct device *dev,
 			    struct device_attribute *attr,
@@ -37,9 +37,8 @@ static const char * const status_msg[] = {
 };
 
 /*
- * The sysfs interface to check the test status:
- * To check the status of last test
- * cat /sys/devices/platform/ifs/status
+ * The sysfs interface to check the last test status:
+ * cat /sys/devices/virtual/misc/intel_ifs_<n>/status
  */
 static ssize_t status_show(struct device *dev,
 			   struct device_attribute *attr,
@@ -53,12 +52,12 @@ static ssize_t status_show(struct device *dev,
 static DEVICE_ATTR_RO(status);
 
 /*
- * The sysfs interface for single core testing
- * To start test, for example, cpu5
- * echo 5 > /sys/devices/platform/ifs/run_test
+ * The sysfs interface for single-core testing.
+ * To start a test, for example on CPU5:
+ * echo 5 > /sys/devices/virtual/misc/intel_ifs_<n>/run_test
  * To check the result:
- * cat /sys/devices/platform/ifs/result
- * The sibling core gets tested at the same time.
+ * cat /sys/devices/virtual/misc/intel_ifs_<n>/status
+ * The sibling thread gets tested at the same time.
  */
 static ssize_t run_test_store(struct device *dev,
 			      struct device_attribute *attr,
Signature · 1 line
2.43.0
#3 lore raw

PATCH v3 3/17 platform/x86/intel/ifs: Clarify In-Field Scan MSR bit macro definitions

In reply to Ehab Ababneh

From: Qiuxu Zhuo <[email protected]>

Current macros for Intel In-Field Scan MSR bits are confusing. They don't clearly distinguish between testing types (Scan At Field vs. Array BIST) or testing timing (processor startup vs. Linux Intel IFS driver at runtime).

Clarify these macros by adopting the naming convention from [1]:

- PERIODIC (vs. STARTUP) indicates testing capability at runtime.

- SCAN_BIST indicates Scan At Field testing capability.

- ARRAY_BIST indicates Array BIST testing capability [2].

Additionally, align these macros vertically for better readability.

No functional changes.

[1] Intel 64 and IA-32 Architectures Software Developer's Manual (SDM), Vol. 4, "Additional MSRs Supported by the Intel Xeon 6 P-Core Processors".

[2] Use ARRAY_BIST instead of MEM_BIST used in [1], which is confusing with DDR memory.

---
 arch/x86/include/asm/msr-index.h       | 12 ++++++------
 drivers/platform/x86/intel/ifs/core.c  |  4 ++--
 tools/arch/x86/include/asm/msr-index.h | 12 ++++++------
 3 files changed, 14 insertions(+), 14 deletions(-)
arch/x86/include/asm/msr-index.h +6 -6
index addbcdd02b9b..fcf58e1b381f 100644
@@ -277,12 +277,12 @@
 #define MSR_IA32_POWER_CTL_BIT_EE	19
 
 /* Abbreviated from Intel SDM name IA32_INTEGRITY_CAPABILITIES */
-#define MSR_INTEGRITY_CAPS			0x000002d9
-#define MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT      2
-#define MSR_INTEGRITY_CAPS_ARRAY_BIST          BIT(MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT)
-#define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT	4
-#define MSR_INTEGRITY_CAPS_PERIODIC_BIST	BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT)
-#define MSR_INTEGRITY_CAPS_SAF_GEN_MASK	GENMASK_ULL(10, 9)
+#define MSR_INTEGRITY_CAPS				0x000002d9
+#define MSR_INTEGRITY_CAPS_PERIODIC_ARRAY_BIST_BIT	2
+#define MSR_INTEGRITY_CAPS_PERIODIC_ARRAY_BIST		BIT(MSR_INTEGRITY_CAPS_PERIODIC_ARRAY_BIST_BIT)
+#define MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST_BIT	4
+#define MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST		BIT(MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST_BIT)
+#define MSR_INTEGRITY_CAPS_SAF_GEN_MASK			GENMASK_ULL(10, 9)
 
 #define MSR_LBR_NHM_FROM		0x00000680
 #define MSR_LBR_NHM_TO			0x000006c0
drivers/platform/x86/intel/ifs/core.c +2 -2
index 574f2a366d06..85a04ecc9dbe 100644
@@ -32,12 +32,12 @@ ATTRIBUTE_GROUPS(plat_ifs_array);
 bool *ifs_pkg_auth;
 
 static const struct ifs_test_caps scan_test = {
-	.integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
+	.integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST_BIT,
 	.test_num = IFS_TYPE_SAF,
 };
 
 static const struct ifs_test_caps array_test = {
-	.integrity_cap_bit = MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT,
+	.integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_ARRAY_BIST_BIT,
 	.test_num = IFS_TYPE_ARRAY_BIST,
 };
 
tools/arch/x86/include/asm/msr-index.h +6 -6
index a65cfa7a10e4..2a243fda4e5c 100644
@@ -275,12 +275,12 @@
 #define MSR_IA32_POWER_CTL_BIT_EE	19
 
 /* Abbreviated from Intel SDM name IA32_INTEGRITY_CAPABILITIES */
-#define MSR_INTEGRITY_CAPS			0x000002d9
-#define MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT      2
-#define MSR_INTEGRITY_CAPS_ARRAY_BIST          BIT(MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT)
-#define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT	4
-#define MSR_INTEGRITY_CAPS_PERIODIC_BIST	BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT)
-#define MSR_INTEGRITY_CAPS_SAF_GEN_MASK	GENMASK_ULL(10, 9)
+#define MSR_INTEGRITY_CAPS				0x000002d9
+#define MSR_INTEGRITY_CAPS_PERIODIC_ARRAY_BIST_BIT	2
+#define MSR_INTEGRITY_CAPS_PERIODIC_ARRAY_BIST		BIT(MSR_INTEGRITY_CAPS_PERIODIC_ARRAY_BIST_BIT)
+#define MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST_BIT	4
+#define MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST		BIT(MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST_BIT)
+#define MSR_INTEGRITY_CAPS_SAF_GEN_MASK			GENMASK_ULL(10, 9)
 
 #define MSR_LBR_NHM_FROM		0x00000680
 #define MSR_LBR_NHM_TO			0x000006c0
Signature · 1 line
2.43.0
#4 lore raw

PATCH v3 4/17 platform/x86/intel/ifs: Use u64 to define the bits of IFS MSR registers

In reply to Ehab Ababneh

From: Qiuxu Zhuo <[email protected]>

The IFS (In-Field Scan) related MSR registers are all 64-bit wide. Use a single u64 within a struct to define the bits of an IFS MSR register in a more compact form, instead of using {u16, u32} for each bit, to enhance readability.

No functional changes.

---
 drivers/platform/x86/intel/ifs/ifs.h | 66 ++++++++++++++--------------
 1 file changed, 33 insertions(+), 33 deletions(-)
drivers/platform/x86/intel/ifs/ifs.h +33 -33
index 0f5cdc1ad14d..f52287745366 100644
@@ -156,26 +156,26 @@
 union ifs_scan_hashes_status {
 	u64	data;
 	struct {
-		u32	chunk_size	:16;
-		u32	num_chunks	:8;
-		u32	rsvd1		:8;
-		u32	error_code	:8;
-		u32	rsvd2		:11;
-		u32	max_core_limit	:12;
-		u32	valid		:1;
+		u64	chunk_size	: 16,
+			num_chunks	:  8,
+			rsvd1		:  8,
+			error_code	:  8,
+			rsvd2		: 11,
+			max_core_limit	: 12,
+			valid		:  1;
 	};
 };
 
 union ifs_scan_hashes_status_gen2 {
 	u64	data;
 	struct {
-		u16	chunk_size;
-		u16	num_chunks;
-		u32	error_code		:8;
-		u32	chunks_in_stride	:9;
-		u32	rsvd			:2;
-		u32	max_core_limit		:12;
-		u32	valid			:1;
+		u64	chunk_size		: 16,
+			num_chunks		: 16,
+			error_code		:  8,
+			chunks_in_stride	:  9,
+			rsvd			:  2,
+			max_core_limit		: 12,
+			valid			:  1;
 	};
 };
 
@@ -183,21 +183,21 @@ union ifs_scan_hashes_status_gen2 {
 union ifs_chunks_auth_status {
 	u64	data;
 	struct {
-		u32	valid_chunks	:8;
-		u32	total_chunks	:8;
-		u32	rsvd1		:16;
-		u32	error_code	:8;
-		u32	rsvd2		:24;
+		u64	valid_chunks	:  8,
+			total_chunks	:  8,
+			rsvd1		: 16,
+			error_code	:  8,
+			rsvd2		: 24;
 	};
 };
 
 union ifs_chunks_auth_status_gen2 {
 	u64	data;
 	struct {
-		u16	valid_chunks;
-		u16	total_chunks;
-		u32	error_code	:8;
-		u32	rsvd2		:24;
+		u64	valid_chunks	: 16,
+			total_chunks	: 16,
+			error_code	:  8,
+			rsvd2		: 24;
 	};
 };
 
@@ -216,8 +216,8 @@ union ifs_scan {
 				u16	stop;
 			} gen2;
 		};
-		u32	delay	:31;
-		u32	sigmce	:1;
+		u32	delay	: 31,
+			sigmce	:  1;
 	};
 };
 
@@ -236,10 +236,10 @@ union ifs_status {
 				u16	chunk_stop_index;
 			} gen2;
 		};
-		u32	error_code		:8;
-		u32	rsvd2			:22;
-		u32	control_error		:1;
-		u32	signature_error		:1;
+		u32	error_code		:  8,
+			rsvd2			: 22,
+			control_error		:  1,
+			signature_error		:  1;
 	};
 };
 
@@ -247,10 +247,10 @@ union ifs_status {
 union ifs_array {
 	u64	data;
 	struct {
-		u32	array_bitmask;
-		u16	array_bank;
-		u16	rsvd			:15;
-		u16	ctrl_result		:1;
+		u64	array_bitmask		: 32,
+			array_bank		: 16,
+			rsvd			: 15,
+			ctrl_result		:  1;
 	};
 };
 
Signature · 1 line
2.43.0
#5 lore raw

PATCH v3 5/17 platform/x86/intel/ifs: Early return on the IFS image hash/chunk error

In reply to Ehab Ababneh

From: Qiuxu Zhuo <[email protected]>

Return immediately upon encountering a hash error or chunk error in the IFS (In-Field Scan) test image to avoid meaningless assignments following these errors.

Additionally, assign the boolean value 'true' instead of '1' to the boolean variable 'ifs_pkg_auth', and use SZ_1K macro instead of '1024' for better readability.

---
 drivers/platform/x86/intel/ifs/load.c | 34 ++++++++++++---------------
 1 file changed, 15 insertions(+), 19 deletions(-)
drivers/platform/x86/intel/ifs/load.c +15 -19
index dde3f5eb379f..0edbf9eedc12 100644
@@ -123,7 +123,6 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work)
 	int i, num_chunks, chunk_size;
 	struct ifs_data *ifsd;
 	u64 linear_addr, base;
-	u32 err_code;
 
 	ifsd = ifs_get_data(dev);
 	msrs = ifs_get_test_msrs(dev);
@@ -131,17 +130,16 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work)
 	wrmsrq(msrs->copy_hashes, ifs_hash_ptr);
 	rdmsrq(msrs->copy_hashes_status, hashes_status.data);
 
-	/* enumerate the scan image information */
-	num_chunks = hashes_status.num_chunks;
-	chunk_size = hashes_status.chunk_size * 1024;
-	err_code = hashes_status.error_code;
-
 	if (!hashes_status.valid) {
 		ifsd->loading_error = true;
-		hashcopy_err_message(dev, err_code);
+		hashcopy_err_message(dev, hashes_status.error_code);
 		goto done;
 	}
 
+	/* enumerate the scan image information */
+	num_chunks = hashes_status.num_chunks;
+	chunk_size = hashes_status.chunk_size * SZ_1K;
+
 	/* base linear address to the scan data */
 	base = ifs_test_image_ptr;
 
@@ -153,14 +151,13 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work)
 		wrmsrq(msrs->copy_chunks, linear_addr);
 		rdmsrq(msrs->copy_chunks_status, chunk_status.data);
 
-		ifsd->valid_chunks = chunk_status.valid_chunks;
-		err_code = chunk_status.error_code;
-
-		if (err_code) {
+		if (chunk_status.error_code) {
 			ifsd->loading_error = true;
-			auth_err_message(dev, err_code);
+			auth_err_message(dev, chunk_status.error_code);
 			goto done;
 		}
+
+		ifsd->valid_chunks = chunk_status.valid_chunks;
 	}
 done:
 	complete(&ifs_done);
@@ -199,16 +196,15 @@ static int copy_hashes_authenticate_chunks_gen2(struct device *dev)
 		wrmsrq(msrs->copy_hashes, ifs_hash_ptr);
 		rdmsrq(msrs->copy_hashes_status, hashes_status.data);
 
+		if (!hashes_status.valid) {
+			hashcopy_err_message(dev, hashes_status.error_code);
+			return -EIO;
+		}
+
 		/* enumerate the scan image information */
 		chunk_size = hashes_status.chunk_size * SZ_1K;
-		err_code = hashes_status.error_code;
-
 		num_chunks = get_num_chunks(ifsd->generation, hashes_status);
 
-		if (!hashes_status.valid) {
-			hashcopy_err_message(dev, err_code);
-			return -EIO;
-		}
 		ifsd->loaded_version = ifs_header_ptr->rev;
 		ifsd->chunk_size = chunk_size;
 	} else {
@@ -344,7 +340,7 @@ static int scan_chunks_sanity_check(struct device *dev)
 			ret = -EIO;
 			goto out;
 		}
-		ifs_pkg_auth[curr_pkg] = 1;
+		ifs_pkg_auth[curr_pkg] = true;
 	}
 	ret = 0;
 	ifsd->loaded_version = ifs_header_ptr->rev;
Signature · 1 line
2.43.0
#6 lore raw

PATCH v3 6/17 platform/x86/intel/ifs: Refactor Array BIST function interface

In reply to Ehab Ababneh

From: Jithu Joseph <[email protected]>

In preparation for upcoming changes, refactor the Array BIST test to use a more generic structure (run_array_params) when passing parameters to the caller function.

This change enhances maintainability and flexibility for future modifications.

---
 drivers/platform/x86/intel/ifs/runtest.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/platform/x86/intel/ifs/runtest.c +12 -2
index 96b538c665f4..c6a4d6dcccf1 100644
@@ -30,6 +30,11 @@ struct run_params {
 	union ifs_status status;
 };
 
+struct run_array_params {
+	struct ifs_data *ifsd;
+	union ifs_array *command;
+};
+
 /*
  * Number of TSC cycles that a logical CPU will wait for the other
  * logical CPU on the core in the WRMSR(ACTIVATE_SCAN).
@@ -302,10 +307,12 @@ static void ifs_test_core(int cpu, struct device *dev)
 
 static int do_array_test(void *data)
 {
-	union ifs_array *command = data;
+	struct run_array_params *params = data;
 	int cpu = smp_processor_id();
+	union ifs_array *command;
 	int first;
 
+	command = params->command;
 	wait_for_sibling_cpu(&array_cpus_in, NSEC_PER_SEC);
 
 	/*
@@ -324,12 +331,14 @@ static int do_array_test(void *data)
 
 static void ifs_array_test_core(int cpu, struct device *dev)
 {
+	struct run_array_params params;
 	union ifs_array command = {};
 	bool timed_out = false;
 	struct ifs_data *ifsd;
 	unsigned long timeout;
 
 	ifsd = ifs_get_data(dev);
+	params.ifsd = ifsd;
 
 	command.array_bitmask = ~0U;
 	timeout = jiffies + HZ / 2;
@@ -340,7 +349,8 @@ static void ifs_array_test_core(int cpu, struct device *dev)
 			break;
 		}
 		atomic_set(&array_cpus_in, 0);
-		stop_core_cpuslocked(cpu, do_array_test, &command);
+		params.command = &command;
+		stop_core_cpuslocked(cpu, do_array_test, &params);
 
 		if (command.ctrl_result)
 			break;
Signature · 1 line
2.43.0
#7 lore raw

PATCH v3 7/17 stop_machine: Add stop_cluster_cpuslocked() for per-cluster operations

In reply to Ehab Ababneh

From: Qiuxu Zhuo <[email protected]>

stop_core_cpuslocked() can only run a function simultaneously on the threads of a single core. However, Intel In-Field Scan (IFS) on Diamond Rapids requires a near-simultaneous WRMSR on all threads of a cluster to start a test, because the cores of a module share one scan test engine.

Add stop_cluster_cpuslocked(), a customized version of stop_machine_cpuslocked() for operating solely on the threads of a single cluster.

---
 include/linux/stop_machine.h | 15 +++++++++++++++
 kernel/stop_machine.c        | 35 ++++++++++++++++++++++-------------
 2 files changed, 37 insertions(+), 13 deletions(-)
include/linux/stop_machine.h +15 -0
index 84e7fb627ba4..870ea49aa32a 100644
@@ -157,6 +157,21 @@ int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, const struct cpumask *
  */
 int stop_core_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data);
 
+/**
+ * stop_cluster_cpuslocked - stop all threads on a CPU cluster
+ * @cpu: any CPU in the targeted cluster
+ * @fn: the function to run
+ * @data: the data ptr for @fn()
+ *
+ * Same as above, only the CPUs associated with a single CPU cluster are affected.
+ *
+ * Context: Must be called from within a cpus_read_lock() protected region.
+ *
+ * Return: 0 if all executions of @fn returned 0, any non zero return
+ * value if any returned non zero.
+ */
+int stop_cluster_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data);
+
 int stop_machine_from_inactive_cpu(cpu_stop_fn_t fn, void *data,
 				   const struct cpumask *cpus);
 #else	/* CONFIG_SMP || CONFIG_HOTPLUG_CPU */
kernel/stop_machine.c +22 -13
index d085ba1f4b44..1afda0ddfb90 100644
@@ -630,32 +630,41 @@ int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus)
 }
 EXPORT_SYMBOL_GPL(stop_machine);
 
-#ifdef CONFIG_SCHED_SMT
-/*
- * INTEL_IFS is the only user of this API. That selftest can
- * only be compiled if SMP=y. On x86 it selects SCHED_SMT.
- * Keep the ifdefs for now.
- */
-int stop_core_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data)
+static int stop_cpus_cpuslocked(const struct cpumask *cpus, cpu_stop_fn_t fn, void *data)
 {
-	const struct cpumask *smt_mask = cpu_smt_mask(cpu);
-
 	struct multi_stop_data msdata = {
 		.fn = fn,
 		.data = data,
-		.num_threads = cpumask_weight(smt_mask),
-		.active_cpus = smt_mask,
+		.num_threads = cpumask_weight(cpus),
+		.active_cpus = cpus,
 	};
 
 	lockdep_assert_cpus_held();
 
-	/* Set the initial state and stop all online cpus. */
+	/* Set the initial state and stop all online @cpus. */
 	set_state(&msdata, MULTI_STOP_PREPARE);
-	return stop_cpus(smt_mask, multi_cpu_stop, &msdata);
+	return stop_cpus(cpus, multi_cpu_stop, &msdata);
+}
+
+#ifdef CONFIG_SCHED_SMT
+/*
+ * INTEL_IFS is the only user of this API. That selftest can
+ * only be compiled if SMP=y. On x86 it selects SCHED_SMT.
+ * Keep the ifdefs for now.
+ */
+int stop_core_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data)
+{
+	return stop_cpus_cpuslocked(cpu_smt_mask(cpu), fn, data);
 }
 EXPORT_SYMBOL_GPL(stop_core_cpuslocked);
 #endif
 
+int stop_cluster_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data)
+{
+	return stop_cpus_cpuslocked(topology_cluster_cpumask(cpu), fn, data);
+}
+EXPORT_SYMBOL_GPL(stop_cluster_cpuslocked);
+
 /**
  * stop_machine_from_inactive_cpu - stop_machine() from inactive CPU
  * @fn: the function to run
Signature · 1 line
2.43.0
#8 lore raw

PATCH v3 8/17 platform/x86/intel/ifs: Enumerate the bit to determine if CPUs need to join for IFS tests

In reply to Ehab Ababneh

From: Jithu Joseph <[email protected]>

Starting with Granite Rapids (GNR), bit 21 (ALL_LP_JOIN_NEEDED) of MSR_INTEGRITY_CAPABILITIES register [1] indicates whether all CPUs sharing the scan test engine need to be tested together. These CPUs must join using MSR_ACTIVATE_SCAN.

Add an enumeration of bit 21 to determine if CPUs need to join to run IFS tests together.

[1] Vol. 4 "Table 2-56. Additional MSRs Supported by the Intel® Xeon® 6 P-Core Processors" in the Intel Software Developers' Manual, March 2025.

---
 arch/x86/include/asm/msr-index.h      |  2 ++
 drivers/platform/x86/intel/ifs/core.c | 12 ++++++++++++
 drivers/platform/x86/intel/ifs/ifs.h  |  2 ++
 3 files changed, 16 insertions(+)
arch/x86/include/asm/msr-index.h +2 -0
index fcf58e1b381f..9224b55e1f07 100644
@@ -283,6 +283,8 @@
 #define MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST_BIT	4
 #define MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST		BIT(MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST_BIT)
 #define MSR_INTEGRITY_CAPS_SAF_GEN_MASK			GENMASK_ULL(10, 9)
+#define MSR_INTEGRITY_CAPS_ALL_LP_JOIN_BIT		21
+#define MSR_INTEGRITY_CAPS_ALL_LP_JOIN			BIT(MSR_INTEGRITY_CAPS_ALL_LP_JOIN_BIT)
 
 #define MSR_LBR_NHM_FROM		0x00000680
 #define MSR_LBR_NHM_TO			0x000006c0
drivers/platform/x86/intel/ifs/core.c +12 -0
index 85a04ecc9dbe..f2d2caab0479 100644
@@ -110,6 +110,18 @@ static int __init ifs_init(void)
 			continue;
 		ifs_devices[i].rw_data.generation = FIELD_GET(MSR_INTEGRITY_CAPS_SAF_GEN_MASK,
 							      msrval);
+		/*
+		 * For Sapphire Rapids and Emerald Rapids (SAF_GEN=0), the ALL_LP_JOIN
+		 * indicator is unavailable. However, all the threads within a core still
+		 * need to run IFS simultaneously, so the variable 'all_lp_join' is
+		 * forced to true.
+		 *
+		 * For Granite Rapids and later generations (SAF_GEN=2), the ALL_LP_JOIN
+		 * indicator is available, the variable 'all_lp_join' is determined by
+		 * this indicator.
+		 */
+		ifs_devices[i].rw_data.all_lp_join = ifs_devices[i].rw_data.generation ?
+						(msrval & MSR_INTEGRITY_CAPS_ALL_LP_JOIN) : true;
 		ifs_devices[i].rw_data.array_gen = (u32)m->driver_data;
 		ret = misc_register(&ifs_devices[i].misc);
 		if (ret)
drivers/platform/x86/intel/ifs/ifs.h +2 -0
index f52287745366..814ebac10a5d 100644
@@ -295,6 +295,7 @@ struct ifs_test_msrs {
  * @generation: IFS test generation enumerated by hardware
  * @chunk_size: size of a test chunk
  * @array_gen: test generation of array test
+ * @all_lp_join: all logical processors join test
  */
 struct ifs_data {
 	int	loaded_version;
@@ -307,6 +308,7 @@ struct ifs_data {
 	u32	generation;
 	u32	chunk_size;
 	u32	array_gen;
+	bool	all_lp_join;
 };
 
 struct ifs_work {
Signature · 1 line
2.43.0
#9 lore raw

PATCH v3 9/17 platform/x86/intel/ifs: Select CPUs from topology_cluster_cpumask() for simultaneous IFS tests

In reply to Ehab Ababneh

From: Jithu Joseph <[email protected]>

The current intel_ifs driver selects CPUs from cpu_smt_mask() to run IFS test simultaneously. This approach works well for processors currently supported by the intel_ifs driver, where threads in a CPU core share the same SCAN test engine. However, it will not work for new Intel Xeon processors, such as Diamond Rapids, where multiple CPU cores in a module share the same SCAN test engine and must run IFS tests simultaneously.

Starting with Granite Rapids (GNR) and later generations, bit[20:16] (TID_BIT_SHIFT) of MSR_INTEGRITY_CAPABILITIES register [1] contains the number of bits to shift right on x2APICID to obtain a unique topology ID for all logical processors that share a SCAN test engine. In theory, computing a cpumask by this method and using a stop_machine() variant with an arbitrary cpumask passed in to rendezvous CPUs for simultaneous IFS tests should work for both cases where threads in a core or CPU cores in a module share the same SCAN test engine. However, as per Tony Luck's feedback and the previous discussion [2], a stop_machine() variant with an arbitrary cpumask is not wanted.

Observations on existing Intel Xeon processors and the upcoming Diamond Rapids with IFS capability show that the logical processors sharing the same SCAN test engine are exactly the logical processors sharing the same L2 cache.

topology_cluster_cpumask() returns the cpumask for CPUs sharing the same L2 cache. Therefore, select CPUs from topology_cluster_cpumask() to run IFS tests if simultaneous testing is required.

[1] Vol. 4 "Table 2-56. Additional MSRs Supported by the Intel® Xeon® 6 P-Core Processors" in the Intel Software Developers' Manual, March 2025.

---
 drivers/platform/x86/intel/ifs/ifs.h     |  2 +
 drivers/platform/x86/intel/ifs/runtest.c | 59 +++++++++++++++++++-----
 2 files changed, 49 insertions(+), 12 deletions(-)
drivers/platform/x86/intel/ifs/ifs.h +2 -0
index 814ebac10a5d..365429fafe7a 100644
@@ -285,6 +285,7 @@ struct ifs_test_msrs {
 
 /**
  * struct ifs_data - attributes related to Intel IFS driver
+ * @grp_cpumask: set of CPUs being tested simultaneously
  * @loaded_version: stores the currently loaded ifs image version.
  * @loaded: If a valid test binary has been loaded into the memory
  * @loading_error: Error occurred on another CPU while loading image
@@ -298,6 +299,7 @@ struct ifs_test_msrs {
  * @all_lp_join: all logical processors join test
  */
 struct ifs_data {
+	cpumask_t	grp_cpumask;
 	int	loaded_version;
 	bool	loaded;
 	bool	loading_error;
drivers/platform/x86/intel/ifs/runtest.c +47 -12

120 lines not on this page · raw message

Signature · 1 line
2.43.0
#10 lore raw

PATCH v3 10/17 platform/x86/intel/ifs: Warn if a group test fails with CPUs missing

In reply to Ehab Ababneh

All the logical processors that share a SCAN test engine must join a group test. TID_BIT_SHIFT [1] gives the number of low APIC ID bits that tell these logical processors apart. The driver builds the group from topology_cluster_cpumask(), which only holds CPUs that are enumerated and online. So it cannot tell whether every logical processor sharing the engine actually takes part, for example on a part that exposes only one core per module, or when a sibling has been taken offline.

Checking this once at driver load does not help: the group can change at runtime through CPU hotplug, and failing to load would stop parts that may still test fine. Instead, read TID_BIT_SHIFT at init and, when a test does not pass, check whether all logical processors in the CPU's TID_BIT_SHIFT APIC ID range were in the group. If not, say so in the log. The test is run either way.

TID_BIT_SHIFT is only enumerated starting with SAF_GEN=2 (Granite Rapids), so skip the check on SAF_GEN=0 parts (Sapphire Rapids and Emerald Rapids).

[1] Vol. 4 "Table 2-56. Additional MSRs Supported by the Intel® Xeon® 6 P-Core Processors" in the Intel Software Developers' Manual, March 2025.

---
 arch/x86/include/asm/msr-index.h         |  1 +
 drivers/platform/x86/intel/ifs/core.c    |  6 +++++
 drivers/platform/x86/intel/ifs/ifs.h     |  2 ++
 drivers/platform/x86/intel/ifs/runtest.c | 33 ++++++++++++++++++++++++
 4 files changed, 42 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
index 9224b55e1f07..baa16d75749d 100644
@@ -283,6 +283,7 @@
 #define MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST_BIT	4
 #define MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST		BIT(MSR_INTEGRITY_CAPS_PERIODIC_SCAN_BIST_BIT)
 #define MSR_INTEGRITY_CAPS_SAF_GEN_MASK			GENMASK_ULL(10, 9)
+#define MSR_INTEGRITY_CAPS_TID_BIT_SHIFT_MASK		GENMASK_ULL(20, 16)
 #define MSR_INTEGRITY_CAPS_ALL_LP_JOIN_BIT		21
 #define MSR_INTEGRITY_CAPS_ALL_LP_JOIN			BIT(MSR_INTEGRITY_CAPS_ALL_LP_JOIN_BIT)
 
drivers/platform/x86/intel/ifs/core.c +6 -0
index f2d2caab0479..b9ac04228141 100644
@@ -122,6 +122,12 @@ static int __init ifs_init(void)
 		 */
 		ifs_devices[i].rw_data.all_lp_join = ifs_devices[i].rw_data.generation ?
 						(msrval & MSR_INTEGRITY_CAPS_ALL_LP_JOIN) : true;
+
+		/* TID_BIT_SHIFT is only enumerated on SAF_GEN=2 and later */
+		if (ifs_devices[i].rw_data.generation)
+			ifs_devices[i].rw_data.tid_bit_shift =
+				FIELD_GET(MSR_INTEGRITY_CAPS_TID_BIT_SHIFT_MASK, msrval);
+
 		ifs_devices[i].rw_data.array_gen = (u32)m->driver_data;
 		ret = misc_register(&ifs_devices[i].misc);
 		if (ret)
drivers/platform/x86/intel/ifs/ifs.h +2 -0
index 365429fafe7a..62db0a6aa940 100644
@@ -297,6 +297,7 @@ struct ifs_test_msrs {
  * @chunk_size: size of a test chunk
  * @array_gen: test generation of array test
  * @all_lp_join: all logical processors join test
+ * @tid_bit_shift: APIC-ID bits of the logical processors sharing a scan engine
  */
 struct ifs_data {
 	cpumask_t	grp_cpumask;
@@ -311,6 +312,7 @@ struct ifs_data {
 	u32	chunk_size;
 	u32	array_gen;
 	bool	all_lp_join;
+	u8	tid_bit_shift;
 };
 
 struct ifs_work {
drivers/platform/x86/intel/ifs/runtest.c +33 -0
index 9797e1e6dd51..a67f2b313eb9 100644
@@ -1,10 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright(c) 2022 Intel Corporation. */
 
+#include <linux/bits.h>
 #include <linux/cpu.h>
 #include <linux/delay.h>
 #include <linux/fs.h>
 #include <linux/nmi.h>
+#include <linux/processor.h>
 #include <linux/slab.h>
 #include <linux/stop_machine.h>
 #include <asm/msr.h>
@@ -430,6 +432,32 @@ static void build_cpugroup_mask(struct device *dev, int cpu)
 	cpumask_copy(&ifsd->grp_cpumask, topology_cluster_cpumask(cpu));
 }
 
+/*
+ * Check whether all logical processors that share the scan engine with @cpu
+ * (the TID_BIT_SHIFT APIC-ID range) are online and in the test group. If not,
+ * the test is still attempted; it may pass if the microcode handles the
+ * missing logical processors, e.g. a module with only one core.
+ */
+static bool ifs_group_incomplete(int cpu, struct ifs_data *ifsd)
+{
+	u32 shift = ifsd->tid_bit_shift;
+	u32 engine = cpu_data(cpu).topo.apicid >> shift;
+	int i;
+
+	if (!ifsd->generation || !ifsd->all_lp_join)
+		return false;
+
+	if (cpumask_weight(&ifsd->grp_cpumask) != BIT(shift))
+		return true;
+
+	for_each_cpu(i, &ifsd->grp_cpumask) {
+		if (cpu_data(i).topo.apicid >> shift != engine)
+			return true;
+	}
+
+	return false;
+}
+
 /*
  * Initiate per core test. It wakes up work queue threads on the target CPU and
  * its sibling CPU. Once all sibling threads wake up, the scan test gets executed and
@@ -469,6 +497,11 @@ int do_core_test(int cpu, struct device *dev)
 	default:
 		ret = -EINVAL;
 	}
+
+	if (!ret && ifsd->status != SCAN_TEST_PASS && ifs_group_incomplete(cpu, ifsd)) {
+		dev_warn(dev, "CPU %d: test did not pass; not all CPUs sharing the scan engine were found (group %*pbl)\n",
+			 cpu, cpumask_pr_args(&ifsd->grp_cpumask));
+	}
 out:
 	cpus_read_unlock();
 	return ret;
Signature · 1 line
2.43.0
#11 lore raw

PATCH v3 11/17 platform/x86/intel/ifs: Track and report scan results on a per-CPU basis

In reply to Ehab Ababneh

From: Jithu Joseph <[email protected]>

IFS requires invoking the scan simultaneously within a group of CPUs, as indicated in the MSR_INTEGRITY_CAPABILITIES (bits 20:16). When bit 21 is set, it indicates that all threads in the groups need to trigger the test at the same time.

When the tests are run simultaneously, record the test results in a per-CPU structure. This reduces the need to redundantly repeat the test for all thread in the same group.

There are several benefits:

- Reduced power consumption by avoiding multiple scans.

- Decreased time to complete a scan by 50% or more.

- These tests could take up to 200ms. Prevents taking these cores out of circulation just to repeat tests that have already been conducted.

The cores in a group share a scan engine but each reports its own result, and they can differ. So when a test is restarted, restart from the lowest chunk any CPU in the group reached. When the test times out or stops making progress, mark only the CPUs that did not reach the last chunk as timed out or partially completed, and keep any error code a CPU's hardware reported.

The existing status and details files now report the result of the whole group: status is "pass" only if every CPU in the group passed. Otherwise it is "fail" if any CPU failed, or "untested" if any CPU was not fully tested, and details holds the status of the first such CPU. The new per-CPU files added later in this series show which CPU did not pass.

---
 drivers/platform/x86/intel/ifs/core.c    |  17 ++-
 drivers/platform/x86/intel/ifs/ifs.h     |  12 ++
 drivers/platform/x86/intel/ifs/runtest.c | 174 ++++++++++++++++-------
 3 files changed, 154 insertions(+), 49 deletions(-)
drivers/platform/x86/intel/ifs/core.c +16 -1
index b9ac04228141..25b7c0f6427e 100644
@@ -49,6 +49,8 @@ static const struct ifs_test_msrs scan_msrs = {
 	.test_ctrl = MSR_SAF_CTRL,
 };
 
+DEFINE_PER_CPU(struct ifs_test_output, ifs_scan_n);
+
 static struct ifs_device ifs_devices[] = {
 	[IFS_TYPE_SAF] = {
 		.test_caps = &scan_test,
@@ -58,6 +60,9 @@ static struct ifs_device ifs_devices[] = {
 			.minor = MISC_DYNAMIC_MINOR,
 			.groups = plat_ifs_groups,
 		},
+		.rw_data = {
+			.result_ptr = &ifs_scan_n,
+		},
 	},
 	[IFS_TYPE_ARRAY_BIST] = {
 		.test_caps = &array_test,
@@ -86,7 +91,7 @@ static int __init ifs_init(void)
 {
 	const struct x86_cpu_id *m;
 	u64 msrval;
-	int i, ret;
+	int i, ret, cpu;
 
 	m = x86_match_cpu(ifs_cpu_ids);
 	if (!m)
@@ -105,6 +110,16 @@ static int __init ifs_init(void)
 	if (!ifs_pkg_auth)
 		return -ENOMEM;
 
+	/*
+	 * Clear the per-CPU results before misc_register() below makes
+	 * run_test visible to user space, so no test can be running yet.
+	 */
+	for_each_possible_cpu(cpu) {
+		struct ifs_test_output *out = per_cpu_ptr(&ifs_scan_n, cpu);
+
+		memset(out, 0, sizeof(*out));
+	}
+
 	for (i = 0; i < IFS_NUMTESTS; i++) {
 		if (!(msrval & BIT(ifs_devices[i].test_caps->integrity_cap_bit)))
 			continue;
drivers/platform/x86/intel/ifs/ifs.h +12 -0
index 62db0a6aa940..acf8d8a7b105 100644
@@ -130,6 +130,7 @@
  */
 #include <linux/device.h>
 #include <linux/miscdevice.h>
+#include <linux/percpu-defs.h>
 
 #define MSR_ARRAY_BIST				0x00000105
 #define MSR_COPY_SCAN_HASHES			0x000002c2
@@ -290,6 +291,7 @@ struct ifs_test_msrs {
  * @loaded: If a valid test binary has been loaded into the memory
  * @loading_error: Error occurred on another CPU while loading image
  * @valid_chunks: number of chunks which could be validated.
+ * @cpu: The CPU on which the test was triggered
  * @status: it holds simple status pass/fail/untested
  * @scan_details: opaque scan status code from h/w
  * @cur_batch: number indicating the currently loaded test file
@@ -298,6 +300,7 @@ struct ifs_test_msrs {
  * @array_gen: test generation of array test
  * @all_lp_join: all logical processors join test
  * @tid_bit_shift: APIC-ID bits of the logical processors sharing a scan engine
+ * @result_ptr: points to percpu result
  */
 struct ifs_data {
 	cpumask_t	grp_cpumask;
@@ -305,6 +308,7 @@ struct ifs_data {
 	bool	loaded;
 	bool	loading_error;
 	int	valid_chunks;
+	int	cpu;
 	int	status;
 	u64	scan_details;
 	u32	cur_batch;
@@ -313,6 +317,7 @@ struct ifs_data {
 	u32	array_gen;
 	bool	all_lp_join;
 	u8	tid_bit_shift;
+	struct ifs_test_output __percpu *result_ptr;
 };
 
 struct ifs_work {
@@ -327,6 +332,13 @@ struct ifs_device {
 	struct miscdevice misc;
 };
 
+struct ifs_test_output {
+	u64	test_details;
+	int	test_result;
+};
+
+DECLARE_PER_CPU(struct ifs_test_output, ifs_scan_n);
+
 static inline struct ifs_data *ifs_get_data(struct device *dev)
 {
 	struct miscdevice *m = dev_get_drvdata(dev);
drivers/platform/x86/intel/ifs/runtest.c +126 -48

284 lines not on this page · raw message

Signature · 1 line
2.43.0
#12 lore raw

PATCH v3 12/17 platform/x86/intel/ifs: Add new sysfs interfaces {status, details, cpus_ran}_list

In reply to Ehab Ababneh

From: Jithu Joseph <[email protected]>

Problem
=======
The current legacy interface for Intel In-Field Scan is designed to simultaneously test all CPUs in a group [1], but it only reports a single result for the whole group and doesn't indicate which CPUs have been tested. This results in the following issues:

- All CPUs in a group can hold different statuses, but when the group does not pass, the user cannot see which CPU failed or was not tested.

- The topology of a group of CPUs may vary across systems. For example, in a Hyper-Threading (HT) system, the group consists of all CPUs in a core, while in a Dual-Core Module (DCM) based system (e.g., Intel Diamond Rapids CPU), two cores in a module form a group. The user may be unaware of the group topology and test each CPU of the system individually, leading to duplicate test runs.

Solution
========
The user continues to write a single value to run_test, and while the legacy sysfs reports the result of the whole group (pass only if all CPUs in the group passed), new sysfs interfaces {status, details, cpus_ran}_list provide results for each CPU tested as part of a group. The user can check for the presence of new sysfs interfaces to understand that multiple results are available, read them, and identify which CPUs have been tested to avoid duplicate tests.

intel_ifs_0

  +---- run_test	<--- Same legacy file
  +---- current_batch
  +---- details
  +---- details_list	<--- Details for all CPUs in the group (new)
  +---- dev
  +---- image_version
  +---- status
  +---- status_list	<--- Status for all CPUs in the group (new)
  +---- cpus_ran_list	<--- CPUs in the group tested along with CPU written to run_test (new)

\---- uevent

Example of reading the cpus_ran_list to see the CPUs tested:

echo 0 > run_test
cat cpus_ran_list
0,96

cat status_list
pass pass

cat details_list
0x8086 0x8087

[1] Indicated by bits [20:16] of MSR_INTEGRITY_CAPABILITIES when bit 21 is set. E.g., in Hyper-Threading (HT) systems, a group includes all threads in a core; in Dual-Core Module (DCM) system, a group includes all CPU cores in a module.

---
 drivers/platform/x86/intel/ifs/sysfs.c | 58 ++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
drivers/platform/x86/intel/ifs/sysfs.c +58 -0
index 287f96bb033e..46a74826606d 100644
@@ -135,6 +135,61 @@ static ssize_t image_version_show(struct device *dev,
 
 static DEVICE_ATTR_RO(image_version);
 
+static ssize_t status_list_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct ifs_data *ifsd = ifs_get_data(dev);
+	struct ifs_test_output *pcpu_state;
+	int lcpu, len = 0;
+
+	for_each_cpu(lcpu, &ifsd->grp_cpumask) {
+		pcpu_state = per_cpu_ptr(ifsd->result_ptr, lcpu);
+		len += sysfs_emit_at(buf, len, "%s%s", (len > 0) ? " " : "",
+				     status_msg[pcpu_state->test_result]);
+	}
+
+	if (!len)
+		return sysfs_emit(buf, "%s\n", "none");
+
+	len += sysfs_emit_at(buf, len, "\n");
+
+	return len;
+}
+
+static DEVICE_ATTR_RO(status_list);
+
+static ssize_t details_list_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct ifs_data *ifsd = ifs_get_data(dev);
+	struct ifs_test_output *pcpu_state;
+	int lcpu, len = 0;
+
+	for_each_cpu(lcpu, &ifsd->grp_cpumask) {
+		pcpu_state = per_cpu_ptr(ifsd->result_ptr, lcpu);
+		len += sysfs_emit_at(buf, len, "%s%#llx", (len > 0) ? " " : "",
+				     pcpu_state->test_details);
+	}
+
+	if (!len)
+		return sysfs_emit(buf, "%s\n", "none");
+
+	len += sysfs_emit_at(buf, len, "\n");
+
+	return len;
+}
+
+static DEVICE_ATTR_RO(details_list);
+
+static ssize_t cpus_ran_list_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct ifs_data *ifsd = ifs_get_data(dev);
+
+	if (cpumask_empty(&ifsd->grp_cpumask))
+		return sysfs_emit(buf, "%s\n", "none");
+
+	return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(&ifsd->grp_cpumask));
+}
+
+static DEVICE_ATTR_RO(cpus_ran_list);
 /* global scan sysfs attributes */
 struct attribute *plat_ifs_attrs[] = {
 	&dev_attr_details.attr,
@@ -142,6 +197,9 @@ struct attribute *plat_ifs_attrs[] = {
 	&dev_attr_run_test.attr,
 	&dev_attr_current_batch.attr,
 	&dev_attr_image_version.attr,
+	&dev_attr_status_list.attr,
+	&dev_attr_details_list.attr,
+	&dev_attr_cpus_ran_list.attr,
 	NULL
 };
 
Signature · 1 line
2.43.0
#13 lore raw

PATCH v3 13/17 platform/x86/intel/ifs: Add additional details sysfs interface

In reply to Ehab Ababneh

From: Jithu Joseph <[email protected]>

The MSR_LAST_SAF_WP register provides information about the core when the last WRMSR(ACTIVATE_SCAN) was executed. It is available only if enumerated in bits [10:9] of MSR_INTEGRITY_CAPABILITIES.

Add a new sysfs interface, addnl_details_list, to the user space to provide additional details about the last In-Field Scan testing.

---
 drivers/platform/x86/intel/ifs/ifs.h     |  2 ++
 drivers/platform/x86/intel/ifs/runtest.c |  4 ++++
 drivers/platform/x86/intel/ifs/sysfs.c   | 24 ++++++++++++++++++++++++
 3 files changed, 30 insertions(+)
drivers/platform/x86/intel/ifs/ifs.h +2 -0
index acf8d8a7b105..10eea2c6b871 100644
@@ -139,6 +139,7 @@
 #define MSR_CHUNKS_AUTHENTICATION_STATUS	0x000002c5
 #define MSR_ACTIVATE_SCAN			0x000002c6
 #define MSR_SCAN_STATUS				0x000002c7
+#define MSR_LAST_SAF_WP				0x000002c9
 #define MSR_ARRAY_TRIGGER			0x000002d6
 #define MSR_ARRAY_STATUS			0x000002d7
 #define MSR_SAF_CTRL				0x000004f0
@@ -334,6 +335,7 @@ struct ifs_device {
 
 struct ifs_test_output {
 	u64	test_details;
+	u64	addnl_details;
 	int	test_result;
 };
 
drivers/platform/x86/intel/ifs/runtest.c +4 -0
index 9022ec55d0a1..041d281b0103 100644
@@ -190,6 +190,7 @@ static int doscan(void *data)
 	struct run_params *params = data;
 	union ifs_status status;
 	struct ifs_data *ifsd;
+	u64 saf_wp = 0;
 	int start, stop;
 
 	ifsd = params->ifsd;
@@ -216,9 +217,12 @@ static int doscan(void *data)
 	wrmsrq(MSR_ACTIVATE_SCAN, params->activate->data);
 	rdmsrq(MSR_SCAN_STATUS, status.data);
 
+	if (ifsd->generation)
+		rdmsrq(MSR_LAST_SAF_WP, saf_wp);
 	trace_ifs_status(ifsd->cur_batch, start, stop, status.data);
 
 	pcpu_scan->test_details = status.data;
+	pcpu_scan->addnl_details = saf_wp;
 
 	return 0;
 }
drivers/platform/x86/intel/ifs/sysfs.c +24 -0
index 46a74826606d..917de0efdeef 100644
@@ -190,6 +190,29 @@ static ssize_t cpus_ran_list_show(struct device *dev, struct device_attribute *a
 }
 
 static DEVICE_ATTR_RO(cpus_ran_list);
+
+static ssize_t addnl_details_list_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct ifs_data *ifsd = ifs_get_data(dev);
+	struct ifs_test_output *pcpu_state;
+	int lcpu, len = 0;
+
+	for_each_cpu(lcpu, &ifsd->grp_cpumask) {
+		pcpu_state = per_cpu_ptr(ifsd->result_ptr, lcpu);
+		len += sysfs_emit_at(buf, len, "%s%#llx", (len > 0) ? " " : "",
+				     pcpu_state->addnl_details);
+	}
+
+	if (!len)
+		return sysfs_emit(buf, "%s\n", "none");
+
+	len += sysfs_emit_at(buf, len, "\n");
+
+	return len;
+}
+
+static DEVICE_ATTR_RO(addnl_details_list);
+
 /* global scan sysfs attributes */
 struct attribute *plat_ifs_attrs[] = {
 	&dev_attr_details.attr,
@@ -200,6 +223,7 @@ struct attribute *plat_ifs_attrs[] = {
 	&dev_attr_status_list.attr,
 	&dev_attr_details_list.attr,
 	&dev_attr_cpus_ran_list.attr,
+	&dev_attr_addnl_details_list.attr,
 	NULL
 };
 
Signature · 1 line
2.43.0
#14 lore raw

PATCH v3 14/17 platform/x86/intel/ifs: Add Intel Diamond Rapids server support

In reply to Ehab Ababneh

From: Jithu Joseph <[email protected]>

Intel Diamond Rapids CPU is a Dual-Core Module (DCM) based system where two cores in a module form a group that must simultaneously run the In-Field Scan (IFS) testing. The intel_ifs driver already supports IFS for this type of DCM-based system. Add the Diamond Rapids CPU model ID for IFS support.

---
 drivers/platform/x86/intel/ifs/core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/x86/intel/ifs/core.c +1 -0
index 25b7c0f6427e..85b5323cdd2e 100644
@@ -22,6 +22,7 @@ static const struct x86_cpu_id ifs_cpu_ids[] __initconst = {
 	X86_MATCH(INTEL_GRANITERAPIDS_D, ARRAY_GEN0),
 	X86_MATCH(INTEL_ATOM_CRESTMONT_X, ARRAY_GEN1),
 	X86_MATCH(INTEL_ATOM_DARKMONT_X, ARRAY_GEN1),
+	X86_MATCH(INTEL_DIAMONDRAPIDS_X, ARRAY_GEN0),
 	{}
 };
 MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids);
Signature · 1 line
2.43.0
#15 lore raw

PATCH v3 15/17 platform/x86/intel/ifs: Remove limit on number of batch files

In reply to Ehab Ababneh

From: Tony Luck <[email protected]>

Writing to the current_batch sysfs file rejects batch numbers above 0xff. That limit was expected to be enough, but Diamond Rapids needs more than 256 IFS test image (batch) files.

Remove the limit check on the batch number supplied by the user.

---
 Documentation/ABI/testing/sysfs-platform-intel-ifs | 10 +++++++---
 drivers/platform/x86/intel/ifs/sysfs.c             |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)
Documentation/ABI/testing/sysfs-platform-intel-ifs +7 -3
index 11cd2f412d81..2b922c2cd821 100644
@@ -46,9 +46,13 @@ What:		/sys/devices/virtual/misc/intel_ifs_<N>/current_batch
 Date:		Nov 16 2022
 KernelVersion:	6.2
 Contact:	"Jithu Joseph" <[email protected]>
-Description:	Write a number less than or equal to 0xff to load an IFS test image.
-		The number written treated as the 2 digit suffix in the following file name:
-		/lib/firmware/intel/ifs_<N>/ff-mm-ss-02x.scan
+Description:	Write a number to load an IFS test image.
+		The number written is used as the <batch> suffix in the
+		following file name:
+		/lib/firmware/intel/ifs_<N>/ff-mm-ss-<batch>.scan
+		where ff, mm and ss are the CPU family, model and stepping,
+		and <batch> is the number written, in lowercase hex,
+		zero-padded to at least 2 digits (e.g. 02, ff, 100).
 		Reading the file will provide the suffix of the currently loaded IFS test image.
 		This file is present only for device instances where a test image is applicable.
 Devices:	intel_ifs_0
drivers/platform/x86/intel/ifs/sysfs.c +1 -1
index 917de0efdeef..5dffe584d6f7 100644
@@ -91,7 +91,7 @@ static ssize_t current_batch_store(struct device *dev,
 	int rc;
 
 	rc = kstrtouint(buf, 0, &cur_batch);
-	if (rc < 0 || cur_batch > 0xff)
+	if (rc < 0)
 		return -EINVAL;
 
 	if (down_interruptible(&ifs_sem))
Signature · 1 line
2.43.0
#16 lore raw

PATCH v3 16/17 platform/x86/intel/ifs: Update IFS documentation

In reply to Ehab Ababneh

From: Qiuxu Zhuo <[email protected]>

Update the simultaneous IFS testing domain in the IFS documentation from a core to a group that shares the same SCAN engine, which works for both the traditional Hyper-Threading (HT) systems and the Dual-Core Module (DCM) based systems (e.g., Diamond Rapids).

Add documentation for the new sysfs interfaces {status, details, addnl_details, cpus_ran}_list.

---
 drivers/platform/x86/intel/ifs/ifs.h | 73 +++++++++++++++++++---------
 1 file changed, 51 insertions(+), 22 deletions(-)
drivers/platform/x86/intel/ifs/ifs.h +51 -22
index 10eea2c6b871..f735f9c6bcf0 100644
@@ -14,11 +14,11 @@
  * Introduction
  * ------------
  *
- * In Field Scan (IFS) is a hardware feature to run circuit level tests on
- * a CPU core to detect problems that are not caught by parity or ECC checks.
- * Future CPUs will support more than one type of test which will show up
- * with a new platform-device instance-id.
- *
+ * In-Field Scan (IFS) is a hardware feature that runs circuit-level tests on
+ * all CPUs in a group, where all CPUs share the same SCAN test engine to
+ * detect problems that are not caught by parity or ECC checks. Future CPUs
+ * will support more than one type of test, which will show up with a new
+ * platform-device instance-id.
  *
  * IFS Image
  * ---------
@@ -59,19 +59,19 @@
  * Running tests
  * -------------
  *
- * Tests are run by the driver synchronizing execution of all threads on a
- * core and then writing to the ACTIVATE_SCAN MSR on all threads. Instruction
- * execution continues when:
+ * Tests are run by the driver synchronizing execution of all CPUs in a group
+ * that share the same SCAN test engine, then writing to the ACTIVATE_SCAN MSR
+ * on all CPUs. Instruction execution continues when:
  *
  * 1) All tests have completed.
  * 2) Execution was interrupted.
  * 3) A test detected a problem.
  *
- * Note that ALL THREADS ON THE CORE ARE EFFECTIVELY OFFLINE FOR THE
+ * Note that ALL CPUs IN THE GROUP ARE EFFECTIVELY OFFLINE FOR THE
  * DURATION OF THE TEST. This can be up to 200 milliseconds. If the system
- * is running latency sensitive applications that cannot tolerate an
+ * is running latency-sensitive applications that cannot tolerate an
  * interruption of this magnitude, the system administrator must arrange
- * to migrate those applications to other cores before running a core test.
+ * to migrate those applications to other CPUs before running a group test.
  * It may also be necessary to redirect interrupts to other CPUs.
  *
  * In all cases reading the corresponding test's STATUS MSR provides details on what
@@ -81,30 +81,59 @@
  * The IFS driver provides sysfs interfaces via /sys/devices/virtual/misc/intel_ifs_<n>/
  * to control execution:
  *
- * Test a specific core::
+ * Test a specific group::
  *
  *   # echo <CPU#> > /sys/devices/virtual/misc/intel_ifs_<n>/run_test
  *
- * when HT is enabled any of the sibling CPU# can be specified to test
- * its corresponding physical core. Since the tests are per physical core,
- * the result of testing any thread is same. All siblings must be online
- * to run a core test. It is only necessary to test one thread.
+ * Any CPU in the same group that shares the same SCAN test engine can be
+ * specified to test its corresponding group. Offline CPUs in the group do
+ * not take part in the test; if the test then does not pass, the driver
+ * warns. It is only necessary to test one CPU in the group.
  *
- * For e.g. to test core corresponding to CPU5
+ * For e.g. to test a group corresponding to CPU5
  *
  *   # echo 5 > /sys/devices/virtual/misc/intel_ifs_<n>/run_test
  *
- * Results of the last test is provided in /sys::
+ * The result of the last test for the whole group is provided in /sys::
  *
  *   $ cat /sys/devices/virtual/misc/intel_ifs_<n>/status
  *   pass
  *
- * Status can be one of pass, fail, untested
+ * Status can be one of pass, fail, untested. It is pass only if all CPUs in
+ * the group passed. Otherwise it is fail if any CPU failed, or untested if
+ * any CPU was not fully tested. The per-CPU files below show which CPU did
+ * not pass.
  *
- * Additional details of the last test is provided by the details file::
+ * Additional details of the last test are provided in /sys. If the group
+ * did not pass, they are for the first CPU with the reported status::
  *
  *   $ cat /sys/devices/virtual/misc/intel_ifs_<n>/details
- *   0x8081
+ *   0x7f0080
+ *
+ * For intel_ifs_0, there are following additional sysfs files:
+ *
+ * All CPUs in the same group that ran the test are provided in /sys::
+ *
+ *   $ cat /sys/devices/virtual/misc/intel_ifs_0/cpus_ran_list
+ *   5,149
+ *
+ * The results of the last test for all CPUs in the same group are provided
+ * in /sys::
+ *
+ *   $ cat /sys/devices/virtual/misc/intel_ifs_0/status_list
+ *   pass pass
+ *
+ * Additional details of the last test for all CPUs in the same group are
+ * provided in /sys::
+ *
+ *   $ cat /sys/devices/virtual/misc/intel_ifs_0/details_list
+ *   0x7f0080 0x7f0080
+ *
+ * More additional details of the last test for all CPUs in the same group
+ * are provided in /sys::
+ *
+ *   $ cat /sys/devices/virtual/misc/intel_ifs_0/addnl_details_list
+ *   0xc44191a 0xc44191a
  *
  * The details file reports the hex value of the test specific status MSR.
  * Hardware defined error codes are documented in volume 4 of the Intel
@@ -125,7 +154,7 @@
  * uses the subrange feature to restart an interrupted test.
  *
  * 2) Hardware allows for some number of cores to be tested in parallel.
- * The driver does not make use of this, it only tests one core at a time.
+ * The driver does not make use of this, it only tests one group at a time.
  *
  */
 #include <linux/device.h>
Signature · 1 line
2.43.0
#17 lore raw

PATCH v3 17/17 Documentation/ABI: Update IFS ABI doc

In reply to Ehab Ababneh

From: Qiuxu Zhuo <[email protected]>

Add documentation for the new sysfs interfaces {status, details, additional_details, cpus_ran}_list.

---
 .../ABI/testing/sysfs-platform-intel-ifs      | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
Documentation/ABI/testing/sysfs-platform-intel-ifs +34 -0
index 2b922c2cd821..519ad83a89f9 100644
@@ -22,6 +22,10 @@ KernelVersion:	6.2
 Contact:	"Jithu Joseph" <[email protected]>
 Description:	The status of the last test. It can be one of "pass", "fail"
 		or "untested".
+		When the test ran on a group of CPUs (see cpus_ran_list), it
+		is "pass" only if all of them passed. Otherwise it is "fail"
+		if any CPU failed, or "untested" if any CPU was not fully
+		tested. status_list shows the result of each CPU.
 Devices:	all
 
 What:		/sys/devices/virtual/misc/intel_ifs_<N>/details
@@ -31,6 +35,8 @@ Contact:	"Jithu Joseph" <[email protected]>
 Description:	Additional information regarding the last test. The details file reports
 		the hex value of the STATUS MSR for this test. Note that the error_code field
 		may contain driver defined software code not defined in the Intel SDM.
+		When a group test did not pass, the details are for the first
+		CPU with the reported status (see details_list).
 Devices:	all
 
 What:		/sys/devices/virtual/misc/intel_ifs_<N>/image_version
@@ -56,3 +62,31 @@ Description:	Write a number to load an IFS test image.
 		Reading the file will provide the suffix of the currently loaded IFS test image.
 		This file is present only for device instances where a test image is applicable.
 Devices:	intel_ifs_0
+
+What:		/sys/devices/virtual/misc/intel_ifs_<N>/cpus_ran_list
+Date:		Mar 3 2025
+Contact:	"Qiuxu Zhuo" <[email protected]>
+Description:	The CPU list of the last test. These CPUs share the same SCAN
+		test engine.
+Devices:	intel_ifs_0
+
+What:		/sys/devices/virtual/misc/intel_ifs_<N>/status_list
+Date:		Mar 3 2025
+Contact:	"Qiuxu Zhuo" <[email protected]>
+Description:	The status list of the last test for CPUs sharing the same
+		SCAN test engine.
+Devices:	intel_ifs_0
+
+What:		/sys/devices/virtual/misc/intel_ifs_<N>/details_list
+Date:		Mar 3 2025
+Contact:	"Qiuxu Zhuo" <[email protected]>
+Description:	The detail status list of the last test for CPUs sharing the
+		same SCAN test engine.
+Devices:	intel_ifs_0
+
+What:		/sys/devices/virtual/misc/intel_ifs_<N>/addnl_details_list
+Date:		Mar 3 2025
+Contact:	"Qiuxu Zhuo" <[email protected]>
+Description:	The additional detail status list of the last test for CPUs
+		sharing the same SCAN test engine.
+Devices:	intel_ifs_0
Signature · 1 line
2.43.0