Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: Fix 5-level paging support in kexec/hibernate trampoline

Add the missing code to allocate P4D level page tables when cloning the
the kernel page tables. This fixes a crash that may be observed when
attempting to resume from hibernation on an LPA2 capable system with 4k
pages, which therefore uses 5 levels of paging.

Presumably, kexec is equally affected.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250110175145.785702-2-ardb+git@google.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Ard Biesheuvel and committed by
Will Deacon
3648027d 2014c95a

+7
+7
arch/arm64/mm/trans_pgd.c
··· 162 162 unsigned long next; 163 163 unsigned long addr = start; 164 164 165 + if (pgd_none(READ_ONCE(*dst_pgdp))) { 166 + dst_p4dp = trans_alloc(info); 167 + if (!dst_p4dp) 168 + return -ENOMEM; 169 + pgd_populate(NULL, dst_pgdp, dst_p4dp); 170 + } 171 + 165 172 dst_p4dp = p4d_offset(dst_pgdp, start); 166 173 src_p4dp = p4d_offset(src_pgdp, start); 167 174 do {