From: sashiko-bot@kernel.org
To: "Ehab Ababneh" <ehab.ababneh@intel.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 17/17] Documentation/ABI: Update IFS ABI doc
Date: Mon, 26 Oct 2026 18:54:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-185648@kernel.org> (raw)
In-Reply-To: <20261026183820.129459-18-ehab.ababneh@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] platform/x86: intel/ifs: ifs_init() fails on gen0 due to cluster check
- [High] platform/x86: intel/ifs: do_core_test() updates grp_cpumask before checks
--
commit d3afda8246f048aa9feb139ad53fbb292e1d53d9
Author: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Documentation/ABI: Update IFS ABI doc
This series updates the Intel In-Field Scan (IFS) driver to support CPU
clusters sharing a scan test engine, validates cluster topology against
MSR_INTEGRITY_CAPS, tracks per-CPU scan results, and adds sysfs list
interfaces along with their documentation.
> diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c
> index 3dafa28a10104..5c9c86e048371 100644
> --- a/drivers/platform/x86/intel/ifs/core.c
> +++ b/drivers/platform/x86/intel/ifs/core.c
[ ... ]
> +/*
> + * 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;
> +}
[ ... ]
> @@ -134,11 +157,33 @@ 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;
> +
> + 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;
> + }
[Severity: High]
Will ifs_init() -> topology_cluster_matched() cause a regression where driver
initialization unconditionally fails with -EINVAL on all Sapphire Rapids and
Emerald Rapids (generation == 0) processors?
In ifs_init(), when ifs_devices[i].rw_data.generation is 0, all_lp_join is
forced to true, and topology_cluster_matched() is then called without checking
whether generation is non-zero.
On generation 0 platforms, bits [20:16] (MSR_INTEGRITY_CAPS_TID_BIT_SHIFT_MASK)
of MSR_INTEGRITY_CAPS are reserved and read as 0, so shift is 0 and (1 << shift)
is 1. However, in topology_cluster_matched(), dist = step * cpus is always at
least 2 (when SMT is enabled, cpus >= 2 and step >= 1; when SMT is disabled,
cpus == 1 and step is set to 2). As a result, dist != (1 << shift) always
evaluates to true and ifs_init() aborts with -EINVAL.
Additionally, on generation >= 2 systems, topology_cluster_matched() computes
cpus = cpumask_weight(topology_cluster_cpumask(0)) using only currently online
CPUs and assumes !step always means 2-way SMT disabled (step = 2). If any
sibling thread or core in CPU 0's cluster is offline when the module loads,
won't dist != (1 << shift) also fail initialization?
> diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c
> index dfc119d7354d7..d5303dd722333 100644
> --- a/drivers/platform/x86/intel/ifs/runtest.c
> +++ b/drivers/platform/x86/intel/ifs/runtest.c
[ ... ]
> +static void build_cpugroup_mask(struct device *dev, int cpu)
> {
> - union ifs_sbaf_status status = (union ifs_sbaf_status)status_data;
> + struct ifs_data *ifsd = ifs_get_data(dev);
>
[ ... ]
> + cpumask_clear(&ifsd->grp_cpumask);
>
> /*
> - * This WRMSR will wait for other HT threads to also write
> - * to this MSR (at most for activate.delay cycles). Then it
> - * starts scan of each requested bundle. The core test happens
> - * during the "execution" of the WRMSR.
> + * 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
> + * 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)
> @@ -628,9 +493,10 @@ int do_core_test(int cpu, struct device *dev)
>
> /* Prevent CPUs from being taken offline during the scan test */
> cpus_read_lock();
> + build_cpugroup_mask(dev, cpu);
>
> 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;
> }
[Severity: High]
Can calling build_cpugroup_mask() in do_core_test() before checking
cpu_online(cpu) and ifsd->loaded dereference a NULL cpumask pointer or corrupt
ifsd->grp_cpumask?
In drivers/platform/x86/intel/ifs/sysfs.c, run_test_store() only verifies
cpu < nr_cpu_ids before calling do_core_test(cpu, dev):
run_test_store()
do_core_test(cpu, dev)
build_cpugroup_mask(dev, cpu)
If user space writes a CPU number that is < nr_cpu_ids but not in
cpu_possible_mask:
1) When ifsd->all_lp_join is true, build_cpugroup_mask() calls
cpumask_copy(&ifsd->grp_cpumask, topology_cluster_cpumask(cpu)), which reads
per_cpu(cpu_l2c_shared_map, cpu). Because cpu_l2c_shared_map is only allocated
for possible CPUs in smp_prepare_cpus_common(), won't this dereference a NULL
pointer when CONFIG_CPUMASK_OFFSTACK=y?
2) When ifsd->all_lp_join is false, build_cpugroup_mask() sets the non-possible
CPU in ifsd->grp_cpumask before the !cpu_online(cpu) check returns -EINVAL.
Subsequent reads of status_list_show(), details_list_show(), and
addnl_details_list_show() in drivers/platform/x86/intel/ifs/sysfs.c will then
iterate over ifsd->grp_cpumask and call per_cpu_ptr(ifsd->result_ptr, lcpu) on
an unallocated per-CPU slot.
Even when cpu is possible, if cpu is offline (-EINVAL) or !ifsd->loaded (-EPERM
in the IFS_TYPE_SAF case), build_cpugroup_mask() has already overwritten
ifsd->grp_cpumask, causing cpus_ran_list, status_list, details_list, and
addnl_details_list to report stale or untested CPUs instead of "none" or the
previous test's group.
Should build_cpugroup_mask() be moved after the cpu_online(cpu) and
ifsd->loaded checks?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261026183820.129459-1-ehab.ababneh@intel.com?part=17
prev parent reply other threads:[~2026-10-26 18:54 UTC|newest]
Thread overview: 24+ 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:47 ` sashiko-bot
2026-10-26 18:38 ` [PATCH 10/17] platform/x86/intel/ifs: Validate TID_BIT_SHIFT matches topology_cluster_cpumask() Ehab Ababneh
2026-10-26 18:49 ` sashiko-bot
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:54 ` sashiko-bot
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:49 ` sashiko-bot
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:58 ` sashiko-bot
2026-10-26 18:38 ` [PATCH 17/17] Documentation/ABI: Update IFS ABI doc Ehab Ababneh
2026-10-26 18:54 ` sashiko-bot [this message]
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=sashiko-outbox-185648@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ehab.ababneh@intel.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.