Re: [PATCH v3 1/6] arm64: make huge_ptep_get handled unaligned addresses
From: Muchun Song <muchun.song@linux.dev>
Date: 2026-07-04 02:43:45
Also in:
linux-mm, lkml, stable
From: Muchun Song <muchun.song@linux.dev>
Date: 2026-07-04 02:43:45
Also in:
linux-mm, lkml, stable
On Jul 3, 2026, at 19:41, Dev Jain [off-list ref] wrote:
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.
Fixes: 29cb80519689 ("arm64: hugetlb: Cleanup huge_pte size discovery mechanisms")
Cc: stable@vger.kernel.org
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Dev Jain <dev.jain@arm.com>Acked-by: Muchun Song <muchun.song@linux.dev> Thanks.