From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 88E0126A082; Wed, 23 Apr 2025 15:18:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745421534; cv=none; b=lwSLWvrT6uaq7yI+6Y30Td+xrbh54iFMFVG2vu93sUBg58ggy1Uzzoa28ZOyI8tgvTa30VdF8Sxj5tmMMBVh2yFnxknSdGaRiD7prWUHGlyde9ElvdiHxXxuBIPzpCXIYU5dUoCh5ElU57Yi6/akDxj5yGRPNgAajjny4Dw2Sg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745421534; c=relaxed/simple; bh=KWmfyQPCUBIukcacwa5hofIQCuLTM3f2n9O3xtWp5aI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jtnjZzwkywKhaRmeJfoblNvekQ5VCV8pAKyfFld1LnfA+v0cpoUJ4lAzN/nF2DpVvCszvV/sGda5QIyxJIss8k7NHmuSWf8ZA3+ND/GpcbBWQWerigIsfXpWMxNBjnUdFH8QzfS3yEBBbqgvPUf3pmxVKvlfeR+A7qWSw0T2Xvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jk80Qf+p; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jk80Qf+p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF601C4CEE2; Wed, 23 Apr 2025 15:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745421534; bh=KWmfyQPCUBIukcacwa5hofIQCuLTM3f2n9O3xtWp5aI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jk80Qf+phG56wuia5m9Hk+/uTZHWea9nO6I+XgCe0bn+wB6XVEdbdSSsqlTbNE5ip 3/VDRPcwP2xNcRHaw4xaW1Vz6+dxcqx3UuVthPVdGLsGgGNxXM4T+HuAGMa7ECd5pA 2c20dXXfx+a3Q+O7nOtxaOZeDB+SUVWOzXZDlRYg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Hildenbrand , Alistair Popple , Alex Shi , Danilo Krummrich , Dave Airlie , Jann Horn , Jason Gunthorpe , Jerome Glisse , John Hubbard , Jonathan Corbet , Karol Herbst , Liam Howlett , Lorenzo Stoakes , Lyude , "Masami Hiramatsu (Google)" , Oleg Nesterov , Pasha Tatashin , Peter Xu , "Peter Zijlstra (Intel)" , SeongJae Park , Simona Vetter , Vlastimil Babka , Yanteng Si , Barry Song , Andrew Morton Subject: [PATCH 6.6 189/393] mm/rmap: reject hugetlb folios in folio_make_device_exclusive() Date: Wed, 23 Apr 2025 16:41:25 +0200 Message-ID: <20250423142651.192590549@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250423142643.246005366@linuxfoundation.org> References: <20250423142643.246005366@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Hildenbrand commit bc3fe6805cf09a25a086573a17d40e525208c5d8 upstream. Even though FOLL_SPLIT_PMD on hugetlb now always fails with -EOPNOTSUPP, let's add a safety net in case FOLL_SPLIT_PMD usage would ever be reworked. In particular, before commit 9cb28da54643 ("mm/gup: handle hugetlb in the generic follow_page_mask code"), GUP(FOLL_SPLIT_PMD) would just have returned a page. In particular, hugetlb folios that are not PMD-sized would never have been prone to FOLL_SPLIT_PMD. hugetlb folios can be anonymous, and page_make_device_exclusive_one() is not really prepared for handling them at all. So let's spell that out. Link: https://lkml.kernel.org/r/20250210193801.781278-3-david@redhat.com Fixes: b756a3b5e7ea ("mm: device exclusive memory access") Signed-off-by: David Hildenbrand Reviewed-by: Alistair Popple Tested-by: Alistair Popple Cc: Alex Shi Cc: Danilo Krummrich Cc: Dave Airlie Cc: Jann Horn Cc: Jason Gunthorpe Cc: Jerome Glisse Cc: John Hubbard Cc: Jonathan Corbet Cc: Karol Herbst Cc: Liam Howlett Cc: Lorenzo Stoakes Cc: Lyude Cc: "Masami Hiramatsu (Google)" Cc: Oleg Nesterov Cc: Pasha Tatashin Cc: Peter Xu Cc: Peter Zijlstra (Intel) Cc: SeongJae Park Cc: Simona Vetter Cc: Vlastimil Babka Cc: Yanteng Si Cc: Barry Song Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/rmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/rmap.c +++ b/mm/rmap.c @@ -2296,7 +2296,7 @@ static bool folio_make_device_exclusive( * Restrict to anonymous folios for now to avoid potential writeback * issues. */ - if (!folio_test_anon(folio)) + if (!folio_test_anon(folio) || folio_test_hugetlb(folio)) return false; rmap_walk(folio, &rwc);