From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 29CD43B777F for ; Wed, 1 Jul 2026 10:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782903412; cv=none; b=EwX/4mLXzkynyzAQ0ti8A/XuJY9oCFt02prYnqOiRGfidJ8VRbj8aDpH3M9p0UPJMjBsepO+FDEAwFQnRtnVCwacVkev2n01sTZbdYiA32ZF9m4kgfHOXIykMYlEmuD6Zr+JBodeoViZwBBMeVNhOdFJSd1MGoiWQqQaPpzirOI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782903412; c=relaxed/simple; bh=HGavdTM9p0o+hadjLMvlRkflQdK08K99RnJQUkEw2aI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Q1dHLhdx2fBr96lUHdL31TITDFDhDydGO0OV45YKy/b0tvWx+6Ol4YhGSjMChBYJuXCZdbbFvwQnUDxj7E8UuiJoG7pOaOoRDE7qt+dltOFb8XdNsROyA3OtgddTuWddhNCmv8fwzDmg05PmoNGxoST/LRSD2NYfM0kK36rURmY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=BEB28umq; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="BEB28umq" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1782903403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=nL6GH6ik36u+3oisiWgN6v5JDtof35vJCqA02nCfVYE=; b=BEB28umqoFY1ipQDj8kEy/vtLPrXMX1C7Kkgaj8zaafTEosNcpsLG7NOlJYsD9PyFOtiTu HWHx5nd3jNMt9CguvZgfRuTVKpb9ZSmeutmg6b6893N8dAzMOO8yXFzItuyK0V2GFeMkEY uovwpvnkIaETiOvNvkCYzuyw9T8GnIw= From: Kaitao Cheng To: Andrew Morton , David Hildenbrand , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple Cc: Naoya Horiguchi , Mel Gorman , Andi Kleen , Muchun Song , Jun'ichi Nomura , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kaitao Cheng Subject: [PATCH] migrate: Skip hwpoisoned hugetlb folios during migration Date: Wed, 1 Jul 2026 18:55:44 +0800 Message-ID: <20260701105544.97059-1-kaitao.cheng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Kaitao Cheng Hugetlb migration does not check whether the source folio contains hwpoisoned memory before trying to move it. After the folio is unmapped, the move path can reach hugetlbfs_migrate_folio() and then migrate_huge_page_move_mapping(), which copies the source folio into the new folio. That copy uses folio_mc_copy(), so architectures with recoverable machine-check copy support can fail the copy with -EHWPOISON. However, there is no reason to attempt the move once the source folio is already known to contain poisoned memory. Architectures without such copy_mc support also fall back to a normal copy, which can consume the poison. Check folio_contain_hwpoisoned_page() after locking the source hugetlb folio and fail the migration with -EHWPOISON before unmapping or copying it. This covers both a hwpoisoned hugetlb head folio and large folios that only have the has_hwpoisoned summary flag set. Fixes: 290408d4a250 ("hugetlb: hugepage migration core") Signed-off-by: Kaitao Cheng --- mm/migrate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/migrate.c b/mm/migrate.c index 49e10feeb094..ac12e9aeb05f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1510,6 +1510,11 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio, goto out_unlock; } + if (unlikely(folio_contain_hwpoisoned_page(src))) { + rc = -EHWPOISON; + goto out_unlock; + } + if (folio_test_anon(src)) anon_vma = folio_get_anon_vma(src); -- 2.43.0