From: Ehab Ababneh <ehab.ababneh@intel.com>
To: ilpo.jarvinen@linux.intel.com, hansg@kernel.org, tony.luck@intel.com
Cc: ashok.raj.linux@gmail.com, platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, tglx@kernel.org, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
hpa@zytor.com, rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com,
linux-trace-kernel@vger.kernel.org, peterz@infradead.org,
sathyanarayanan.kuppuswamy@linux.intel.com, pengfei.xu@intel.com,
ravi.v.shankar@intel.com
Subject: [PATCH 10/17] platform/x86/intel/ifs: Validate TID_BIT_SHIFT matches topology_cluster_cpumask()
Date: Mon, 26 Oct 2026 11:38:13 -0700 [thread overview]
Message-ID: <20261026183820.129459-11-ehab.ababneh@intel.com> (raw)
In-Reply-To: <20261026183820.129459-1-ehab.ababneh@intel.com>
From: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
The intel_ifs driver assumes logical processors indicated by TID_BIT_SHIFT
[1] that share the same SCAN test engine match topology_cluster_cpumask().
Validate this assumption during driver initialization and fail loading if
it doesn't hold.
[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 <tony.luck@intel.com>
Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Signed-off-by: Ehab Ababneh <ehab.ababneh@intel.com>
---
arch/x86/include/asm/msr-index.h | 1 +
drivers/platform/x86/intel/ifs/core.c | 48 +++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 554ce662fdf4..e93c76389ca5 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -281,6 +281,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)
diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c
index f2d2caab0479..c830a02fe7b3 100644
--- a/drivers/platform/x86/intel/ifs/core.c
+++ b/drivers/platform/x86/intel/ifs/core.c
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright(c) 2022 Intel Corporation. */
+#define pr_fmt(fmt) "intel_ifs: " fmt
+
#include <linux/bitfield.h>
#include <linux/module.h>
#include <linux/kdev_t.h>
@@ -69,6 +71,45 @@ static struct ifs_device ifs_devices[] = {
},
};
+/*
+ * Test whether logical processors indicated by TID_BIT_SHIFT that share the
+ * same SCAN test engine match the cpumask from topology_cluster_cpumask().
+ */
+static bool topology_cluster_matched(u32 msrval)
+{
+ u32 dist, shift = FIELD_GET(MSR_INTEGRITY_CAPS_TID_BIT_SHIFT_MASK, msrval);
+ const cpumask_t *cpumask = topology_cluster_cpumask(0);
+ u32 delta, step = 0, first = cpu_data(0).topo.apicid;
+ unsigned int cpu, cpus;
+
+ /* Get the minimal APIC ID step among the CPUs in the same cluster. */
+ for_each_cpu_andnot(cpu, cpumask, cpumask_of(0)) {
+ delta = abs(cpu_data(cpu).topo.apicid - first);
+
+ if (!step) {
+ step = delta;
+ continue;
+ }
+
+ if (step > delta)
+ step = delta;
+ }
+
+ /* A Hyper-Threading (HT) system with HT disabled. */
+ if (!step)
+ step = 2;
+
+ cpus = cpumask_weight(cpumask);
+ dist = step * cpus;
+
+ if (dist != (1 << shift)) {
+ pr_err_once("APICID step %u, group cpus %u, TID_BIT_SHIFT %u\n", step, cpus, shift);
+ return false;
+ }
+
+ return true;
+}
+
#define IFS_NUMTESTS ARRAY_SIZE(ifs_devices)
static void ifs_cleanup(void)
@@ -122,6 +163,13 @@ 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;
+
+ if (ifs_devices[i].rw_data.all_lp_join && !topology_cluster_matched(msrval)) {
+ pr_err_once("TID_BIT_SHIFT mismatched topology_cluster_cpumask().\n");
+ ret = -EINVAL;
+ goto err_exit;
+ }
+
ifs_devices[i].rw_data.array_gen = (u32)m->driver_data;
ret = misc_register(&ifs_devices[i].misc);
if (ret)
--
2.43.0
next prev parent reply other threads:[~2026-10-26 18:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 18:38 [PATCH 00/17] platform/x86/intel/ifs: Support group-based In-Field Scan and Diamond Rapids Ehab Ababneh
2026-10-26 18:38 ` [PATCH 01/17] platform/x86/intel/ifs: Revert SBAF feature Ehab Ababneh
2026-10-26 18:38 ` [PATCH 02/17] platform/x86/intel/ifs: Fix IFS sysfs interfaces in the comments Ehab Ababneh
2026-10-26 18:38 ` [PATCH 03/17] platform/x86/intel/ifs: Clarify In-Field Scan MSR bit macro definitions Ehab Ababneh
2026-10-26 18:38 ` [PATCH 04/17] platform/x86/intel/ifs: Use u64 to define the bits of IFS MSR registers Ehab Ababneh
2026-10-26 18:38 ` [PATCH 05/17] platform/x86/intel/ifs: Early return on the IFS image hash/chunk error Ehab Ababneh
2026-10-26 18:38 ` [PATCH 06/17] platform/x86/intel/ifs: Refactor Array BIST function interface Ehab Ababneh
2026-10-26 18:38 ` [PATCH 07/17] stop_machine: Add stop_cluster_cpuslocked() for per-cluster operations Ehab Ababneh
2026-10-26 18:38 ` [PATCH 08/17] platform/x86/intel/ifs: Enumerate the bit to determine if CPUs need to join for IFS tests Ehab Ababneh
2026-10-26 18:38 ` [PATCH 09/17] platform/x86/intel/ifs: Select CPUs from topology_cluster_cpumask() for simultaneous " Ehab Ababneh
2026-10-26 18:38 ` Ehab Ababneh [this message]
2026-10-26 18:38 ` [PATCH 11/17] platform/x86/intel/ifs: Track and report scan results on a per-CPU basis Ehab Ababneh
2026-10-26 18:38 ` [PATCH 12/17] platform/x86/intel/ifs: Add new sysfs interfaces {status, details, cpus_ran}_list Ehab Ababneh
2026-10-26 18:38 ` [PATCH 13/17] platform/x86/intel/ifs: Add additional details sysfs interface Ehab Ababneh
2026-10-26 18:38 ` [PATCH 14/17] platform/x86/intel/ifs: Add Intel Diamond Rapids server support Ehab Ababneh
2026-10-26 18:38 ` [PATCH 15/17] platform/x86/intel/ifs: Remove limit on number of batch files Ehab Ababneh
2026-10-26 18:38 ` [PATCH 16/17] platform/x86/intel/ifs: Update IFS documentation Ehab Ababneh
2026-10-26 18:38 ` [PATCH 17/17] Documentation/ABI: Update IFS ABI doc Ehab Ababneh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261026183820.129459-11-ehab.ababneh@intel.com \
--to=ehab.ababneh@intel.com \
--cc=ashok.raj.linux@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hansg@kernel.org \
--cc=hpa@zytor.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=pengfei.xu@intel.com \
--cc=peterz@infradead.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=ravi.v.shankar@intel.com \
--cc=rostedt@goodmis.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®