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 EE78D2FFDEA for ; Sun, 5 Jul 2026 07:45:37 +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=1783237542; cv=none; b=LYfutaubyD57hVENCLzDUHFt6aDOo51B9LKRD1xpge9asOgFN8zc2bz8zmMXL1rgUWyJhY9UzRGzghwvdRWM9qszxGgOTPKYRF3g9vzM8nmciNtYv9SWc6th3PHgYlAocdn+fHNwMgNjEnmG6nbp/629snV70KEaoQANgfFIIJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783237542; c=relaxed/simple; bh=v14VHmq9Zc3e6ngomxELR/YIT5aEWFnyWrcO5Bk0bp0=; h=Date:To:From:Subject:Message-Id; b=BN6/8VuxXxuDm2Hj/o/p5CgDtMRze4iB+WtM4/jrqiHXK8GeHGzMXNO60zxy6mnKKsEtSrqzRtKUXkIZOTHZBrLCOKw5u3Sfc/Xy8bm3WKLH1eFbKxTuVZfZgT9i4ctogomEpaNj0XHta2yursM34gidgBy3QmOV+ji+4mJQYKY= 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=VfI81oFs; 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="VfI81oFs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0CE41F00A3A; Sun, 5 Jul 2026 07:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1783237535; bh=phvb2et3DUt/JksoRtoFnC0bDxgdMzBvRYgEicJ9C2Q=; h=Date:To:From:Subject; b=VfI81oFs1FSaWlX+ICFLcTR51WUtI5cI522uSVtTZRIhHSwwCIgAwynGNqEqqJMso D/hiSq4+NjGwzTVi8EXOjmYT9dYYmkpHTc/pGmsAFbyS+JPAj7saBSfd+Hn+UwtgDf 2zEZdCNSbh0kPWcUoZ5gccrSH96uDKOtrQdqwxlA= Date: Sun, 05 Jul 2026 00:45:35 -0700 To: mm-commits@vger.kernel.org,dev.jain@arm.com,akpm@linux-foundation.org From: Andrew Morton Subject: + arm64-make-huge_ptep_get-handled-unaligned-addresses.patch added to mm-new branch Message-Id: <20260705074535.D0CE41F00A3A@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: arm64: make huge_ptep_get handled unaligned addresses has been added to the -mm mm-new branch. Its filename is arm64-make-huge_ptep_get-handled-unaligned-addresses.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/arm64-make-huge_ptep_get-handled-unaligned-addresses.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: 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. 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. Link: https://lore.kernel.org/20260703114202.365553-1-dev.jain@arm.com Link: https://lore.kernel.org/20260703114202.365553-2-dev.jain@arm.com Fixes: 29cb80519689 ("arm64: hugetlb: Cleanup huge_pte size discovery mechanisms") Signed-off-by: Dev Jain Acked-by: David Hildenbrand (Arm) Acked-by: Muchun Song Cc: Alistair Popple Cc: Andi Kleen Cc: Anshuman Khandual Cc: Byungchul Park Cc: Catalin Marinas Cc: Dave Hansen 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 --- arch/arm64/mm/hugetlbpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/arm64/mm/hugetlbpage.c~arm64-make-huge_ptep_get-handled-unaligned-addresses +++ a/arch/arm64/mm/hugetlbpage.c @@ -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 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