From nobody Fri Apr 17 00:23:50 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEB50A932 for ; Wed, 25 Feb 2026 06:40:36 +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=1772001639; cv=none; b=gWNY3AjxbibzHdODmvXjJNEH84uETLomFHtf7hQQRe3BJlhXjsxDEkgIWF8cUX02QTkp31tYalJK61VAWgZYY9Hg345JYwfDC2g8mEibHWA9xImbTUpN+jpHp3Z68J3QweOa5FNv2CHcarnfsAUBYyhU6BCVmxN+f47hgaGdPbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772001639; c=relaxed/simple; bh=edV9+w+AFYhW4a7zYMR5pjhhZu6GBK8Tty+qKRY/Rcw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=EpuCZRoNFpTBRzmXHtpsEKIisvgT3Z+7Lz20bs7T3zaq1e9AVphiG1/7cU8MYGANZ/E0DUkxW0I+Ca7NVgTYFxL2qxzhc1/YMJskQx9ctDazbdbnQhVNdfbCnCkDe+AjqgyByajtI83+KWxP8zUWlerhWVq0Ya2eWj1HyW75eEo= 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 7A56B165C; Tue, 24 Feb 2026 22:40:29 -0800 (PST) Received: from ergosum.cambridge.arm.com (ergosum.cambridge.arm.com [10.1.196.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 78BD83F59E; Tue, 24 Feb 2026 22:40:34 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Mark Rutland , Ryan Roberts , linux-kernel@vger.kernel.org Subject: [PATCH] arm64/mm: Describe TTBR1_BADDR_4852_OFFSET Date: Wed, 25 Feb 2026 06:40:28 +0000 Message-Id: <20260225064028.1525192-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/ 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/as= m/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 =20 #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 =20 #endif --=20 2.30.2