From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A5E0153BE9 for ; Thu, 8 Jan 2026 04:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767845048; cv=none; b=tbKEsy9/xLpZGd2lxK0aMec9A1L+8FtlI0L/tkXE2shxdSyqM0qRKI82IR8Vr7wgbrJnPYhxtfL8dQ9Gg9h9PcafaVcA6b1859PNqS+hndd4UfRDbgSIgkb83OVKHCQfUFcnJm3WasEYRbq5tjXTqoCtRIWJdASBjbP94/492CU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767845048; c=relaxed/simple; bh=XyTXmn/SU6nI471rsTEvibq3rjBxQDorDqz/5dOVavk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YZmuo0EiX8wY/6MJG7tVFQGVWv/8EbbebQZqA6d4letYUYt2KSD6zv++l99FwdrAKFnDUq7h5hlgi0W+IJiBsSOawoqG4FPx2KRAxCLpNvA1/ahUc1dtjx64tJY52epVoz3dFm+CVWchCzNw+jw8/fQKvUGpA3j/N367VehbC6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 558AA497; Wed, 7 Jan 2026 20:03:58 -0800 (PST) Received: from [10.163.83.134] (unknown [10.163.83.134]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 591B73F694; Wed, 7 Jan 2026 20:04:03 -0800 (PST) Message-ID: <4f2005ba-ff12-4ad9-bd4c-33cae87bdc78@arm.com> Date: Thu, 8 Jan 2026 09:34:00 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arm64/mm: Assert NR_BM_PUD_TABLES for bm_pud[] To: Mark Rutland Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org References: <20260107061606.3160088-1-anshuman.khandual@arm.com> <32030401-06d3-40ad-a0b6-fbd366092f2b@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 07/01/26 3:41 PM, Mark Rutland wrote: > On Wed, Jan 07, 2026 at 02:37:51PM +0530, Anshuman Khandual wrote: >> >> >> On 07/01/26 2:03 PM, Ryan Roberts wrote: >>> On 07/01/2026 06:16, Anshuman Khandual wrote: >>>> There is an implicit assumption about bm_pud[] being single entry PUD table >>>> just like bp_pmd[] which is a single entry PMD table. Though only the later >>>> gets asserted via NR_BM_PMD_TABLES. Hence let's add a similar check for PUD >>>> table as well. >>>> >>>> Cc: Catalin Marinas >>>> Cc: Will Deacon >>>> Cc: linux-arm-kernel@lists.infradead.org >>>> Cc: linux-kernel@vger.kernel.org >>>> Signed-off-by: Anshuman Khandual >>>> --- >>>> arch/arm64/mm/fixmap.c | 3 +++ >>>> 1 file changed, 3 insertions(+) >>>> >>>> diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c >>>> index c5c5425791da..e02594be8b8e 100644 >>>> --- a/arch/arm64/mm/fixmap.c >>>> +++ b/arch/arm64/mm/fixmap.c >>>> @@ -23,8 +23,11 @@ static_assert(FIXADDR_TOT_START > PCI_IO_END); >>>> SPAN_NR_ENTRIES(FIXADDR_TOT_START, FIXADDR_TOP, PMD_SHIFT) >>>> #define NR_BM_PMD_TABLES \ >>>> SPAN_NR_ENTRIES(FIXADDR_TOT_START, FIXADDR_TOP, PUD_SHIFT) >>>> +#define NR_BM_PUD_TABLES \ >>>> + SPAN_NR_ENTRIES(FIXADDR_TOT_START, FIXADDR_TOP, P4D_SHIFT) >>>> >>>> static_assert(NR_BM_PMD_TABLES == 1); >>>> +static_assert(NR_BM_PUD_TABLES == 1); >>> >>> But if there is only one PMD table, there must only be one PUD table (and one >>> P4D table, and one PGD table) by definition. So I don't think this is checking >>> anything that the existing PMD table check is not. >> >> Agreed but should not this check help tighten this code up given that bm_pud[] >> array gets used for possible PUD entries ? > > An assert isn't going to help with code generation, so this patch alone is not > useful. When I last looked at actually ommiting the table in various > configurations, it was more trouble than it was worth. > > As Ryan said, we deliberately only added the assert for the PMD level, > and it's sufficient as-is. That happened in commit: > > 414c109bdf49 ("arm64: mm: always map fixmap at page granularity") > > ... where the commit message said: > > Our VA layout means that the fixmap will always fall within a single PMD > table (and consequently, within a single PUD/P4D/PGD entry), which we > can verify at compile time with a static_assert(). With that assert a > number of runtime warnings become impossible, and are removed. > > Please leave this as-is. Alright, makes sense.