[PATCH 3/8] arch/x86: Stop special-casing hugetlb mappings in arch_get_unmapped_area
From: Oscar Salvador
Date: Fri Jun 05 2026 - 23:53:02 EST
arch_get_unmapped_area* sets info.align_mask to make room for extra alignment,
so that is added on top of the length we request in unmapped_area{_topdown}.
hugetlb_get_unmapped_area() already adds this extra padding in the 'len'
parameter, and it also masks off the address it gets to properly align it to
the huge_page_size we are using.
So, stop special-casing hugetlb in arch_get_unmapped_area* functions.
Also, there is no need to worry about align_offset and start_gap because
the former will be masked off back in hugetlb_get_unmapped_area() and
the latter only applies to mappings created via vm_mmap_shadow_stack() which
do not involve hugetlb.
Signed-off-by: Oscar Salvador <osalvador@xxxxxxx>
---
arch/x86/kernel/sys_x86_64.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index 776ae6fa7f2d..1cf2dafd223b 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -18,7 +18,6 @@
#include <linux/random.h>
#include <linux/uaccess.h>
#include <linux/elf.h>
-#include <linux/hugetlb.h>
#include <asm/elf.h>
#include <asm/ia32.h>
@@ -28,8 +27,6 @@
*/
static unsigned long get_align_mask(struct file *filp)
{
- if (filp && 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())))
return 0;
@@ -151,10 +148,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len,
info.length = len;
info.low_limit = begin;
info.high_limit = end;
- if (!(filp && is_file_hugepages(filp))) {
- info.align_offset = pgoff << PAGE_SHIFT;
- info.start_gap = stack_guard_placement(vm_flags);
- }
+ info.align_offset = pgoff << PAGE_SHIFT;
+ info.start_gap = stack_guard_placement(vm_flags);
if (filp) {
info.align_mask = get_align_mask(filp);
info.align_offset += get_align_bits();
@@ -205,10 +200,8 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0,
info.low_limit = PAGE_SIZE;
info.high_limit = get_mmap_base(0);
- if (!(filp && is_file_hugepages(filp))) {
- info.start_gap = stack_guard_placement(vm_flags);
- info.align_offset = pgoff << PAGE_SHIFT;
- }
+ info.start_gap = stack_guard_placement(vm_flags);
+ info.align_offset = pgoff << PAGE_SHIFT;
/*
* If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area
--
2.35.3