From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
To: jez@sfcompute.com
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Len Brown <len.brown@intel.com>,
Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Andrew James <ajames@sfcompute.com>,
John Ranzie <jranzie@sfcompute.com>
Subject: Re: [PATCH 2/2] thermal: intel: hfi: Disable HFI left enabled by a previous kernel
Date: Wed, 18 Nov 2026 21:42:04 -0800 [thread overview]
Message-ID: <20261119054204.GA7495@ranerica-svr.sc.intel.com> (raw)
In-Reply-To: <20261028-hfi-kexec-v1-2-956234dcfb2b@sfcompute.com>
On Wed, Oct 28, 2026 at 12:14:46AM +0000, Jez Ng via B4 Relay wrote:
> From: Jez Ng <jez@sfcompute.com>
[ ... ]
>
> When the first CPU of a package comes online, check
> MSR_IA32_HW_FEEDBACK_CONFIG and disable HFI if it is already enabled. If
> a client subscribes later, HFI is re-enabled with this kernel's table as
> before.
This is not true on all processors. Some ignore later writes to
MSR_IA32_HW_FEEDBACK_PTR and, when HFI is enabled again, keep writing to
the table programmed by the first kernel after reset. Perhaps this
sentence can be qualified?
Also, would you be willing to check whether your Sapphire Rapids systems
honor later writes to MSR_IA32_HW_FEEDBACK_PTR?
[ ... ]
> + /*
> + * A previous kernel may have left HFI enabled across kexec. Hardware
> + * would keep writing to that kernel's table, in memory this kernel now
> + * owns.
> + */
> + if (hfi_disable_if_enabled())
> + pr_info("HFI left enabled on package %u, disabled\n", pkg_id);
> +
By the time this message is printed, memory corruption may already have
happened. Perhaps this should be a pr_warn() that mentions the potential
corruption explicitly?
As you acknowledge in the changelog, this code runs rather late during
boot. HFI could be disabled much earlier, from intel_init_thermal(),
which runs at CPU identify time: from start_kernel() for the boot CPU
and from smp_init() for the APs. This also works when the next kernel
has CONFIG_INTEL_HFI_THERMAL=n.
Maybe something like this in therm_throt.c or intel_hfi.h, called first
thing in intel_init_thermal():
static void intel_hfi_disable_stale(struct cpuinfo_x86 *c)
{
u64 msr_val;
if (!cpu_has(c, X86_FEATURE_HFI))
return;
if (IS_ENABLED(CONFIG_INTEL_HFI_THERMAL) && system_state >= SYSTEM_RUNNING)
return;
rdmsrq(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val);
if (!(msr_val & HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT))
return;
wrmsrq(MSR_IA32_HW_FEEDBACK_CONFIG,
msr_val & ~HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT);
pr_warn("CPU%d: HFI was enabled by a previous kernel; disabled it. Memory may be corrupted.\n",
smp_processor_id());
}
intel_init_thermal() also runs when a CPU comes online after boot and
on resume. Such a CPU must not disable an HFI instance that the driver
enabled for the other CPUs of its package. intel_hfi_disable_stale()
therefore checks system_state. Before SYSTEM_RUNNING, no client can have
asked for HFI. SYSTEM_BOOTING would not work: the APs come up during
smp_init() with SYSTEM_SCHEDULING.
I tried this on a Panther Lake-H system (one package, 16 CPUs). I
disabled the shutdown path of patch 1 and subscribed a thermal netlink
client to leave HFI enabled across kexec. The boot CPU disabled HFI
before smp_init() and acpi_init(). With your patch 2 alone, HFI remained
enabled 2.9 seconds longer. You should see a larger difference on your
systems, since 21 of their 30 seconds were spent in acpi_init().
A package with no CPU online at boot, for instance with maxcpus= or
nr_cpus=, keeps writing to the previous kernel's table until one of its
CPUs comes online, if ever. The check you added in intel_hfi_online() is
still needed to catch such a package when it comes online. With the
earlier check, that is the only case in which your check can find HFI
enabled. Only the syscore shutdown callback, in the previous kernel,
protects the time before that. Could the comment above your check and
the changelog say so?
next prev parent reply other threads:[~2026-11-19 5:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 0:14 [PATCH 0/2] thermal: intel: hfi: Stop hardware writing to freed memory after kexec Jez Ng via B4 Relay
2026-10-28 0:14 ` [PATCH 1/2] thermal: intel: hfi: Disable HFI on shutdown and kexec Jez Ng via B4 Relay
2026-11-19 5:42 ` Ricardo Neri
2026-10-28 0:14 ` [PATCH 2/2] thermal: intel: hfi: Disable HFI left enabled by a previous kernel Jez Ng via B4 Relay
2026-11-19 5:42 ` Ricardo Neri [this message]
2026-11-13 15:26 ` [PATCH 0/2] thermal: intel: hfi: Stop hardware writing to freed memory after kexec Rafael J. Wysocki (Intel)
2026-11-19 5:45 ` Ricardo Neri
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=20261119054204.GA7495@ranerica-svr.sc.intel.com \
--to=ricardo.neri-calderon@linux.intel.com \
--cc=ajames@sfcompute.com \
--cc=daniel.lezcano@kernel.org \
--cc=jez@sfcompute.com \
--cc=jranzie@sfcompute.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=stable@vger.kernel.org \
--cc=stanislaw.gruszka@linux.intel.com \
/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®