Re: [PATCH v2] kexec: keep the next kernel off hardware-poisoned pages

Breno Leitao <[email protected]> Thu, 30 Jul 2026 09:18:00 -0700
Newsgroups org.infradead.lists.kexec,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
On Thu, Jul 30, 2026 at 08:55:50AM -0700, Breno Leitao wrote:
> Memory failures (such as unrecoverable ECCs errors) are getting more and
> more common. The kernel knows how to handle it while running, marking it
> as poisoned (and SIGBUS user tasks).
> 
> Poisoned memory is removed from the buddy allocator, but, not from
> other places. A current problem is that kexec will load new kernel
> on top of a bad/poisoned memory, which is undesirable.
> 
> If the next kernel's image, initrd or purgatory lands on poisoned frame,
> the relocation copy writes to the bad memory and the machine checks
> during the kexec.
> 
> Skip hardware-poisoned frames when placing segments: check them in the
> kexec_file hole finder so it lays the next kernel down on good memory,
> and reject a poisoned destination in sanity_check_segment_list() for
> the kexec_load path, which cannot relocate.
> 
> Suggested-by: Kiryl Shutsemau <[email protected]>
> Signed-off-by: Breno Leitao <[email protected]>
> ---
> Changes in v2:
 - change from pfn_to_page() to pfn_to_online_page() (Miaohe Lin)
 - Return the poisioned address once we find a hit, to avoid O(n^2)
   chcek. (Sashiko)