arm64: pgtable: Decouple PGDIR size macros from PGD/PUD/PMD levels
authorArd Biesheuvel <ardb@kernel.org>
Wed, 14 Feb 2024 12:29:06 +0000 (13:29 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 16 Feb 2024 12:42:34 +0000 (12:42 +0000)
commit34b98e55f6840cab938d480968c0f600a2ed97d5
tree45b32dc1635156bb8aabaad714e05d9313a6bc08
parente6128a8e523cfa8f46a1501e6432c37523b47bdf
arm64: pgtable: Decouple PGDIR size macros from PGD/PUD/PMD levels

The mapping from PGD/PUD/PMD to levels and shifts is very confusing,
given that, due to folding, the shifts may be equal for different
levels, if the macros are even #define'd to begin with.

In a subsequent patch, we will modify the ID mapping code to decouple
the number of levels from the kernel's view of how these types are
folded, so prepare for this by reformulating the macros without the use
of these types.

Instead, use SWAPPER_BLOCK_SHIFT as the base quantity, and derive it
from either PAGE_SHIFT or PMD_SHIFT, which -if defined at all- are
defined unambiguously for a given page size, regardless of the number of
configured levels.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20240214122845.2033971-65-ardb+git@google.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/kernel-pgtable.h