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 DA98747D470 for ; Fri, 31 Jul 2026 23:59:37 +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=1785542378; cv=none; b=hskdcxTmMJyMvKBOnnPbC1TAm6XRUV5wLsMm0ShsyEFYDsqUjGBL1IsfztioTRfW5H1VfeuCXjF71RfYNmvLUcFgkQFOezFX20gJkxHLWU2dO9+CZ+4YAZWLYC6EP0aC+JduFkFZ9Zrcrt/VCAxlsA4Kh1QZqJf1VlyhhHC0zNY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785542378; c=relaxed/simple; bh=rGn+GggftE6E1oxCP7d0KjedcN6vAV8VFXF27tI3T9g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NEeaSTfbWGgZdC5Si/O8zJ9U/syP6CnButrKA6Ejra8gjGoJnSjfxn+kDJNsbqBieUxoZNgKC/mserMoHAbPZcBOJSXEXbS92giPL9tQFb6SXfdoHEPT/v8x770F1Jx+9yTcbDGeXgd6mmoGgrrx4pb9QsTAWY2MiY7UIp/NVbA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UKlE9Vcx; 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="UKlE9Vcx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 943BA1F00AC4; Fri, 31 Jul 2026 23:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785542377; bh=XA1kKM3E+TpKdyNI13D9hg7MTBUHQOPfee6xIaIE/BI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=UKlE9Vcx+ibmwZLg8uTgDhwFr1MQKvh4COZdEA29Zk4+a0WEHLRHV+s0GW3A7iSHe 3HD4/3g/v7nfvJumkgVcBV6bvBu1SfB7gaIyD4dF2MbygEzfAackvuElPeKYN09ozI vNr2sH/bIqJTIJ/1Sh8QjXQC23L52Z4YVCtA2hQVxOb8dltXl6qMLWG7NCwcIO0/qd Cd1Or+kj2bGVCdnHe9tbzDuwafP4AW8GXLqzKcY9q8OjsvcroCAcjGJeEecCteY5vk 2NzvhxfvKva7KE8T2F6nN/SVnRI+4YH8G/vz9LxdcQS01ioUBR5erT0qJtsRngShCP EDSvUcG27ePBg== Date: Fri, 31 Jul 2026 23:59:35 +0000 From: Yosry Ahmed To: Brendan Jackman Cc: Borislav Petkov , Dave Hansen , Peter Zijlstra , Andrew Morton , David Hildenbrand , Vlastimil Babka , Mike Rapoport , Wei Xu , Johannes Weiner , Zi Yan , Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, Sumit Garg , Will Deacon , rientjes@google.com, "Kalyazin, Nikita" , patrick.roy@linux.dev, "Itazuri, Takahiro" , Andy Lutomirski , David Kaplan , Thomas Gleixner , Patrick Bellasi , Reiji Watanabe , Sean Christopherson Subject: Re: [PATCH v3 05/26] x86: move PAE PMD preallocation defines to header Message-ID: References: <20260726-page_alloc-unmapped-v3-0-6f5729aa9832@google.com> <20260726-page_alloc-unmapped-v3-5-6f5729aa9832@google.com> 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: <20260726-page_alloc-unmapped-v3-5-6f5729aa9832@google.com> On Sun, Jul 26, 2026 at 10:22:38PM +0000, Brendan Jackman wrote: > In a subsequent patch these defines will need to be referenced from a new > file, move them as a separate patch for easy review. > > The comments have style violations (personal pronouns etc), do not fix > them as this is just code movement. > > No functional change intended. > > Signed-off-by: Brendan Jackman AFAICT, this is only needed to expose PREALLOCATED_PMDS for mm_local_map_to_user() in patch #7. The only usage is a BUILD_BUG_ON(). I wonder if it would be more preferrable to keep the definitions in pgtable.c and add a runtime check instead in mm_local_map_to_user(), something like: diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 09b8d8e6a56ea..15055cb80092c 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -268,7 +268,6 @@ static inline pmd_t *pgd_to_pmd_walk(pgd_t *pgd, unsigned long va) static inline int mm_local_map_to_user(struct mm_struct *mm) { - BUILD_BUG_ON(!PREALLOCATED_PMDS); pgd_t *k_pgd = pgd_offset(mm, MM_LOCAL_BASE_ADDR); pgd_t *u_pgd = kernel_to_user_pgdp(k_pgd); pmd_t *k_pmd, *u_pmd; @@ -277,6 +276,9 @@ static inline int mm_local_map_to_user(struct mm_struct *mm) k_pmd = pgd_to_pmd_walk(k_pgd, MM_LOCAL_BASE_ADDR); u_pmd = pgd_to_pmd_walk(u_pgd, MM_LOCAL_BASE_ADDR); + if (WARN_ON_ONCE(!k_pmd || !u_pmd)) + return -EINVAL; + BUILD_BUG_ON(MM_LOCAL_END_ADDR - MM_LOCAL_BASE_ADDR > PMD_SIZE); /* Preallocate the PTE table so it can be shared. */