Re: [PATCH] x86/mm: don't apply va_align to hugetlb mappings on AMD F15h

From: Laurent Wandrebeck

Date: Sat Sep 19 2026 - 05:25:22 EST


On Wed, 2026-09-16 at 13:02 -0700, Borislav Petkov wrote:
> On Tue, Sep 01, 2026 at 10:12:07AM +0200, Laurent Wandrebeck wrote:
> > Sorry about, replied from my phone without thinking about it.
>
> No worries.
>
> > FYI, patched kernel has run a couple more days without any problem, and
> > I’m now running 7.3-rc1 with the same patch flawlessly.
>
> ...
>  
> > Can I do anything else ?
>
> Does Dave's suggestion work too?
>
> https://lore.kernel.org/all/3faecf65-7edb-4cec-be7a-e5266dd3a649@xxxxxxxxx/
>
> Thx.
>

Here’s the « v2 » patch I used instead, on top of 7.3-rc3.
Works without problem (several hours uptime).
If this looks ok to you, I’ll follow up with a proper [PATCH v2] mail.
Thanks !

diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index 776ae6fa7f2d..a54f930e2c9a 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -28,7 +28,7 @@
*/
static unsigned long get_align_mask(struct file *filp)
{
- if (filp && is_file_hugepages(filp))
+ if (is_file_hugepages(filp))
return huge_page_mask_align(filp);
/* handle 32- and 64-bit case with a single conditional */
if (va_align.flags < 0 || !(va_align.flags & (2 - mmap_is_ia32())))
@@ -50,9 +50,13 @@ static unsigned long get_align_mask(struct file *filp)
* value before calling vm_unmapped_area() or ORed directly to the
* address.
*/
-static unsigned long get_align_bits(void)
+static unsigned long get_align_bits(struct file *filp)
{
- return va_align.bits & get_align_mask(NULL);
+ /* hugetlb mappings must stay on the huge page boundary. */
+ if (is_file_hugepages(filp))
+ return 0;
+
+ return va_align.bits & get_align_mask(filp);
}

static int __init control_va_addr_alignment(char *str)
@@ -157,7 +161,7 @@ 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();
+ info.align_offset += get_align_bits(filp);
}

return vm_unmapped_area(&info);
@@ -222,7 +226,7 @@ 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();
+ info.align_offset += get_align_bits(filp);
}
addr = vm_unmapped_area(&info);
if (!(addr & ~PAGE_MASK))

--
Laurent Wandrebeck <l.wandrebeck@xxxxxxxxxxxxxxx>