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

From: Breno Leitao

Date: Wed Jul 29 2026 - 06:54:40 EST


On Wed, Jul 29, 2026 at 05:33:17PM +0800, Miaohe Lin wrote:

> > + if (pfn_valid(pfn) && PageHWPoison(pfn_to_page(pfn)))
>
> Should we use pfn_to_online_page here? I doubt we might meet the same problem
> in [1] if pfn_to_page is used here.

Good catch, thanks -- yes. An offlined but not removed block is still
pfn_valid() while its struct page is uninitialized, so PageHWPoison()
on it hits VM_BUG_ON_PAGE(PagePoisoned(page)), the same failure as
commit d613f53c83ec ("mm/memory-failure: fix
VM_BUG_ON_PAGE(PagePoisoned(page)) when unpoison memory") fixes.

I'll switch to pfn_to_online_page() in v2:

for (pfn = PHYS_PFN(start); pfn <= end_pfn; pfn++) {
struct page *page = pfn_to_online_page(pfn);

if (page && PageHWPoison(page))
return true;
}

Thanks for the review.
--breno