From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
To: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
Cc: jez@sfcompute.com, Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Len Brown <len.brown@intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Andrew James <ajames@sfcompute.com>,
John Ranzie <jranzie@sfcompute.com>
Subject: Re: [PATCH 0/2] thermal: intel: hfi: Stop hardware writing to freed memory after kexec
Date: Wed, 18 Nov 2026 21:45:11 -0800 [thread overview]
Message-ID: <20261119054511.GC7495@ranerica-svr.sc.intel.com> (raw)
In-Reply-To: <CAJZ5v0hf9odYCxz1r3Er5dh2tjXCtDwKuhdS1b3tP6MOMjQSeA@mail.gmail.com>
On Fri, Nov 13, 2026 at 04:26:06PM +0100, Rafael J. Wysocki (Intel) wrote:
> On Wed, Oct 28, 2026 at 1:20 AM Jez Ng via B4 Relay
> <devnull+jez.sfcompute.com@kernel.org> wrote:
> >
> > HFI hardware writes updates to a table at a physical address the kernel
> > programs. Nothing disables HFI on shutdown, and since commit b33f3d2677b8
> > ("thermal: intel: hfi: Enable HFI only when required") a kernel that
> > starts without thermal netlink clients does not touch HFI at all. So
> > after a kexec, hardware keeps writing into the previous kernel's table,
> > which the new kernel treats as free memory.
> >
> > We hit this on dual-socket Sapphire Rapids hosts (Xeon Platinum 8462Y+)
> > that boot a Debian 6.1 kernel and kexec into a 7.0 kernel. The new
> > kernel crashed in find_inode_fast() when the inode hash table landed on
> > one of the old table pages. Reading MSR 0x17d0 on the running 7.0
> > kernel showed both packages still pointing at the 6.1 kernel's tables,
> > and the corruption had the HFI table layout: a timestamp, a changed
> > flag, then one row per CPU.
> >
> > Patch 1 disables HFI in a syscore shutdown callback, which covers
> > reboot, power off and kexec, and keeps it disabled afterwards: on kexec,
> > user space runs until machine_shutdown(), so a new thermal netlink
> > client could otherwise enable HFI again. Patch 2 makes a starting kernel
> > disable HFI if the previous kernel left it enabled. Patch 2 can only
> > narrow the window: hardware can still write between kernel start and
> > the moment the package's first CPU reaches the thermal online callback,
> > which was about 30 seconds into boot on these hosts.
> >
> > This is the kexec counterpart of the hibernation corruption fixed by
> > commit 97566d09fd02 ("thermal: intel: hfi: Add syscore callbacks for
> > system-wide PM"), which disables HFI for suspend and hibernation but not
> > for shutdown.
> >
> > Tested on one of the hosts above with both patches applied to this base,
> > alternating 100 kexecs (kexec_file_load + reboot(LINUX_REBOOT_CMD_KEXEC))
> > between the patched kernel and an unpatched 7.0 kernel. Before each
> > kexec, a thermal netlink subscriber enabled HFI on both packages. All
> > 100 passed:
> >
> > - Patch 1: after each of the 50 kexecs out of the patched kernel, the
> > unpatched kernel read HW_FEEDBACK_CONFIG = 0 on both packages.
> >
> > - Patch 2: after each of the 50 kexecs into the patched kernel, it
> > logged "HFI left enabled on package N, disabled" for both packages
> > and read HW_FEEDBACK_CONFIG = 0.
>
> Ricardo, can you please have a look at this series and let me know
> what you think about it?
Hi Rafael, Jez,
These patches fix a real problem, and I think they can be applied
once we close on my comments on patch 2.
This series does not cover processors that ignore a write to
MSR_IA32_HW_FEEDBACK_PTR after the first one. On those processors, the
HFI table of the first kernel after reset must be preserved across
kexec and reused by the next kernel. I have work in progress for that,
based on Kexec Handover (KHO), and plan to send it as a follow-up to
this series.
prev parent reply other threads:[~2026-11-19 5:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 0:14 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
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 [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=20261119054511.GC7495@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 \
/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®