[PATCH v6 2/2] kexec: keep the next kernel off hardware-poisoned pages

Miaohe Lin linmiaohe at huawei.com
Tue Aug 18 05:15:58 PDT 2026


On 2026/8/12 19:31, 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 a poisoned
> frame, the relocation copy puts it on memory that is known bad. The
> error happens on the first read from a bad page, and that is what we
> want to avoid.
> 
> Skip hardware-poisoned frames that were detected by the memory failure
> subsystem earlier when placing kexec segments.
> 
> To do so, add a helper that reports the first or the last poisoned page
> in a range: memory is walked top-down by locate_mem_hole_top_down() and
> bottom-up by locate_mem_hole_bottom_up(), so each direction needs a
> different answer to stay clear of the poison.
> 
> kexec_load() gets its destinations from userspace and cannot move them,
> so there sanity_check_segment_list() just rejects a segment that happens
> to have a poisoned page.
> 
> is_page_hwpoison() also covers hugetlb, so a poisoned hugetlb folio is
> skipped as a whole.
> 
> 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>
> Reviewed-by: Pratyush Yadav <pratyush at kernel.org>
> Reviewed-by: Bradley Morgan <include at grrlz.net>

Reviewed-by: Miaohe Lin <linmiaohe at huawei.com>

Thanks.
.



More information about the kexec mailing list