Skip to contentSkip to conversation

arm64-make-huge_ptep_get-handled-unaligned-addresses.patch removed from -mm tree

merged Andrew Morton 1 participant 1 message Jul 28 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: arm64: make huge_ptep_get handled unaligned addresses
has been removed from the -mm tree. Its filename was
arm64-make-huge_ptep_get-handled-unaligned-addresses.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Dev Jain <[email protected]>
Subject: arm64: make huge_ptep_get handled unaligned addresses
Date: Fri, 3 Jul 2026 11:41:54 +0000

Patch series "Fix incorrect access of hugetlb pte entries", v3.

There are various places which use ptep_get() to get the pte entry corresponding to a hugetlb folio. Some arches (like s390) have special handling to compute the pteval, so they provide huge_ptep_get(). Use this helper consistently.

Additionally, some code paths may provide huge_ptep_get with an unaligned address. This is a problem on arm64 (I checked other arches and it looks fine for them), which is fixed in patch 1. The fix is made to be
backport-friendly: the cleaner fix would be to perhaps pass the hstate to huge_ptep_get() - that is wider churn and we can do that later.

This patch (of 6):

huge_ptep_get() can be handed a virtual address pointing to the middle of a contpmd/contpte mapped hugetlb folio (examples of callers are pagemap_hugetlb_range, page_mapped_in_vma).

The arm64 helper rewalks the pgtables in find_num_contig to answer whether the huge pte we have maps a contpmd or a contpte hugetlb folio, and returns CONT_PMDS or CONT_PTES, so that it can collect a/d bits over the contiguous ptes. We can falsely return CONT_PTES instead of CONT_PMDS if the addr is not aligned.

THis mean that on systems where CONT_PTES != CONT_PMDS (meaning page size is 16K) we could collect excess a/d bit state, meaning extra work for the kernel.

Fix this by aligning the pmdp pointer down to a contpmd base before checking equality with the passed huge pte pointer, to correctly answer whether the huge pte is the base of a contpmd block.

Fixes 29cb80519689 ("arm64: hugetlb: Cleanup huge_pte size discovery mechanisms")
Cc Alistair Popple <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Anshuman Khandual <[email protected]>
Cc Byungchul Park <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Gregory Price <[email protected]>
Cc Harry Yoo <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Jann Horn <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Joshua Hahn <[email protected]>
Cc Jun'ichi "Nick" Nomura <[email protected]>
Cc Kiryl Shutsemau <[email protected]>
Cc Lance Yang <[email protected]>
Cc Liam R. Howlett <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Naoya Horiguchi <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Pedro Falcato <[email protected]>
Cc Rakie Kim <[email protected]>
Cc Ralph Campbell <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Will Deacon <[email protected]>
Cc Zi Yan <[email protected]>

---

 arch/arm64/mm/hugetlbpage.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/mm/hugetlbpage.c renamed from arch/arm64/mm/hugetlbpage.c~arm64-make-huge_ptep_get-handled-unaligned-addresses +1 -1
@@ -87,7 +87,7 @@ static int find_num_contig(struct mm_str
 	p4dp = p4d_offset(pgdp, addr);
 	pudp = pud_offset(p4dp, addr);
 	pmdp = pmd_offset(pudp, addr);
-	if ((pte_t *)pmdp == ptep) {
+	if ((pte_t *)PTR_ALIGN_DOWN(pmdp, sizeof(*pmdp) * CONT_PMDS) == ptep) {
 		*pgsize = PMD_SIZE;
 		return CONT_PMDS;
 	}

_

Patches currently in -mm which might be from [email protected] are

mm-swap-rename-subpage-page-in-folio_dup_swap-folio_put_swap.patch mm-mprotect-drop-sub-from-batching-context.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 mm-rmap-convert-page-folio-for-hwpoison-checks.patch mm-rmap-add-try_to_unmap_hugetlb_one.patch mm-rmap-refactor-some-code-around-lazyfree-folio-unmapping.patch mm-rmap-refactor-anon-folio-unmap-in-try_to_unmap_one.patch mm-rmap-add-anon-folio-unmap-dispatcher.patch mm-memory-move-pte_install_uffd_wp_if_needed-into-memoryc.patch mm-memory-batch-set-uffd-wp-markers-during-zapping.patch mm-rmap-batch-unmap-file-folios-belonging-to-uffd-wp-vmas.patch