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 1039737C112 for ; Wed, 27 May 2026 18:28:42 +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=1779906524; cv=none; b=Ard36twUskvi/pFcpZh0trFt3zopGl/Vc2XBK5TFRkVQmWAEiR3JLBpff1i0JvEPozU80vnuIZbWvWV9b3wYcz+nIDUH2wdXhcITrfwrBqApHAQeqvOEqAITRdT2Ldi6fYBigaePWGZRYFZxZ5U2LmPepL2sbv0raHT3oUGJGSs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779906524; c=relaxed/simple; bh=xN5OCrNmctT7FMfC05kEdM9lSU+8Z2extkkZ7eFtT0E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LceqX6d4eQ/yu5LTHejRuQ3fFxQ+GXw/HdmUIAq3KWidTNMqT+22Y4QGn0ZvWZ4OHwSCPDUewrFnCSh7+41kJzFouDgkz19+lj77A3nfuOdEW+vL5ngwvTqEe2MWePK+FRPf9BC5PCfVRryOLLGVjwL0KyVlsRf6W1o4BERDDFg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kkJ+CqYY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kkJ+CqYY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A3E51F000E9; Wed, 27 May 2026 18:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779906522; bh=+UBPRqt5aK8NgfUALvrYrTLfLGbcXXtkVRVkSHYLKXE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=kkJ+CqYYC3TjrIVm1bSP+yy6GdPJQKO7KEbDC7tXSg+EjBtPWle0vDTd3Si4yjY77 yRu8daKMjU4UKJ2U9zws8q2x144wJBEZChmEBZDwzC2vDaMZ97bf3YjL3ATRdcLrEC 49VIBhDs2OnX1bbQnE0Sr77EjRWdUXOQY2SWvyvIZ9v+v+ypv60mF7if+49q8GzTB4 5GMvXucJ33tVFMv+ytYkvRkHzdYRxZiMNY5/UiB2oC3EP3c6HvQoPBQIuM/mXqlAbg cMi2T7MWnXYTFT2XR+z9pRhHxDJCUb3DFgvHvch2KTCsDr7QCnCKecHCWtAYgS7uaS +NzC4lFFqR43A== Date: Wed, 27 May 2026 20:28:36 +0200 From: "Oscar Salvador (SUSE)" To: Karsten Desler Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: Re: [REGRESSION] x86/hugetlb: AMD F15h VA alignment offset breaks MAP_HUGETLB alignment Message-ID: References: <20260527143643.GO31091@soohrt.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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