From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A782D30596F for ; Tue, 18 Aug 2026 12:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.221 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787055371; cv=none; b=nHZAx9bCqCxGbaMpCPIrQMQ0s7K/a7zbg/mvlLyttIPv9zBnP2mMT1lLYd7vaAxY3DRA3ooDqPaWglg9CoNdz0+16Hfaf4D44gQJ90WABYrxmaZbie0z17+nfk4Q9oGh1YQ6ws0oPQ0Q8bv1eceaNpfI4w7777Be/4CcCdVGz7k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787055371; c=relaxed/simple; bh=ibVI4kvL825bJ+2QH1+vaUpNxQ+qNATpilaLQiTszkM=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=cyG5VGGxATmltqB9OUEJ3WWPDxWVI/BJm13bUmoigO4dF7e1KEuWpDNtaY5Ikj3sd4ZOgpogZ9/N9rw4ioF/wwH/743TGfVkracLGGK8viCsqBKfOUYdZrkfdCmTRGx4rSdRNWtR1MtFVCCA4IBuPkAI456xU7VQ+IMGRZpC5jk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=CtkBOOzd; arc=none smtp.client-ip=113.46.200.221 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="CtkBOOzd" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=YJN1XNbV1kVG2NQ3eF3Cz0aSxHqvy1o4DerQ17ykIz0=; b=CtkBOOzdgvQOOkYQfbKQ9+0f6okaXLJPPYPMqpbF8rpax8HOWbesMuK28GuLhRD77zlNyyGCc b1Rvju6IUfwQKh/prrn2V54H+ShXHIpbM34dNJzEFASE4P+GnwduddcihO2hS+GFEcb+eDFnQkh xK3Kz/K/Mlck3bzypEjgXFU= Received: from mail.maildlp.com (unknown [172.19.162.197]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4hPT0x3MLnzRhQt; Tue, 18 Aug 2026 20:05:21 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 6B8D14057D; Tue, 18 Aug 2026 20:16:00 +0800 (CST) Received: from kwepemq500010.china.huawei.com (7.202.194.235) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 18 Aug 2026 20:16:00 +0800 Received: from [10.173.124.160] (10.173.124.160) by kwepemq500010.china.huawei.com (7.202.194.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 18 Aug 2026 20:15:58 +0800 Subject: Re: [PATCH v6 2/2] kexec: keep the next kernel off hardware-poisoned pages To: Breno Leitao CC: , , , , , , Kiryl Shutsemau , Bradley Morgan , Andrew Morton , "David Hildenbrand" , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , "Mike Rapoport" , Suren Baghdasaryan , "Michal Hocko" , Baoquan He , Pasha Tatashin , Pratyush Yadav , "Naoya Horiguchi" References: <20260812-kexec_posioned-v6-0-e477887086f0@debian.org> <20260812-kexec_posioned-v6-2-e477887086f0@debian.org> From: Miaohe Lin Message-ID: Date: Tue, 18 Aug 2026 20:15:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20260812-kexec_posioned-v6-2-e477887086f0@debian.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemq500010.china.huawei.com (7.202.194.235) 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 > Signed-off-by: Breno Leitao > Reviewed-by: Kiryl Shutsemau (Meta) > Reviewed-by: Pratyush Yadav > Reviewed-by: Bradley Morgan Reviewed-by: Miaohe Lin Thanks. .