platform/x86/intel/ifs: Support group-based In-Field Scan and Diamond Rapids
Subsystems (4)
v2 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, but now report the result of the CPU written to run_test rather than the first CPU in the group.
- 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). Where Qiuxu changed a patch written by someone else, the change is noted in brackets in the commit message, and I have added my Signed-off-by to every patch.
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 | 33 +- arch/x86/include/asm/msr-index.h | 17 +- drivers/platform/x86/intel/ifs/core.c | 59 ++- drivers/platform/x86/intel/ifs/ifs.h | 229 ++++----- drivers/platform/x86/intel/ifs/load.c | 52 +- drivers/platform/x86/intel/ifs/runtest.c | 450 ++++++++---------- drivers/platform/x86/intel/ifs/sysfs.c | 109 ++++- 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, 531 insertions(+), 509 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.43.0
PATCH v2 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 2/17 platform/x86/intel/ifs: Fix IFS sysfs interfaces in the comments
In reply to Ehab AbabnehFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 3/17 platform/x86/intel/ifs: Clarify In-Field Scan MSR bit macro definitions
In reply to Ehab AbabnehFrom: 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
@@ -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
@@ -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
@@ -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
PATCH v2 4/17 platform/x86/intel/ifs: Use u64 to define the bits of IFS MSR registers
In reply to Ehab AbabnehFrom: 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
@@ -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
PATCH v2 5/17 platform/x86/intel/ifs: Early return on the IFS image hash/chunk error
In reply to Ehab AbabnehFrom: 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
@@ -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
PATCH v2 6/17 platform/x86/intel/ifs: Refactor Array BIST function interface
In reply to Ehab AbabnehFrom: 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
@@ -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, ¶ms);if (command.ctrl_result)break ;
Signature · 1 line
2.43.0
PATCH v2 7/17 stop_machine: Add stop_cluster_cpuslocked() for per-cluster operations
In reply to Ehab AbabnehFrom: Qiuxu Zhuo <[email protected]>
There is already stop_core_cpuslocked() for hardware core-level testing features, which requires near-simultaneous execution of the WRMSR instruction on all threads of a core to initiate a test. However, some hardware requires this simultaneous execution of WRMSR at the cluster level.
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
@@ -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
@@ -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
Ilpo Järvinen
maintainerRe: [PATCH v2 07/17] stop_machine: Add stop_cluster_cpuslocked() for per-cluster operations
Quoted 3 lines · Ehab Ababneh
From: Qiuxu Zhuo <[email protected]>
There is already
stop_core_cpuslocked()for hardware core-level testing
Please rewrite this paragraph, as is it starts at middle of nowhere so it won't connect to anything.
Do not depend on shortlog in the changelog body, the body should be 100% readable on its own.
Quoted 4 lines
features, which requires near-simultaneous execution of the WRMSR instruction on all threads of a core to initiate a test. However, some hardware requires this simultaneous execution of WRMSR at the cluster level.
Something along the lines of:
stop_core_cpuslocked() is limited in performing simultaneous execution of WRMSR on all threads of a core. However, ...
That will immediately tell the reader there's a limitation and why the limitation has to be removed.
I'm not sure if "for hardware core-level testing features" is that necessary at all (perhaps that's from LLM that wanted to describe unnecessary details like it usually does).
"some hardware" is vague, please be precise.
Quoted 18 lines
Add
stop_cluster_cpuslocked(), a customized version ofstop_machine_cpuslocked()for operating solely on the threads of a single cluster.Suggested-by Tony Luck <[email protected]>Signed-off-by Qiuxu Zhuo <[email protected]>Signed-off-by Ehab Ababneh <[email protected]>Tested-by Yi Lai <[email protected]>--- include/linux/stop_machine.h | 15 +++++++++++++++ kernel/stop_machine.c | 35 ++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 13 deletions(-)include/linux/stop_machine.h +0
-0
include/linux/stop_machine.h int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, const struct cpumask * · line 161
Quoted 5 lines
include/linux/stop_machine.h +2
-0@@ -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
Extra :
Quoted 76 lines
include/linux/stop_machine.h +13
-0+* @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@@ -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
i.
PATCH v2 8/17 platform/x86/intel/ifs: Enumerate the bit to determine if CPUs need to join for IFS tests
In reply to Ehab AbabnehFrom: 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.
[ Qiuxu: Elaborate commit message. ]
--- 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
@@ -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
@@ -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
@@ -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
PATCH v2 9/17 platform/x86/intel/ifs: Select CPUs from topology_cluster_cpumask() for simultaneous IFS tests
In reply to Ehab AbabnehFrom: 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], the Linux community is not in favor of a stop_machine() variant with an arbitrary cpumask.
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.
[ Qiuxu: Re-wrote the commit message. ]
[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.
[2] https://lore.kernel.org/all/[email protected]/
--- drivers/platform/x86/intel/ifs/ifs.h | 2 + drivers/platform/x86/intel/ifs/runtest.c | 54 ++++++++++++++++++------ 2 files changed, 44 insertions(+), 12 deletions(-)
drivers/platform/x86/intel/ifs/ifs.h +2 -0
@@ -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 +42 -12
109 lines not on this page · raw message
Signature · 1 line
2.43.0
Ilpo Järvinen
maintainerRe: [PATCH v2 09/17] platform/x86/intel/ifs: Select CPUs from topology_cluster_cpumask() for simultaneous IFS tests
Quoted 9 lines · Ehab Ababneh
From: Jithu Joseph <[email protected]>
The current
intel_ifsdriver selects CPUs fromcpu_smt_mask()to run IFS test simultaneously. This approach works well for processors currently supported by theintel_ifsdriver, 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.
Quoted 10 lines
Starting with Granite Rapids (GNR) and later generations, bit[20:16] (
TID_BIT_SHIFT) ofMSR_INTEGRITY_CAPABILITIESregister [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 astop_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], the Linux community is not in favor of astop_machine()variant with an arbitrary cpumask.
I suggest using passive voice for what comes after ,
Quoted 11 lines
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 fromtopology_cluster_cpumask()to run IFS tests if simultaneous testing is required.[ Qiuxu: Re-wrote the commit message. ]
There's no Signed-off from Qiuxu ?
Quoted 5 lines
[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.
Move to Link: and add [2] to end.
Quoted 95 lines
Suggested-by Tony Luck <[email protected]>Signed-off-by Jithu Joseph <[email protected]>Signed-off-by Ehab Ababneh <[email protected]>Tested-by Yi Lai <[email protected]>--- drivers/platform/x86/intel/ifs/ifs.h | 2 + drivers/platform/x86/intel/ifs/runtest.c | 54 ++++++++++++++++++------ 2 files changed, 44 insertions(+), 12 deletions(-)drivers/platform/x86/intel/ifs/ifs.h +2
-0@@ -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 +14
-9@@ -156,11 +156,9 @@ static atomic_t scan_cpus_in;/* * Simplified CPU sibling rendezvous loop based on microcode loader wait_for_cpus() */ -static void wait_for_sibling_cpu (atomic_t *t,long long timeout) +static void wait_for_sibling_cpu (struct ifs_data *ifsd,atomic_t *t,long long timeout) { -int cpu =smp_processor_id (); -const struct cpumask *smt_mask =cpu_smt_mask (cpu); -int all_cpus =cpumask_weight (smt_mask); +int all_cpus =cpumask_weight (&ifsd->grp_cpumask);atomic_inc (t);while (atomic_read (t) < all_cpus) {@@ -195,9 +193,9 @@ static int doscan(void *data) }/* Only the first logical CPU on a core reports result */ - first =cpumask_first (cpu_smt_mask (cpu)); + first =cpumask_first (&ifsd->grp_cpumask); -wait_for_sibling_cpu (&scan_cpus_in,NSEC_PER_SEC ); +wait_for_sibling_cpu (ifsd, &scan_cpus_in,NSEC_PER_SEC );/* * This WRMSR will wait for other HT threads to also write @@ -265,7 +263,11 @@ static void ifs_test_core(int cpu, struct device *dev) params.activate = &activate;atomic_set (&scan_cpus_in,0 ); -stop_core_cpuslocked (cpu, doscan, ¶ms); + +if (ifsd->all_lp_join) +stop_cluster_cpuslocked (cpu, doscan, ¶ms); +else +stop_core_cpuslocked (cpu, doscan, ¶ms); status = params.status;@@ -310,15 +312,18 @@ static int do_array_test(void *data)struct run_array_params *params = data;int cpu =smp_processor_id ();union ifs_array *command; +struct ifs_data *ifsd;int first; + ifsd = params->ifsd; + command = params->command; -wait_for_sibling_cpu (&array_cpus_in,NSEC_PER_SEC ); +wait_for_sibling_cpu (ifsd, &array_cpus_in,NSEC_PER_SEC );/* * Only one logical CPU on a core needs to trigger the Array test via MSR write. */ - first =cpumask_first (cpu_smt_mask (cpu)); + first =cpumask_first (&ifsd->grp_cpumask);if (cpu == first) {wrmsrq (MSR_ARRAY_BIST , command->data);
drivers/platform/x86/intel/ifs/runtest.c static void ifs_array_test_core(int cpu, struct device *dev) · line 362
Quoted 9 lines
drivers/platform/x86/intel/ifs/runtest.c +5
-1@@ -350,7 +355,11 @@ static void ifs_array_test_core(int cpu, struct device *dev) }atomic_set (&array_cpus_in,0 ); params.command = &command; -stop_core_cpuslocked (cpu, do_array_test, ¶ms); + +if (ifsd->all_lp_join) +stop_cluster_cpuslocked (cpu, do_array_test, ¶ms); +else +stop_core_cpuslocked (cpu, do_array_test, ¶ms);
Add a helper for this or should it just be a pointer (or add ops)?
Quoted 37 lines
drivers/platform/x86/intel/ifs/runtest.c +19
-2if (command.ctrl_result)break ;@@ -398,6 +407,24 @@ static void ifs_array_test_gen1(int cpu, struct device *dev) ifsd->status =SCAN_TEST_PASS ; } +static void build_cpugroup_mask (struct device *dev,int cpu) +{ +struct ifs_data *ifsd =ifs_get_data (dev); + +cpumask_clear (&ifsd->grp_cpumask); + +/* +* Some CPUs, such as Sierra Forest and Clearwater Forest, have multiple cores +* sharing the same SCAN test engine, but they don't require a rendezvous. +*/ +if (!ifsd->all_lp_join) { +cpumask_set_cpu (cpu, &ifsd->grp_cpumask); +return ; + } + +cpumask_copy (&ifsd->grp_cpumask,topology_cluster_cpumask (cpu)); +} +/* * 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 @@ -420,12 +447,15 @@ int do_core_test(int cpu, struct device *dev)switch (test->test_num) {case IFS_TYPE_SAF : -if (!ifsd->loaded) +if (!ifsd->loaded) { ret = -EPERM ; -else
drivers/platform/x86/intel/ifs/runtest.c int do_core_test(int cpu, struct device *dev) · line 461
Quoted 10 lines
drivers/platform/x86/intel/ifs/runtest.c +4
-0+ }else { +build_cpugroup_mask (dev, cpu);ifs_test_core (cpu, dev); + }break ;case IFS_TYPE_ARRAY_BIST : +build_cpugroup_mask (dev, cpu);if (ifsd->array_gen ==ARRAY_GEN0 )ifs_array_test_core (cpu, dev);else
Unrelated to this patch, this function would be better of with using guard() + simplied code flow it allows.
Signature · 1 line
i.
PATCH v2 10/17 platform/x86/intel/ifs: Warn if a group test fails with CPUs missing
In reply to Ehab AbabnehAll 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 | 30 ++++++++++++++++++++++++ 4 files changed, 39 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
@@ -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
@@ -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
@@ -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 +30 -0
@@ -425,6 +425,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) !=1U << 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
@@ -464,6 +490,10 @@ 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
Ilpo Järvinen
maintainerRe: [PATCH v2 10/17] platform/x86/intel/ifs: Warn if a group test fails with CPUs missing
Quoted 98 lines · 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 fromtopology_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_SHIFTat init and, when a test does not pass, check whether all logical processors in the CPU'sTID_BIT_SHIFTAPIC ID range were in the group. If not, say so in the log. The test is run either way.
TID_BIT_SHIFTis 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.
Suggested-by Tony Luck <[email protected]>Co-developed-by Qiuxu Zhuo <[email protected]>Signed-off-by Qiuxu Zhuo <[email protected]>Signed-off-by Ehab Ababneh <[email protected]>Tested-by Yi Lai <[email protected]>--- 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 | 30 ++++++++++++++++++++++++ 4 files changed, 39 insertions(+)arch/x86/include/asm/msr-index.h +1
-0@@ -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@@ -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@@ -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 +6
-0@@ -425,6 +425,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. +*/
drivers/platform/x86/intel/ifs/runtest.c static void build_cpugroup_mask(struct device *dev, int cpu) · line 443
Quoted 10 lines
drivers/platform/x86/intel/ifs/runtest.c +10
-0+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) !=1U << shift)
BIT()
Quoted 14 lines
drivers/platform/x86/intel/ifs/runtest.c +10
-0+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
drivers/platform/x86/intel/ifs/runtest.c int do_core_test(int cpu, struct device *dev) · line 496
Quoted 7 lines
drivers/platform/x86/intel/ifs/runtest.c +4
-0@@ -464,6 +490,10 @@ 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));
Add include.
Add braces to multiline constructs even if they're single statement.
Quoted 4 lines
drivers/platform/x86/intel/ifs/runtest.c +0
-0out:cpus_read_unlock ();return ret;
Signature · 1 line
i.
PATCH v2 11/17 platform/x86/intel/ifs: Track and report scan results on a per-CPU basis
In reply to Ehab AbabnehFrom: 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 driver marks a test as timed out or partially completed, keep any error code a CPU's hardware reported. When warning about an incomplete group, look at the results of all CPUs in the group, not only the CPU being tested.
--- drivers/platform/x86/intel/ifs/core.c | 14 +- drivers/platform/x86/intel/ifs/ifs.h | 12 ++ drivers/platform/x86/intel/ifs/runtest.c | 171 ++++++++++++++++++----- 3 files changed, 161 insertions(+), 36 deletions(-)
drivers/platform/x86/intel/ifs/core.c +13 -1
@@ -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,13 @@ 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) +memset (per_cpu_ptr (&ifs_scan_n, cpu),0 ,sizeof (struct ifs_test_output )); +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
@@ -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 +136 -35
283 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 11/17] platform/x86/intel/ifs: Track and report scan results on a per-CPU basis
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] platform/x86/intel/ifs: stale ifsd->scan_details in ifs_test_core() - [Medium]…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] platform/x86/intel/ifs: stale ifsd->scan_details in ifs_test_core()
- [Medium] platform/x86/intel/ifs: update_group_status() clobbers passing CPUs
--
commit 3bcc71cc2c29c09c3eadc3e6e70f27cf28c60879
Author: Jithu Joseph <[email protected]>
platform/x86/intel/ifs: Track and report scan results on a per-CPU basis
This commit records In-Field Scan test results in a per-CPU structure for all CPUs in the tested group, restarting from the lowest chunk reached across the group and evaluating results across all CPUs sharing the scan engine.
Quoted 4 lines
drivers/platform/x86/intel/ifs/runtest.c +0
-0
[ ... ]
Quoted 20 lines
drivers/platform/x86/intel/ifs/runtest.c +10
-1@@ -211,12 +205,103 @@ static int doscan(void *data)trace_ifs_status (ifsd->cur_batch, start, stop, status.data);/* Pass back the result of the scan */ -if (cpu == first) +if (cpu == ifsd->cpu) params->status = status; + pcpu_scan->test_details = status.data; +return 0 ; } +#define get_scan_status (stat) ((union ifs_status *)(&((stat)->test_details))) + +static void update_group_status (struct device *dev,int reason) +{ +struct ifs_data *ifsd =ifs_get_data (dev); +struct ifs_test_output *pcpu_scan; +union ifs_status *scan_status;
drivers/platform/x86/intel/ifs/runtest.c static int doscan(void *data) · line 232
Quoted 10 lines
drivers/platform/x86/intel/ifs/runtest.c +10
-0+int lcpu; + +for_each_cpu (lcpu, &ifsd->grp_cpumask) { + pcpu_scan =per_cpu_ptr (ifsd->result_ptr, lcpu); + scan_status =get_scan_status (pcpu_scan); +/* Don't hide an error code reported by the hardware */ +if (scan_status->error_code ==IFS_NO_ERROR ) + scan_status->error_code = reason; + } +}
[Severity: Medium]
Can update_group_status() overwrite scan_status->error_code on a CPU that has already completed all chunks?
When one CPU in the group finishes through to_stop (leaving chunk_num > to_stop and error_code == IFS_NO_ERROR) while another CPU stalls on an earlier chunk until the test times out or exhausts retries, update_group_status() sets error_code to reason on the completed CPU as well. update_group_result() then sees a non-zero error_code and marks that passing CPU as SCAN_NOT_TESTED.
[ ... ]
Quoted 32 lines
drivers/platform/x86/intel/ifs/runtest.c +32
-0+static void update_group_result (struct device *dev,int stop_chunk) +{ +struct ifs_data *ifsd =ifs_get_data (dev); +struct ifs_test_output *pcpu_scan; +union ifs_status *scan_status; +u32 reached_chunk; +int lcpu; + +for_each_cpu (lcpu, &ifsd->grp_cpumask) { + pcpu_scan =per_cpu_ptr (ifsd->result_ptr, lcpu); + scan_status =get_scan_status (pcpu_scan); + reached_chunk = ifsd->generation ? scan_status->gen2.chunk_num : + scan_status->gen0.chunk_num; + +if (scan_status->signature_error) { + pcpu_scan->test_result =SCAN_TEST_FAIL ; +message_fail (dev, lcpu, *scan_status); + }else if (scan_status->control_error || scan_status->error_code || + reached_chunk <= stop_chunk) { +/* E.g. another CPU in the group stopped the scan */ +if (!scan_status->control_error && !scan_status->error_code) + scan_status->error_code =IFS_SW_PARTIAL_COMPLETION ; + pcpu_scan->test_result =SCAN_NOT_TESTED ; +message_not_tested (dev, lcpu, *scan_status); + }else { + pcpu_scan->test_result =SCAN_TEST_PASS ; + } + +if (lcpu == ifsd->cpu) + ifsd->status = pcpu_scan->test_result; + } +}
[ ... ]
Quoted 33 lines
drivers/platform/x86/intel/ifs/runtest.c +4
-4@@ -258,6 +348,7 @@ static void ifs_test_core(int cpu, struct device *dev)while (to_start <= to_stop) {if (time_after (jiffies, timeout)) { status.error_code =IFS_SW_TIMEOUT ; +update_group_status (dev,IFS_SW_TIMEOUT );break ; }@@ -272,15 +363,16 @@ static void ifs_test_core(int cpu, struct device *dev) status = params.status;/* Some cases can be retried, give up for others */ -if (!can_restart (status)) +if (!can_restart_test_group (dev))break ; - status_chunk = ifsd->generation ? status.gen2.chunk_num : status.gen0.chunk_num; + status_chunk =group_min_chunk (ifsd);if (status_chunk == to_start) {/* Check for forward progress */ if (--retries ==0 ) {if (status.error_code ==IFS_NO_ERROR ) status.error_code =IFS_SW_PARTIAL_COMPLETION ; +update_group_status (dev,IFS_SW_PARTIAL_COMPLETION );break ; } }else {@@ -295,16 +387,7 @@ static void ifs_test_core(int cpu, struct device *dev)/* Update status for this core */ ifsd->scan_details = status.data; - -if (status.signature_error) {
drivers/platform/x86/intel/ifs/runtest.c static void ifs_test_core(int cpu, struct device *dev) · line 391
Quoted 10 lines
drivers/platform/x86/intel/ifs/runtest.c +1
-8- ifsd->status =SCAN_TEST_FAIL ; -message_fail (dev, cpu, status); - }else if (status.control_error || status.error_code) { - ifsd->status =SCAN_NOT_TESTED ; -message_not_tested (dev, cpu, status); - }else { - ifsd->status =SCAN_TEST_PASS ; - } +update_group_result (dev, to_stop); }
[Severity: Medium]
Can ifsd->scan_details diverge from the target CPU's per-CPU test_details?
ifs_test_core() writes status.data to ifsd->scan_details before update_group_result() runs. If another CPU in the group aborts the scan with a non-restartable error while ifsd->cpu stopped at reached_chunk <= stop_chunk with no error, update_group_result() sets IFS_SW_PARTIAL_COMPLETION in pcpu_scan->test_details and sets ifsd->status to SCAN_NOT_TESTED, leaving ifsd->scan_details (exposed via sysfs details) with error_code == 0. Also, the timeout path unconditionally sets status.error_code = IFS_SW_TIMEOUT, overwriting any retryable hardware error code from the previous iteration that update_group_status() preserved in pcpu_scan->test_details.
Assigning ifsd->scan_details = pcpu_scan->test_details when lcpu == ifsd->cpu in update_group_result() would keep both in sync.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
Ilpo Järvinen
maintainerRe: [PATCH v2 11/17] platform/x86/intel/ifs: Track and report scan results on a per-CPU basis
In reply to Ehab AbabnehQuoted 50 lines · 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 driver marks a test as timed out or partially completed, keep any error code a CPU's hardware reported. When warning about an incomplete group, look at the results of all CPUs in the group, not only the CPU being tested.
Signed-off-by Jithu Joseph <[email protected]>Signed-off-by Ehab Ababneh <[email protected]>Tested-by Yi Lai <[email protected]>--- drivers/platform/x86/intel/ifs/core.c | 14 +- drivers/platform/x86/intel/ifs/ifs.h | 12 ++ drivers/platform/x86/intel/ifs/runtest.c | 171 ++++++++++++++++++----- 3 files changed, 161 insertions(+), 36 deletions(-)drivers/platform/x86/intel/ifs/core.c +2
-0@@ -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,
drivers/platform/x86/intel/ifs/core.c static struct ifs_device ifs_devices[] = { · line 65
Quoted 6 lines
drivers/platform/x86/intel/ifs/core.c +3
-0@@ -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, + }
Add trailing command to all non-terminator entiries.
Quoted 13 lines
drivers/platform/x86/intel/ifs/core.c +1
-1}, [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)
drivers/platform/x86/intel/ifs/core.c static int __init ifs_init(void) · line 118
Quoted 9 lines
drivers/platform/x86/intel/ifs/core.c +6
-0@@ -105,6 +110,13 @@ 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) +memset (per_cpu_ptr (&ifs_scan_n, cpu),0 ,sizeof (struct ifs_test_output ));
Put the pointer into a temporary local variable and do sizeof(*that_var).
IMO, best is to declare it right within the loop.
Quoted 138 lines
drivers/platform/x86/intel/ifs/core.c +1
-0+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@@ -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 +10
-16@@ -83,25 +83,21 @@ static void message_not_tested(struct device *dev, int cpu, union ifs_status sta* been corrupted. Reloading the image may fix this issue. */ if (status.control_error) { -dev_warn (dev,"CPU(s) %*pbl: Scan controller error. Batch: %02x version: 0x%x\n" , -cpumask_pr_args (cpu_smt_mask (cpu)), ifsd->cur_batch, ifsd->loaded_version); +dev_warn (dev,"CPU %d: Scan controller error. Batch: %02x version: 0x%x\n" , cpu, + ifsd->cur_batch, ifsd->loaded_version);return ; }if (status.error_code <ARRAY_SIZE (scan_test_status)) { -dev_info (dev,"CPU(s) %*pbl: SCAN operation did not start. %s\n" , -cpumask_pr_args (cpu_smt_mask (cpu)), +dev_info (dev,"CPU %d: SCAN operation did not start. %s\n" , cpu, scan_test_status[status.error_code]); }else if (status.error_code ==IFS_SW_TIMEOUT ) { -dev_info (dev,"CPU(s) %*pbl: software timeout during scan\n" , -cpumask_pr_args (cpu_smt_mask (cpu))); +dev_info (dev,"CPU %d: software timeout during scan\n" , cpu); }else if (status.error_code ==IFS_SW_PARTIAL_COMPLETION ) { -dev_info (dev,"CPU(s) %*pbl: %s\n" , -cpumask_pr_args (cpu_smt_mask (cpu)), +dev_info (dev,"CPU %d: %s\n" , cpu,"Not all scan chunks were executed. Maximum forward progress retries exceeded" ); }else { -dev_info (dev,"CPU(s) %*pbl: SCAN unknown status %llx\n" , -cpumask_pr_args (cpu_smt_mask (cpu)), status.data); +dev_info (dev,"CPU %d: SCAN unknown status %llx\n" , cpu, status.data); } }@@ -117,8 +113,8 @@ static void message_fail(struct device *dev, int cpu, union ifs_status status)* the core being tested. */ if (status.signature_error) { -dev_err (dev,"CPU(s) %*pbl: test signature incorrect. Batch: %02x version: 0x%x\n" , -cpumask_pr_args (cpu_smt_mask (cpu)), ifsd->cur_batch, ifsd->loaded_version); +dev_err (dev,"CPU %d: test signature incorrect. Batch: %02x version: 0x%x\n" , + cpu, ifsd->cur_batch, ifsd->loaded_version); } }@@ -177,12 +173,13 @@ static void wait_for_sibling_cpu(struct ifs_data *ifsd, atomic_t *t, long long tstatic int doscan (void *data) {int cpu =smp_processor_id (), start, stop; +struct ifs_test_output *pcpu_scan;struct run_params *params = data;union ifs_status status;struct ifs_data *ifsd; -int first; ifsd = params->ifsd; + pcpu_scan =this_cpu_ptr (ifsd->result_ptr);if (ifsd->generation) { start = params->activate->gen2.start;@@ -192,9 +189,6 @@ static int doscan(void *data) stop = params->activate->gen0.stop; } -/* Only the first logical CPU on a core reports result */ - first =cpumask_first (&ifsd->grp_cpumask); -wait_for_sibling_cpu (ifsd, &scan_cpus_in,NSEC_PER_SEC );/* @@ -211,12 +205,103 @@ static int doscan(void *data)trace_ifs_status (ifsd->cur_batch, start, stop, status.data);/* Pass back the result of the scan */
drivers/platform/x86/intel/ifs/runtest.c static int doscan(void *data) · line 216
Quoted 10 lines
drivers/platform/x86/intel/ifs/runtest.c +4
-1-if (cpu == first) +if (cpu == ifsd->cpu) params->status = status; + pcpu_scan->test_details = status.data; +return 0 ; } +#define get_scan_status (stat) ((union ifs_status *)(&((stat)->test_details)))
Can't this be static function which allows getting rid of most of those parenthesis?
Quoted 36 lines
drivers/platform/x86/intel/ifs/runtest.c +36
-0+static void update_group_status (struct device *dev,int reason) +{ +struct ifs_data *ifsd =ifs_get_data (dev); +struct ifs_test_output *pcpu_scan; +union ifs_status *scan_status; +int lcpu; + +for_each_cpu (lcpu, &ifsd->grp_cpumask) { + pcpu_scan =per_cpu_ptr (ifsd->result_ptr, lcpu); + scan_status =get_scan_status (pcpu_scan); +/* Don't hide an error code reported by the hardware */ +if (scan_status->error_code ==IFS_NO_ERROR ) + scan_status->error_code = reason; + } +} + +static bool can_restart_test_group (struct device *dev) +{ +struct ifs_data *ifsd =ifs_get_data (dev); +struct ifs_test_output *pcpu_scan; +union ifs_status *scan_status; +int lcpu; + +for_each_cpu (lcpu, &ifsd->grp_cpumask) { + pcpu_scan =per_cpu_ptr (ifsd->result_ptr, lcpu); + scan_status =get_scan_status (pcpu_scan); +if (!can_restart (*scan_status)) +return false; + } +return true; +} + +/* +* The cores in a group can stop at different chunks. Return the lowest +* chunk reached so that no CPU skips chunks when the test is restarted. +*/
drivers/platform/x86/intel/ifs/runtest.c static int doscan(void *data) · line 263
Quoted 10 lines
drivers/platform/x86/intel/ifs/runtest.c +10
-0+static u32 group_min_chunk (struct ifs_data *ifsd) +{ +struct ifs_test_output *pcpu_scan; +union ifs_status *scan_status; +u32 chunk, min_chunk =U32_MAX ; +int lcpu; + +for_each_cpu (lcpu, &ifsd->grp_cpumask) { + pcpu_scan =per_cpu_ptr (ifsd->result_ptr, lcpu); + scan_status =get_scan_status (pcpu_scan);
These three lines seem to repeat, so consider adding some local for_each_... macro for these iterations.
Quoted 47 lines
drivers/platform/x86/intel/ifs/runtest.c +41
-0+ chunk = ifsd->generation ? scan_status->gen2.chunk_num : + scan_status->gen0.chunk_num; + min_chunk =min (min_chunk, chunk); + } + +return min_chunk; +} + +static void update_group_result (struct device *dev,int stop_chunk) +{ +struct ifs_data *ifsd =ifs_get_data (dev); +struct ifs_test_output *pcpu_scan; +union ifs_status *scan_status; +u32 reached_chunk; +int lcpu; + +for_each_cpu (lcpu, &ifsd->grp_cpumask) { + pcpu_scan =per_cpu_ptr (ifsd->result_ptr, lcpu); + scan_status =get_scan_status (pcpu_scan); + reached_chunk = ifsd->generation ? scan_status->gen2.chunk_num : + scan_status->gen0.chunk_num; + +if (scan_status->signature_error) { + pcpu_scan->test_result =SCAN_TEST_FAIL ; +message_fail (dev, lcpu, *scan_status); + }else if (scan_status->control_error || scan_status->error_code || + reached_chunk <= stop_chunk) { +/* E.g. another CPU in the group stopped the scan */ +if (!scan_status->control_error && !scan_status->error_code) + scan_status->error_code =IFS_SW_PARTIAL_COMPLETION ; + pcpu_scan->test_result =SCAN_NOT_TESTED ; +message_not_tested (dev, lcpu, *scan_status); + }else { + pcpu_scan->test_result =SCAN_TEST_PASS ; + } + +if (lcpu == ifsd->cpu) + ifsd->status = pcpu_scan->test_result; + } +} +/* * Use stop_core_cpuslocked() to synchronize writing to MSR_ACTIVATE_SCAN * on all threads of the core to be tested. Loop if necessary to complete @@ -232,9 +317,14 @@ static void ifs_test_core(int cpu, struct device *dev)int to_start, to_stop;int status_chunk;
drivers/platform/x86/intel/ifs/runtest.c static void ifs_test_core(int cpu, struct device *dev) · line 327
Quoted 10 lines
drivers/platform/x86/intel/ifs/runtest.c +6
-1struct run_params params; -int retries; +int retries, lcpu; ifsd =ifs_get_data (dev); + ifsd->cpu = cpu; + +/* Don't let results from a previous test leak into this one */ +for_each_cpu (lcpu, &ifsd->grp_cpumask) +memset (per_cpu_ptr (ifsd->result_ptr, lcpu),0 ,sizeof (struct ifs_test_output ));
Local var similar to above.
Quoted 112 lines
drivers/platform/x86/intel/ifs/runtest.c +28
-17activate.gen0.rsvd =0 ; activate.delay =IFS_THREAD_WAIT ;@@ -258,6 +348,7 @@ static void ifs_test_core(int cpu, struct device *dev)while (to_start <= to_stop) {if (time_after (jiffies, timeout)) { status.error_code =IFS_SW_TIMEOUT ; +update_group_status (dev,IFS_SW_TIMEOUT );break ; }@@ -272,15 +363,16 @@ static void ifs_test_core(int cpu, struct device *dev) status = params.status;/* Some cases can be retried, give up for others */ -if (!can_restart (status)) +if (!can_restart_test_group (dev))break ; - status_chunk = ifsd->generation ? status.gen2.chunk_num : status.gen0.chunk_num; + status_chunk =group_min_chunk (ifsd);if (status_chunk == to_start) {/* Check for forward progress */ if (--retries ==0 ) {if (status.error_code ==IFS_NO_ERROR ) status.error_code =IFS_SW_PARTIAL_COMPLETION ; +update_group_status (dev,IFS_SW_PARTIAL_COMPLETION );break ; } }else {@@ -295,16 +387,7 @@ static void ifs_test_core(int cpu, struct device *dev)/* Update status for this core */ ifsd->scan_details = status.data; - -if (status.signature_error) { - ifsd->status =SCAN_TEST_FAIL ; -message_fail (dev, cpu, status); - }else if (status.control_error || status.error_code) { - ifsd->status =SCAN_NOT_TESTED ; -message_not_tested (dev, cpu, status); - }else { - ifsd->status =SCAN_TEST_PASS ; - } +update_group_result (dev, to_stop); }static int do_array_test (void *data)@@ -313,7 +396,6 @@ static int do_array_test(void *data)int cpu =smp_processor_id ();union ifs_array *command;struct ifs_data *ifsd; -int first; ifsd = params->ifsd;@@ -323,9 +405,7 @@ static int do_array_test(void *data)/* * Only one logical CPU on a core needs to trigger the Array test via MSR write. */ - first =cpumask_first (&ifsd->grp_cpumask); - -if (cpu == first) { +if (cpu == ifsd->cpu) {wrmsrq (MSR_ARRAY_BIST , command->data);/* Pass back the result of the test */ rdmsrq (MSR_ARRAY_BIST , command->data);@@ -343,6 +423,7 @@ static void ifs_array_test_core(int cpu, struct device *dev)unsigned long timeout; ifsd =ifs_get_data (dev); + ifsd->cpu = cpu; params.ifsd = ifsd; command.array_bitmask = ~0U ;@@ -451,6 +532,26 @@ static bool ifs_group_incomplete(int cpu, struct ifs_data *ifsd)return false; } +/* +* For a scan test, check the result of every CPU in the group, since the +* cores in a group can report different results. Array tests only have +* the result of the target CPU. +*/ +static bool ifs_test_passed (int test_num,struct ifs_data *ifsd) +{ +int lcpu; + +if (test_num !=IFS_TYPE_SAF ) +return ifsd->status ==SCAN_TEST_PASS ; + +for_each_cpu (lcpu, &ifsd->grp_cpumask) { +if (per_cpu_ptr (ifsd->result_ptr, lcpu)->test_result !=SCAN_TEST_PASS ) +return false; + } + +return true; +} +/* * 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 @@ -491,7 +592,7 @@ int do_core_test(int cpu, struct device *dev) ret = -EINVAL ; } -if (!ret && ifsd->status !=SCAN_TEST_PASS &&ifs_group_incomplete (cpu, ifsd)) +if (!ret && !ifs_test_passed (test->test_num, ifsd) &&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:
Signature · 1 line
i.
PATCH v2 12/17 platform/x86/intel/ifs: Add new sysfs interfaces {status, details, cpus_ran}_list
In reply to Ehab AbabnehFrom: 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 the status of the primary CPU in this group and doesn't indicate that secondary CPUs have been tested. This results in the following issues:
- All CPUs in a group can hold different statuses, but the user can only see the status of the primary CPU, as any errors observed by secondary CPUs are ignored.
- 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 results for the tested CPU to ensure backward compatibility, new sysfs interfaces {status, details, cpus_run}_list provide results for multiple related CPUs 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.
[ Qiuxu: wrote the commit message. ]
--- drivers/platform/x86/intel/ifs/sysfs.c | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
drivers/platform/x86/intel/ifs/sysfs.c +60 -0
@@ -135,6 +135,63 @@ 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); +int len; + + len =sysfs_emit (buf,"%*pbl" ,cpumask_pr_args (&ifsd->grp_cpumask)); +if (!len) +return sysfs_emit (buf,"%s\n" ,"none" ); + +return len +sysfs_emit_at (buf, len,"\n" ); +} + +static DEVICE_ATTR_RO (cpus_ran_list);/* global scan sysfs attributes */ struct attribute *plat_ifs_attrs[] = { &dev_attr_details.attr,
@@ -142,6 +199,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
Ilpo Järvinen
maintainerRe: [PATCH v2 12/17] platform/x86/intel/ifs: Add new sysfs interfaces {status, details, cpus_ran}_list
Quoted 51 lines · 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 the status of the primary CPU in this group and doesn't indicate that secondary CPUs have been tested. This results in the following issues:- All CPUs in a group can hold different statuses, but the user can only see the status of the primary CPU, as any errors observed by secondary CPUs are ignored.
- 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 torun_test, and while the legacy sysfs reports results for the tested CPU to ensure backward compatibility, new sysfs interfaces {status, details, cpus_run}_list provide results for multiple related CPUs 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_listto see the CPUs tested:echo 0 >
run_test
catcpus_ran_list
0,96cat
status_list
pass pass
Quoted 8 lines
cat
details_list
0x80860x8087[1] Indicated by bits [20:16] of
MSR_INTEGRITY_CAPABILITIESwhen 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.[ Qiuxu: wrote the commit message. ]
Not among Signed-off-by members?
Quoted 56 lines
Signed-off-by Jithu Joseph <[email protected]>Signed-off-by Ehab Ababneh <[email protected]>Tested-by Yi Lai <[email protected]>--- drivers/platform/x86/intel/ifs/sysfs.c | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)drivers/platform/x86/intel/ifs/sysfs.c +40
-0@@ -135,6 +135,63 @@ 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;
drivers/platform/x86/intel/ifs/sysfs.c static ssize_t image_version_show(struct device *dev, · line 187
Quoted 10 lines
drivers/platform/x86/intel/ifs/sysfs.c +10
-0+} + +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); +int len; + + len =sysfs_emit (buf,"%*pbl" ,cpumask_pr_args (&ifsd->grp_cpumask));
Why doesn't this format string just add \n and return immediately?
Quoted 22 lines
drivers/platform/x86/intel/ifs/sysfs.c +7
-0+if (!len) +return sysfs_emit (buf,"%s\n" ,"none" ); + +return len +sysfs_emit_at (buf, len,"\n" ); +} + +static DEVICE_ATTR_RO (cpus_ran_list);/* global scan sysfs attributes */ struct attribute *plat_ifs_attrs[] = {drivers/platform/x86/intel/ifs/sysfs.c +3
-0&dev_attr_details.attr,@@ -142,6 +199,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
i.
PATCH v2 13/17 platform/x86/intel/ifs: Add additional details sysfs interface
In reply to Ehab AbabnehFrom: 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.
[ Qiuxu: wrote the commit message. ]
--- 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
@@ -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
@@ -177,6 +177,7 @@ static int doscan(void *data)struct run_params *params = data;union ifs_status status;struct ifs_data *ifsd; +u64 saf_wp =0 ; ifsd = params->ifsd; pcpu_scan =this_cpu_ptr (ifsd->result_ptr);
@@ -202,6 +203,8 @@ 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);/* Pass back the result of the scan */
@@ -209,6 +212,7 @@ static int doscan(void *data) params->status = status; pcpu_scan->test_details = status.data; + pcpu_scan->addnl_details = saf_wp;return 0 ; }
drivers/platform/x86/intel/ifs/sysfs.c +24 -0
@@ -192,6 +192,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,
@@ -202,6 +225,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
PATCH v2 14/17 platform/x86/intel/ifs: Add Intel Diamond Rapids server support
In reply to Ehab AbabnehFrom: 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.
[ Qiuxu: wrote the commit message. ]
--- drivers/platform/x86/intel/ifs/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/intel/ifs/core.c +1 -0
@@ -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
PATCH v2 15/17 platform/x86/intel/ifs: Remove limit on number of batch files
In reply to Ehab AbabnehFrom: 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.
[ Qiuxu: Update IFS ABI documentation to reflect the change. ]
--- Documentation/ABI/testing/sysfs-platform-intel-ifs | 9 ++++++--- drivers/platform/x86/intel/ifs/sysfs.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-)
Documentation/ABI/testing/sysfs-platform-intel-ifs +6 -3
@@ -46,9 +46,12 @@ 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
@@ -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
Ilpo Järvinen
maintainerRe: [PATCH v2 15/17] platform/x86/intel/ifs: Remove limit on number of batch files
Quoted 9 lines · Ehab Ababneh
From: Tony Luck <[email protected]>
Writing to the
current_batchsysfs file rejects batch numbers above0xff. 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.
[ Qiuxu: Update IFS ABI documentation to reflect the change. ]
????
Please don't submit garbage notes relating to development of the patch.
Quoted 42 lines
Signed-off-by Tony Luck <[email protected]>Signed-off-by Ehab Ababneh <[email protected]>Tested-by Yi Lai <[email protected]>--- Documentation/ABI/testing/sysfs-platform-intel-ifs | 9 ++++++--- drivers/platform/x86/intel/ifs/sysfs.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-)Documentation/ABI/testing/sysfs-platform-intel-ifs +6
-3@@ -46,9 +46,12 @@ 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_0drivers/platform/x86/intel/ifs/sysfs.c +1
-1@@ -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
i.
PATCH v2 16/17 platform/x86/intel/ifs: Update IFS documentation
In reply to Ehab AbabnehFrom: 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 | 66 ++++++++++++++++++---------- 1 file changed, 44 insertions(+), 22 deletions(-)
drivers/platform/x86/intel/ifs/ifs.h +44 -22
@@ -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,52 @@* 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 primary CPU in the 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. * -* Additional details of the last test is provided by the details file:: +* Additional details of the last test for the primary CPU in the group are provided in /sys:: * * $ 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 +147,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
Ilpo Järvinen
maintainerRe: [PATCH v2 16/17] platform/x86/intel/ifs: Update IFS documentation
Quoted 88 lines · 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.Signed-off-by Qiuxu Zhuo <[email protected]>Signed-off-by Ehab Ababneh <[email protected]>Tested-by Yi Lai <[email protected]>--- drivers/platform/x86/intel/ifs/ifs.h | 66 ++++++++++++++++++---------- 1 file changed, 44 insertions(+), 22 deletions(-)drivers/platform/x86/intel/ifs/ifs.h +17
-18@@ -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,52 @@* 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::
drivers/platform/x86/intel/ifs/ifs.h line 104
Quoted 10 lines
drivers/platform/x86/intel/ifs/ifs.h +3
-2+* The result of the last test for the primary CPU in the 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. * -* Additional details of the last test is provided by the details file:: +* Additional details of the last test for the primary CPU in the group are provided in /sys::
Does kerneldoc require long lines for :: ? If not, please reflow to 80 chars (and all similar cases you touch in this patch).
Quoted 39 lines
drivers/platform/x86/intel/ifs/ifs.h +24
-2* * $ 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 +147,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
i.
PATCH v2 17/17 Documentation/ABI: Update IFS ABI doc
In reply to Ehab AbabnehFrom: Qiuxu Zhuo <[email protected]>
Add documentation for the new sysfs interfaces {status, details, additional_details, cpus_ran}_list.
--- .../ABI/testing/sysfs-platform-intel-ifs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)
Documentation/ABI/testing/sysfs-platform-intel-ifs +24 -0
@@ -55,3 +55,27 @@ 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
Ilpo Järvinen
maintainerRe: [PATCH v2 17/17] Documentation/ABI: Update IFS ABI doc
Quoted 33 lines · Ehab Ababneh
From: Qiuxu Zhuo <[email protected]>
Add documentation for the new sysfs interfaces {status, details,
additional_details, cpus_ran}_list.Signed-off-by Qiuxu Zhuo <[email protected]>Signed-off-by Ehab Ababneh <[email protected]>Tested-by Yi Lai <[email protected]>--- .../ABI/testing/sysfs-platform-intel-ifs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)Documentation/ABI/testing/sysfs-platform-intel-ifs +13
-0@@ -55,3 +55,27 @@ 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 +
Documentation/ABI/testing/sysfs-platform-intel-ifs Description: Write a number to load an IFS test image. · line 80
Quoted 10 lines
Documentation/ABI/testing/sysfs-platform-intel-ifs +10
-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.
Try to stay within 80 chars (long lines are harder to read as they require eye movement).
Signature · 1 line
i.