Re: [REGRESSION] x86/hugetlb: AMD F15h VA alignment offset breaks MAP_HUGETLB alignment

From: Oscar Salvador (SUSE)

Date: Wed May 27 2026 - 14:30:40 EST


On Wed, May 27, 2026 at 05:53:06PM +0200, Oscar Salvador (SUSE) wrote:
> On Wed, May 27, 2026 at 04:36:43PM +0200, Karsten Desler wrote:
> >
> > For hugetlb, get_align_mask(filp) correctly returns the hugepage alignment
> > mask, but get_align_bits() can still return the AMD F15h per-boot offset,
> > e.g. 0x4000. That produces a non-hugepage-aligned hugetlb VMA.
> >
> > Likely introduced by the v6.13-rc1 series:
> >
> > 1317a5e7f7b1 arch/x86: teach arch_get_unmapped_area_vmflags to handle hugetlb mappings
> > 7bd3f1e1a9ae mm: make hugetlb mappings go through mm_get_unmapped_area_vmflags
> > cc92882ee218 mm: drop hugetlb_get_unmapped_area{_*} functions
>
> Yes, that was part of a refactoring I did some time ago.
>
> I will fix it up later today/early tomorrow.
>
> Would you be available for a quick test once I have the patch?

Maybe this? Can you give it a shot?

diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index 776ae6fa7f2d..60f876dce8e5 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -157,7 +157,12 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len,
}
if (filp) {
info.align_mask = get_align_mask(filp);
- info.align_offset += get_align_bits();
+ /*
+ * Hugepages must remain hugepage-aligned, so skip adding an offset
+ * in case we enabled 'align_va_addr'.
+ */
+ if (!is_file_hugepages(filp))
+ info.align_offset += get_align_bits();
}

return vm_unmapped_area(&info);
@@ -222,7 +227,12 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0,

if (filp) {
info.align_mask = get_align_mask(filp);
- info.align_offset += get_align_bits();
+ /*
+ * Hugepages must remain hugepage-aligned, so skip adding an offset
+ * in case we enabled 'align_va_addr'.
+ */
+ if (!is_file_hugepages(filp))
+ info.align_offset += get_align_bits();
}
addr = vm_unmapped_area(&info);
if (!(addr & ~PAGE_MASK))



--
Oscar Salvador
SUSE Labs