D128 reduces the number of descriptors in each translation table, causing some VA size and page granule combinations that use two page table levels with D64 to now require three levels. For three-level page tables, the PUD level is folded while the PMD level remains a real translation level. Hence, PUD_SIZE represents a root-level span. With D128, some configurations have a KASAN shadow region smaller than this span, making it impossible for both KASAN shadow boundaries to satisfy the existing PUD_SIZE alignment requirement. The KASAN initialization code on arm64 already supports shadow boundaries which are not root-level aligned, by installing or cloning the next-level table as required. Similarly for three level D128 page tables, relax SHADOW_ALIGN to PMD_SIZE, which corresponds to the first non-folded level below the root level. Keep the existing alignment requirements unchanged for all other configurations. Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: kasan-dev@googlegroups.com Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/mm/kasan_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index f61f5bc09467..e12abea6ad15 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -178,7 +178,9 @@ static void __init kasan_pgd_populate(unsigned long addr, unsigned long end, } while (pgdp++, addr = next, addr != end); } -#if defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS > 4 +#if defined(CONFIG_ARM64_D128) && CONFIG_PGTABLE_LEVELS == 3 +#define SHADOW_ALIGN PMD_SIZE +#elif defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS > 4 #define SHADOW_ALIGN P4D_SIZE #else #define SHADOW_ALIGN PUD_SIZE -- 2.43.0