public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 0/8] x86/kexec: Add exception handling for relocate_kernel
@ 2025-03-12 14:34 David Woodhouse
  2025-03-12 14:34 ` [PATCH v7 1/8] x86/kexec: Debugging support: load a GDT David Woodhouse
                   ` (8 more replies)
  0 siblings, 9 replies; 38+ messages in thread
From: David Woodhouse @ 2025-03-12 14:34 UTC (permalink / raw)
  To: kexec
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H . Peter Anvin, David Woodhouse, Kirill A . Shutemov, Kai Huang,
	Nikolay Borisov, linux-kernel, Simon Horman, Dave Young,
	Peter Zijlstra, jpoimboe, bsz

Debugging kexec failures is painful, as anything going wrong in execution
of the critical relocate_kernel() function tends to just lead to a triple
fault. Thus leading to *weeks* of my life that I won't get back. Having
hacked something up for my own use, I figured I should share it...

Add a trivial exception handler in the relocate_kernel environment which 
outputs to the early_printk serial console if configured. Currently only 
8250-compatible serial ports are supported, but that could be extended.

I had to hack up QEMU support for a PCI serial port which matches what
the existing early_printk code can drive, and the *real* 8250_pci driver
doesn't seem to cope with that setup at all, but whatever... the kexec
code now drives the same 32-bit stride which is all that earlyprintk
supports. We can always add more later, if anyone cares.

Someone who cares might want to bring the i386 version into line with
this, although the lack of rip-based addressing makes all the PIC code a
bit harder.

David Woodhouse (8):
      x86/kexec: Debugging support: load a GDT
      x86/kexec: Debugging support: Load an IDT and basic exception entry points
      x86/kexec: Debugging support: Dump registers on exception
      x86/kexec: Add 8250 serial port output
      x86/kexec: Add 8250 MMIO serial port output
      x86/kexec: Invalidate GDT/IDT from relocate_kernel() instead of earlier
      [DO NOT MERGE] x86/kexec: Add int3 in kexec path for testing
      [DO NOT MERGE] x86/kexec: Add CFI type information to relocate_kernel()

 arch/x86/include/asm/kexec.h         |   7 ++
 arch/x86/kernel/early_printk.c       |   9 ++
 arch/x86/kernel/machine_kexec_64.c   |  50 ++++++--
 arch/x86/kernel/relocate_kernel_64.S | 254 +++++++++++++++++++++++++++++++++++++++-
 4 files changed, 308 insertions(+), 12 deletions(-)


v7:
 • Drop CONFIG_KEXEC_DEBUG and make it all unconditional in order to
   "throw regressions back into the face of whoever manages to introduce
   them" (Ingo, https://lore.kernel.org/kexec/Z7rwA-qVauX7lY8G@gmail.com/)
 • Move IDT invalidation into relocate_kernel() itself.

v6: https://lore.kernel.org/kexec/20250115191423.587774-1-dwmw2@infradead.org/
 • Rebase onto already-merged fixes in tip/x86/boot.
 • Move CONFIG_KEXEC_DEBUG to generic kernel/Kconfig.kexec as Bartosz is
   working on an Arm64 version.

v5: https://lore.kernel.org/kexec/20241205153343.3275139-1-dwmw2@infradead.org/T/
 • Drop [RFC].
 • Drop _PAGE_NOPTISHADOW fix, which Ingo already took into tip/x86/urgent.
 • Add memory-mapped serial port support (32-bit MMIO spacing only).

v4 (RFC): https://lore.kernel.org/kexec/20241127190343.44916-1-dwmw2@infradead.org/T/
 • Add _PAGE_NOPTISHADOW fix for the identmap code.
 • Drop explicit map of control page, which was masking the identmap bug.

v3 (RFC): https://lore.kernel.org/kexec/20241125100815.2512-1-dwmw2@infradead.org/T/
 • Add CONFIG_KEXEC_DEBUG option and use earlyprintk config.
 • Allocate PGD separately from control page.
 • Explicitly map control page into identmap.

V2 (RFC): https://lore.kernel.org/kexec/20241122224715.171751-1-dwmw2@infradead.org/T/
 • Introduce linker script, start to clean up data access.

V1 (RFC): https://lore.kernel.org/kexec/20241103054019.3795299-1-dwmw2@infradead.org/T/
 • Initial proof-of-concept hacks.


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

end of thread, other threads:[~2025-03-22 11:38 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-12 14:34 [PATCH v7 0/8] x86/kexec: Add exception handling for relocate_kernel David Woodhouse
2025-03-12 14:34 ` [PATCH v7 1/8] x86/kexec: Debugging support: load a GDT David Woodhouse
2025-03-13 10:42   ` [tip: x86/boot] x86/kexec: Add relocate_kernel() debugging support: Load " tip-bot2 for David Woodhouse
2025-03-14 10:16   ` tip-bot2 for David Woodhouse
2025-03-12 14:34 ` [PATCH v7 2/8] x86/kexec: Debugging support: Load an IDT and basic exception entry points David Woodhouse
2025-03-13 10:42   ` [tip: x86/boot] x86/kexec: Add relocate_kernel() debugging " tip-bot2 for David Woodhouse
2025-03-12 14:34 ` [PATCH v7 3/8] x86/kexec: Debugging support: Dump registers on exception David Woodhouse
2025-03-13 10:42   ` [tip: x86/boot] x86/kexec: Add relocate_kernel() debugging " tip-bot2 for David Woodhouse
2025-03-12 14:34 ` [PATCH v7 4/8] x86/kexec: Add 8250 serial port output David Woodhouse
2025-03-13 10:35   ` Ingo Molnar
2025-03-12 14:34 ` [PATCH v7 5/8] x86/kexec: Add 8250 MMIO " David Woodhouse
2025-03-12 14:34 ` [PATCH v7 6/8] x86/kexec: Invalidate GDT/IDT from relocate_kernel() instead of earlier David Woodhouse
2025-03-12 14:34 ` [PATCH v7 7/8] [DO NOT MERGE] x86/kexec: Add int3 in kexec path for testing David Woodhouse
2025-03-13 10:44   ` Ingo Molnar
2025-03-13 11:06     ` David Woodhouse
2025-03-13 17:06       ` Ingo Molnar
2025-03-13 18:38         ` David Woodhouse
2025-03-12 14:34 ` [PATCH v7 8/8] [DO NOT MERGE] x86/kexec: Add CFI type information to relocate_kernel() David Woodhouse
2025-03-14 16:07   ` Josh Poimboeuf
2025-03-14 17:23     ` David Woodhouse
2025-03-14 17:52       ` Josh Poimboeuf
2025-03-14 18:29         ` David Woodhouse
2025-03-17 12:40         ` David Woodhouse
2025-03-18  0:17           ` Josh Poimboeuf
2025-03-18  0:24             ` Josh Poimboeuf
2025-03-18 15:56               ` David Woodhouse
2025-03-18 17:14                 ` Josh Poimboeuf
2025-03-18 21:06                   ` David Woodhouse
2025-03-18 22:41                     ` Josh Poimboeuf
2025-03-19 13:04                       ` David Woodhouse
2025-03-19 15:47                         ` Josh Poimboeuf
2025-03-22 11:38                           ` David Woodhouse
2025-03-13 10:46 ` [PATCH v7 0/8] x86/kexec: Add exception handling for relocate_kernel Ingo Molnar
2025-03-13 10:54   ` Ingo Molnar
2025-03-13 19:58     ` David Woodhouse
2025-03-14  9:25       ` David Woodhouse
2025-03-14 10:21         ` Ingo Molnar
2025-03-14 10:37           ` David Woodhouse

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