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 27CB637A481 for ; Thu, 26 Feb 2026 11:53:41 +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=1772106822; cv=none; b=p+8+hk+kRWkRslHK+3l6IwOzpozmuquUk57PPAKhK9Zw8mnw9X2AxB+Y79liIKZitOaVhM7o6IgrS43UzJ56gdNMVNiLwwzbnfOAtPTc2rHsoV/hkjZgRExh7adFgire/tSfNuZ8Ys05iCkczv9Qw+l+TKAhwsaLp/+5zE6QnAg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772106822; c=relaxed/simple; bh=3AXh4J2qTwflwJqrudgqMq6GBRiPOJZdIdpp6QGrsi4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HkI/QY+zc8KM3TncKZz1YkrXg+cFnj/MG2wwZO5SOWvxkLTzrGV2cfH84c4W0ZT1EKSv9WIVpjQQUWeVBf6WK+/x2EazxoDpejIDl2gFOPjZPWYknf8FvKQekm+f4SVYRAWuQMZz4shFAT2fvyroiyUJM3/orkKix5Pfp6fmL+4= 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 4D9441516; Thu, 26 Feb 2026 03:53:34 -0800 (PST) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 82DF23F62B; Thu, 26 Feb 2026 03:53:39 -0800 (PST) Date: Thu, 26 Feb 2026 11:53:37 +0000 From: Mark Rutland To: Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Ryan Roberts , linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64/mm: Describe TTBR1_BADDR_4852_OFFSET Message-ID: References: <20260225064028.1525192-1-anshuman.khandual@arm.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: <20260225064028.1525192-1-anshuman.khandual@arm.com> On Wed, Feb 25, 2026 at 06:40:28AM +0000, Anshuman Khandual wrote: > TTBR1_BADDR_4852_OFFSET is a constant offset which gets added into kernel > page table physical address for TTBR1_EL1 when kernel is build for 52 bit > VA but found to be running on 48 bit VA capable system. Although there is > no explanation on how the macro is computed. > > Describe TTBR1_BADDR_4852_OFFSET computation in detail via deriving from > all required parameters involved thus improving clarity and readability. > > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Rutland > Cc: Ryan Roberts > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual > --- > This applies on v7.0-rc1 > > Earlier context can be found here. > > https://lore.kernel.org/linux-arm-kernel/aRb8ezhQd0c0jp9G@J2N7QTR9R3/ As with my comments last time, I have no strong feelings on this either way; I'll leave it to Cataln and Will. Mark. > arch/arm64/include/asm/pgtable-hwdef.h | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h > index 5e6809a462c7..72f31800c703 100644 > --- a/arch/arm64/include/asm/pgtable-hwdef.h > +++ b/arch/arm64/include/asm/pgtable-hwdef.h > @@ -285,9 +285,12 @@ > #endif > > #ifdef CONFIG_ARM64_VA_BITS_52 > +#define PTRS_PER_PGD_52_VA (UL(1) << (52 - PGDIR_SHIFT)) > +#define PTRS_PER_PGD_48_VA (UL(1) << (48 - PGDIR_SHIFT)) > +#define PTRS_PER_PGD_EXTRA (PTRS_PER_PGD_52_VA - PTRS_PER_PGD_48_VA) > + > /* Must be at least 64-byte aligned to prevent corruption of the TTBR */ > -#define TTBR1_BADDR_4852_OFFSET (((UL(1) << (52 - PGDIR_SHIFT)) - \ > - (UL(1) << (48 - PGDIR_SHIFT))) * 8) > +#define TTBR1_BADDR_4852_OFFSET (PTRS_PER_PGD_EXTRA << PTDESC_ORDER) > #endif > > #endif > -- > 2.30.2 >