public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] x86: Fix kexec 5-level to 4-level paging transition
@ 2025-10-22 22:06 Usama Arif
  2025-10-22 22:06 ` [PATCH 1/3] x86/boot: Fix page table access in " Usama Arif
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Usama Arif @ 2025-10-22 22:06 UTC (permalink / raw)
  To: dwmw, tglx, mingo, bp, dave.hansen, ardb, hpa
  Cc: x86, apopple, thuth, nik.borisov, kas, linux-kernel, linux-efi,
	kernel-team, Usama Arif, Michael van der Westhuizen, Tobias Fleig

This series addresses critical bugs in the kexec path when transitioning
from a kernel using 5-level page tables to one using 4-level page tables.

The root cause is improper handling of PGD entry value during the page level
transition. Specifically p4d value is masked with PAGE_MASK instead of
PTE_PFN_MASK, failing to account for high-order software bits like
_PAGE_BIT_NOPTISHADOW (bit 58).

When bit 58 (_PAGE_BIT_NOPTISHADOW) is set in the source kernel, the target
4-level kernel doesn't recognize it and fails to mask it properly, leading
to kexec failure.

This series fixes the issue in three parts:

Patch 1: Fixes the x86 boot compressed code path by replacing direct CR3
dereferencing with read_cr3_pa() and using PTE_PFN_MASK instead
of PAGE_MASK.

Patch 2: Applies the same fix to the EFI stub code path. (Done in a
separate patch as Fixes tag is different).

Patch 3: Moves _PAGE_BIT_NOPTISHADOW from bit 58 (_PAGE_BIT_SOFTW5) to
bit 9 (_PAGE_BIT_SOFTW1), which is already properly masked by
older kernels. This provides backward compatibility without
requiring patches 1 and 2 to be applied to all existing kernel versions,
which is not feasible for production systems or live patching.

Co-developed-by: Kiryl Shutsemau <kas@kernel.org>
Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
Reported-by: Michael van der Westhuizen <rmikey@meta.com>
Reported-by: Tobias Fleig <tfleig@meta.com>

The patches are based on aaa9c3550b60d6259d6ea8b1175ade8d1242444e (next-20251022)
 
Usama Arif (3):
  x86/boot: Fix page table access in 5-level to 4-level paging
    transition
  efi/libstub: Fix page table access in 5-level to 4-level paging
    transition
  x86/mm: Move _PAGE_BIT_NOPTISHADOW from bit 58 to bit 9

 arch/x86/boot/compressed/pgtable_64.c   | 8 +++++---
 arch/x86/include/asm/pgtable_types.h    | 4 ++--
 drivers/firmware/efi/libstub/x86-5lvl.c | 5 ++++-
 3 files changed, 11 insertions(+), 6 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-10-25 21:50 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 22:06 [PATCH 0/3] x86: Fix kexec 5-level to 4-level paging transition Usama Arif
2025-10-22 22:06 ` [PATCH 1/3] x86/boot: Fix page table access in " Usama Arif
2025-10-22 23:16   ` Dave Hansen
2025-10-22 23:49     ` Usama Arif
2025-10-25 21:50     ` H. Peter Anvin
2025-10-23 17:43   ` kernel test robot
2025-10-24  8:07   ` kernel test robot
2025-10-22 22:06 ` [PATCH 2/3] efi/libstub: " Usama Arif
2025-10-23 14:13   ` Ard Biesheuvel
2025-10-23 14:28     ` Kiryl Shutsemau
2025-10-22 22:06 ` [PATCH 3/3] x86/mm: Move _PAGE_BIT_NOPTISHADOW from bit 58 to bit 9 Usama Arif
2025-10-22 23:35   ` Dave Hansen
2025-10-22 23:58     ` Usama Arif
2025-10-23 14:05       ` Dave Hansen
2025-10-23 14:24         ` Kiryl Shutsemau
2025-10-23 15:12           ` Dave Hansen
2025-10-23 15:25             ` Kiryl Shutsemau
2025-10-23 22:15             ` Usama Arif
2025-10-22 22:25 ` [PATCH 0/3] x86: Fix kexec 5-level to 4-level paging transition Usama Arif

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox