From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 F29A8435EF0 for ; Wed, 12 Aug 2026 11:32:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786534341; cv=none; b=E1uX6zVnouQMoqoUOTKAhc2FzivNP03pm0jpnwTDMGxnkw6gOj2jwrjQP8EN2zEk7hUHPilMW4+U2GJe/TPSqORDKb9GyKefHYmInui6pxBpEohr6MR8FIDtG6TMlk2c8CKw/IzqwOk+j3I0DYnls2Eq3Xg4TSiYuSIKXM0xJns= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786534341; c=relaxed/simple; bh=MEuO2alc61B25/RbuNvMKIHActXYMHq90TiaCXPG2gM=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=pO3wYYpPQvo4TW7KTKCqkFjYYDuk7GMbQ1ciC1vvsieeXtCg4S1ZhblbPc/Fu5m69HUWTdK+Zzbf3Bb6APkGtU7i3wh4fxgsd71ppxwulmRaS0ZNWdMRAwXNs2M6lyaidCJijqg/gqkAWlQUM+hyY7yLKTNV1TFb9qVyW13So7g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=nBqpzEym; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="nBqpzEym" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:From:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=XKdbUWVjqXoP5QkUXtvUTfFmZJO1U64wmy2Dn8sFEgY=; b=nBqpzEymNpnG2HId4WtGj1MEdu S6GCQwciU8L1OUqLGN8J587I0XRVbYRruA9hE6AOieKa0nfA9YNRMeThxYiybpb4ebbZ0T95a309C RrMi5JRsPnai1lAY9uxzVZcZSO0aJsQvPFyA80Wl/WE6C2k2qo0pXVOp0M31VgbaSVfblaJ12jrSv hGQWdCfIaoDJJbDZRf+trKB6vAZsVH0AEKVXLupg9QzzE0ske1hrfv08+TS27YAculnFGC5TgBo5U VroTc5gKS436rfbSGtv2ApEnejh6J6o5w3/U6z24wZLjVFsPz4ZXseru4TriWBqQqixRm6vX0ZjYV 475p7TMw==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wu7Bi-004JJE-0s; Wed, 12 Aug 2026 11:32:03 +0000 From: Breno Leitao Subject: [PATCH v6 0/2] kexec: keep the next kernel off hardware-poisoned pages Date: Wed, 12 Aug 2026 04:31:50 -0700 Message-Id: <20260812-kexec_posioned-v6-0-e477887086f0@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAKdZfGoC/2XQ22rDMAyA4Vcxuo6G5VPcXPU9xhhOLLdmkBRnm I6Sdx8pjGXzrdD3I/SAlUvmFQbxgMI1r3mZYRCuEzBdw3xhzBEGAUoqJ3vV4wffeXq/LfsiR+z VOMpgyOggoRNwK5zy/Rl8fesEXPP6uZSvZ7/SPv1J+f+pSkhITk6eInmZ+Bx5zGF+WcoF9lZVB 69l4xUSppOK5K2l5Ezj9a/3UjdeI6HXITiOLLWlxpujb15RDRL2Mto+kXHKxsbbg6f2fouEJ8s 0WlbsrPvjt237BuvIbZutAQAA X-Change-ID: 20260727-kexec_posioned-72bb0a4143a0 To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Baoquan He , Pasha Tatashin , Pratyush Yadav , Miaohe Lin , Naoya Horiguchi Cc: Breno Leitao , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, rmikey@meta.com, riel@surriel.com, kernel-team@meta.com, Kiryl Shutsemau , Bradley Morgan X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=4000; i=leitao@debian.org; h=from:subject:message-id; bh=MEuO2alc61B25/RbuNvMKIHActXYMHq90TiaCXPG2gM=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqfFmsIQEnDIumBT1dUzqWEh0n4xoEnjZzL5AyX uRmodHGmXuJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanxZrAAKCRA1o5Of/Hh3 bZUWD/91dXzRWqOndMqQZW8KYQaSDpHWB5EzGhwM5+rZECR2+0h8C/+bLmI3gUsHIdixbYE/yh2 LWHOiSJhopjAbzpKo2M5MlnhlFD/fEhmMUq/PvSbsO2NnKhYAFG6DDuApmgUHGOaHeBNQBF0dXU yC1fcWse9Xep2n3nwmmRekxkUziMX2FYj78rjQdkTnfWzlIZQjx5cKigcZZc9NxBYkwTVMY61B2 D3HF2sEwu9+nkBMN/MfgbKhoVKRfZEfEl2kwAw86Gbih7GWBr6VXMJ4lhtzBETVfOWq+tJJdhMO KKbVpG4xVhBvGc0HkEW1UnSG3tEb0ZqzmFs5gxLTpFIsCk+rt6LEm8qzda/wVRwwFgXb804Ix5c xd9weCQyDdQw6sTbZfJU2JEuvtxds/Zv4L2FoBOcIf+ZHxOuQffSV9uYSJNUOpSHe+exqt2iJie vAkudANJRCTmaDM+54PO2nasXoB9PhtQGHJV+48InkGTgxZTGZs5/4legBfKMT7YsiyI9LaS/vZ MZ02c1ljfhOsBVceQs0P+WsfJ6jShGinCzLfw+j3CFNXCFkHEsmikbReimi01nCx+Nn3NL028Wo cctiIX+G67d/etdCT0a65SAMdIWjNWqM+CQ9aKkBvpFKvK4tvAjtSsGqzKHXUxnpgy4uY4vGomS DxRKjKNPpzKSHUA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Memory failures are common enough on large fleets that kexec regularly lands the next kernel on a frame the memory failure subsystem has already marked bad. Patch 2 teaches the segment placement to avoid those frames. Patch 1 is a prerequisite. locate_mem_hole_top_down() walks candidates downwards without ever checking that the subtraction stays above zero, so the walk can wrap and report success with a destination outside of RAM. Patch 2 adds one more downward step to that loop, so the bug is fixed first and both patches rely on the same bail-out. Signed-off-by: Breno Leitao --- Changes in v6: - Split the pre-existing top-down underflow out into its own patch, and drop the "if (poison < kbuf->memsz)" guard from the hwpoison hunk now that the loop bail-out covers it. (Mike Rapoport, Sashiko) - Reword the changelog: the MCE comes from reading the poison back, not from the relocation copy writing it, and the placement paragraphs read better split up. (Mike Rapoport) - Move cond_resched() after the struct page dereference, so the scan does not yield between pfn_to_online_page() and is_page_hwpoison(). (Pratyush Yadav, Sashiko) - Keep cond_resched() per pfn rather than batching it. (Kiryl Shutsemau, Rik van Riel) - Link to v5: https://patch.msgid.link/20260810-kexec_posioned-v5-1-95e1b5e2e656@debian.org Changes in v5: - Return -EHWPOISON instead of -EADDRNOTAVAIL - Leverage is_page_hwpoison() instead of per-page check - Link to v4: https://patch.msgid.link/20260807-kexec_posioned-v4-1-70d57f14625d@debian.org Changes in v4: - Anchor the top-down hole finder on the first poisoned page in the window and the bottom-up one on the last, so each jumps clear of the poison in one step. New range_first_hwpoison(). (Kiryl Shutsemau) - Count a poisoned hugetlb folio in full: the flag lives on the folio, not on the subpages, so the per-pfn scan missed poisoned tail pages. (Kiryl Shutsemau) - Link to v3: https://patch.msgid.link/20260803-kexec_posioned-v3-1-83aa6ede0351@debian.org Changes in v3: - Return the address of the last poisoned page in the range, or PHYS_ADDR_MAX when it is clean, instead of a bool plus an output parameter. Renamed to range_last_hwpoison(). (Pratyush Yadav) - Add cond_resched() to the scan loop, as a segment can span half of memory. (Sashiko) - Link to v2: https://patch.msgid.link/20260730-kexec_posioned-v2-1-f92d18551f64@debian.org Changes in v2: - Change from pfn_to_page() to pfn_to_online_page(). (Miaohe Lin) - Return the poisoned address once we find a hit, to avoid the O(n^2) rescan. (Sashiko) - Link to v1: https://patch.msgid.link/20260728-kexec_posioned-v1-1-160c81d180fe@debian.org To: Andrew Morton To: David Hildenbrand To: Lorenzo Stoakes To: "Liam R. Howlett" To: Vlastimil Babka To: Mike Rapoport To: Suren Baghdasaryan To: Michal Hocko To: Baoquan He To: Pasha Tatashin To: Pratyush Yadav To: Miaohe Lin To: Naoya Horiguchi Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org Cc: rmikey@meta.com Cc: riel@surriel.com --- Breno Leitao (2): kexec_file: stop the top-down search before it underflows kexec: keep the next kernel off hardware-poisoned pages include/linux/mm.h | 14 ++++++++++++++ kernel/kexec_core.c | 10 ++++++++++ kernel/kexec_file.c | 20 +++++++++++++++++++- mm/memory-failure.c | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) --- base-commit: c5e32e86ca02b003f86e095d379b38148999293d change-id: 20260727-kexec_posioned-72bb0a4143a0 Best regards, -- Breno Leitao