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

Kiryl Shutsemau kas at kernel.org
Mon Aug 10 07:59:00 PDT 2026


On Mon, Aug 10, 2026 at 06:32:04AM -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.
> 
> The two hole finders walk in opposite directions, so each asks for the
> end of the poison it has to clear: the top-down walk for the first
> poisoned page in the window, the bottom-up walk for the last. A poisoned
> hugetlb folio counts in full, as hugetlb keeps the flag on the folio and
> the poisoned subpages on its raw hwpoison list.
> 
> Suggested-by: Kiryl Shutsemau <kas at kernel.org>
> Signed-off-by: Breno Leitao <leitao at debian.org>

Reviewed-by: Kiryl Shutsemau (Meta) <kas at kernel.org>

-- 
  Kiryl Shutsemau / Kirill A. Shutemov



More information about the kexec mailing list