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

Miaohe Lin <[email protected]>
Newsgroups org.infradead.lists.kexec,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
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 <[email protected]>
> Signed-off-by: Breno Leitao <[email protected]>
> Reviewed-by: Kiryl Shutsemau (Meta) <[email protected]>
> Reviewed-by: Pratyush Yadav <[email protected]>
> Reviewed-by: Bradley Morgan <[email protected]>

Reviewed-by: Miaohe Lin <[email protected]>

Thanks.
.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.