From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EDD8835AC32 for ; Sun, 5 Jul 2026 07:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783237549; cv=none; b=GHXjhMoXN7+PhsCQ3WVrtEPGhkb3F1WxDC29Q1OdsybXngEwBFBZTyruBi2j04DjHb0pO0hSahxj4nwn8ch0kYj6YuiXZDxcVhqQuAQjIIc8goAa8d3cgzYPrcuK3QEk8I3Dvj7kKOaBVJkPAyGoi6xY/Vsvui6goQZLt1cf4E4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783237549; c=relaxed/simple; bh=YzJ4NTwRBSR0fc3PlHVncko3XHU59yxUtNc03i3YzfM=; h=Date:To:From:Subject:Message-Id; b=u7E9mWLcF2VEU/229lWPjJUfJCHbgXK4DpuIN8SJ6onvl3UKiZMt1upXfoV7P6a6QoYMziTyPJRVzZRfvwZTrLHa32KzUoogweipWkACLNPti0IGuJsiDS5BsEIrKoIZOvsBV8umpdts7ircMgZQ9UDwSQUehfNJXg0kV3KikjA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=vWlTa93D; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="vWlTa93D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11DCC1F00A3D; Sun, 5 Jul 2026 07:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1783237541; bh=ivpEBMkqFtaHFEACTy53H0eNT0LCpXY7BH3dqY78yQY=; h=Date:To:From:Subject; b=vWlTa93D/nkpM422fuZ5uAM34RppwjcKXp5Lz60dRo/uf5DnV6xArwmJ0rr+bAl55 nfNLIlChTn/cs+nWDCgzyb/hDIRCof0+4rv7kHDX8wulBTMNEFoaoqSkZJb3Y0ix2t TNmN0gOCp9XIcFTe357GJAkXloVcorVGOUByQDI4= Date: Sun, 05 Jul 2026 00:45:40 -0700 To: mm-commits@vger.kernel.org,dev.jain@arm.com,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-rmap-use-huge_ptep_get-in-try_to_migrate_one.patch added to mm-new branch Message-Id: <20260705074541.11DCC1F00A3D@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm/rmap: use huge_ptep_get() in try_to_migrate_one() has been added to the -mm mm-new branch. Its filename is mm-rmap-use-huge_ptep_get-in-try_to_migrate_one.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-rmap-use-huge_ptep_get-in-try_to_migrate_one.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Dev Jain Subject: mm/rmap: use huge_ptep_get() in try_to_migrate_one() Date: Fri, 3 Jul 2026 11:41:56 +0000 try_to_migrate_one() is used by folio migration to replace a present mapping with a migration entry. For hugetlb folios, page_vma_mapped_walk() returns the pte pointer to the hugetlb folio in pvmw.pte, but the code reads the huge pte entry with ptep_get(). On arches which provide their own huge_ptep_get() to dereference a huge pte pointer, accessing via ptep_get() would cause pte_pfn(), pte_present() etc to misbehave. It is not clear whether this has a trivially visible effect to userspace. Use huge_ptep_get() to dereference a huge pte pointer. Commit a98a2f0c8ce1 copied the bug from try_to_unmap_one into try_to_migrate_one. Link: https://lore.kernel.org/20260703114202.365553-4-dev.jain@arm.com Fixes: a98a2f0c8ce1 ("mm/rmap: split migration into its own function") Signed-off-by: Dev Jain Acked-by: Muchun Song Cc: Alistair Popple Cc: Andi Kleen Cc: Anshuman Khandual Cc: Byungchul Park Cc: Catalin Marinas Cc: Dave Hansen Cc: David Hildenbrand (Arm) Cc: Gregory Price Cc: Harry Yoo Cc: "Huang, Ying" Cc: Jann Horn Cc: Josh Poimboeuf Cc: Joshua Hahn Cc: Jun'ichi "Nick" Nomura Cc: Kiryl Shutsemau Cc: Lance Yang Cc: Liam R. Howlett Cc: Lorenzo Stoakes Cc: Matthew Brost Cc: Mel Gorman Cc: Naoya Horiguchi Cc: Oscar Salvador Cc: Pedro Falcato Cc: Rakie Kim Cc: Ralph Campbell Cc: Rik van Riel Cc: Ryan Roberts Cc: Vlastimil Babka Cc: Will Deacon Cc: Zi Yan Cc: Signed-off-by: Andrew Morton --- mm/rmap.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/mm/rmap.c~mm-rmap-use-huge_ptep_get-in-try_to_migrate_one +++ a/mm/rmap.c @@ -2500,14 +2500,19 @@ static bool try_to_migrate_one(struct fo /* Unexpected PMD-mapped THP? */ VM_BUG_ON_FOLIO(!pvmw.pte, folio); - /* - * Handle PFN swap PTEs, such as device-exclusive ones, that - * actually map pages. - */ - pteval = ptep_get(pvmw.pte); + address = pvmw.address; + if (folio_test_hugetlb(folio)) { + pteval = huge_ptep_get(mm, address, pvmw.pte); + } else { + pteval = ptep_get(pvmw.pte); + } if (likely(pte_present(pteval))) { pfn = pte_pfn(pteval); } else { + /* + * Handle PFN swap PTEs, such as device-exclusive ones, + * that actually map pages. + */ const softleaf_t entry = softleaf_from_pte(pteval); pfn = softleaf_to_pfn(entry); @@ -2515,7 +2520,6 @@ static bool try_to_migrate_one(struct fo } subpage = folio_page(folio, pfn - folio_pfn(folio)); - address = pvmw.address; anon_exclusive = folio_test_anon(folio) && PageAnonExclusive(subpage); _ Patches currently in -mm which might be from dev.jain@arm.com are mm-swap-rename-subpage-page-in-folio_dup_swap-folio_put_swap.patch mm-mprotect-drop-sub-from-batching-context.patch arm64-make-huge_ptep_get-handled-unaligned-addresses.patch mm-rmap-use-huge_ptep_get-in-try_to_unmap_one.patch mm-rmap-use-huge_ptep_get-in-try_to_migrate_one.patch mm-migrate-use-huge_ptep_get-in-remove_migration_pte.patch mm-page_vma_mapped-use-huge_ptep_get-for-hugetlb.patch mm-mprotect-use-huge_ptep_get-for-hugetlb.patch