SlideShare a Scribd company logo
Pratyush Anand
kdump: usage and internals
CFP, #LinuxCon, Beijing, June 19-20, 2017
Pratyush Anand(panand@redhat.com)
Pratyush Anand
Agenda
● kdump from user perspective
● Kernel system calls
● When Kernel crashes…
● vmcore structure
● makedumpfile
● kdump: The Fedora way
● Debugging kdump issues
● What next
Pratyush Anand
kdump from user perspective
Pratyush Anand
Overview
First Kernel
Skips bios/firmware
reset stage and
boots to second kernel
kexec -l kernel.img --initrd=initramfs-image.img –reuse-cmdline
kexec -e
Primary Kernel
(Reserves memory
for crash kernel)
Boot to crash kernel
also known as
capture kernel
kexec -p kernel.img --initrd=initramfs-image.img –reuse-cmdline
Followed by kernel panic(echo c > /proc/sysrq-trigger)
Pratyush Anand
Different pieces
Linux Kernel (git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git)
kernel/kexec*
arch/…/kernel/machine_kexec*.c
Mailing list: kexec@lists.infradead.org
kexec_load(), kexec_file_load() and
reboot() system call
Arch specific code like
machine_kexec() and
machine_crash_shutdown() etc
kexec-tools
(git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git)
Mailing list: kexec@lists.infradead.org
Uses kernel system calls and
provides a user command `kexec`
Distribution code (like fedora kexec-tools)
(git://pkgs.fedoraproject.org/kexec-tools)
Mailing list: kexec@lists.fedoraproject.org
Specs file and scripts to provide user
friendly command/services so that
kexec-tools can be automated in
different user scenarios
makedumpfile
(git://git.code.sf.net/p/makedumpfile/code)
Mailing list: kexec@lists.infradead.org
Used to compress vmcore and erase
sensitive information from it
Pratyush Anand
Kdump : End to end Flow
crashkernel=Y@X
Perform sha256
verification for
all none-purgatory
segments
Copy vmcore to the
disk/network
Analyse vmcore
using
Crash-utility/gdb
Reboot to
sane(primary)
kernel
panic()
If purgatory
Loaded?
yes
no
Primary Kernel
(Reserves memory
for capture kernel)
Loads capture kernel/
Elfcorehdr/
Purgatory/
Initramfs etc
into reserved memory
Kexec -p
Switch to
capture kernel
Creates /proc/vmcore
as per elfcorehdr
information received
Pratyush Anand
Demo
https://www.youtube.com/watch?v=iOq_rJhrKhA
Pratyush Anand
Kernel system calls
Pratyush Anand
Kernel: kexec_load() (1)
• The kexec_load() system call loads a new kernel that can be
executed later by reboot()
• long kexec_load(unsigned long entry, unsigned long nr_segments,
struct kexec_segment *segments, unsigned long flags);
• User space need to pass segment for different components like
kernel, initramfs etc.
• struct kexec_segment {
void *buf; /* Buffer in user space */
size_t bufsz; /* Buffer length in user space */
void *mem; /* Physical address of kernel */
size_t memsz; /* Physical address length */
};
Pratyush Anand
Kernel: kexec_load() (2)
• reboot(LINUX_REBOOT_CMD_KEXEC);
• kexec_load() and above reboot() option is only available when kernel
was configured with CONFIG_KEXEC.
• Supported architecture:
• X86, X86_64, ppc64, ia64, S390x, arm, arm64
• KEXEC_ON_CRASH
• A flag which can be passed to kexec_load()
• Execute the new kernel automatically on a system crash.
• CONFIG_CRASH_DUMP should be configured
Pratyush Anand
Kernel: kexec_file_load()
• CONFIG_KEXEC_FILE should be enabled to use this system
call.
• It is an in-kernel way of segment preparation.
• long kexec_file_load(int kernel_fd, int initrd_fd, unsigned long
cmdline_len, const char __user * cmdline_ptr, unsigned long
flags);
• User space need to pass kernel and initramfs file descriptor.
• Only supported for x86 and powerpc
Pratyush Anand
When Kernel crashes...
Pratyush Anand
When Kernel crashes…..
• Update vmcoreinfo note (crash_save_vmcoreinfo())
• shutdown non-crashing cpus and save registers
(machine_crash_shutdown() & crash_save_cpu())
• Might need to disable interrupt controller here
• Perform kexec reboot now (machine_kexec())
• Load/flush kexec segments to memory
• Pass control to the execution of entry segment
Pratyush Anand
vmcore structure
Pratyush Anand
Elf Program Headers
• Most of the dump cores involved in kdump are in ELF format.
• Each elf file has a program header
• Which is read by the system loader
• Which describes how the program should be loaded into memory.
• `Objdump -p elf_file` can be used to look into program headers
Pratyush Anand
Elf Program Headers
# objdump -p vmcore
vmcore: file format elf64-littleaarch64
Program Header:
NOTE off 0x0000000000010000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**0 filesz
0x00000000000013e8 memsz 0x00000000000013e8 flags ---
LOAD off 0x0000000000020000 vaddr 0xffff000008080000 paddr 0x0000004000280000 align 2**0 filesz
0x0000000001460000 memsz 0x0000000001460000 flags rwx
LOAD off 0x0000000001480000 vaddr 0xffff800000200000 paddr 0x0000004000200000 align 2**0 filesz
0x000000007fc00000 memsz 0x000000007fc00000 flags rwx
LOAD off 0x0000000081080000 vaddr 0xffff8000ffe00000 paddr 0x00000040ffe00000 align 2**0 filesz
0x00000002fa7a0000 memsz 0x00000002fa7a0000 flags rwx
LOAD off 0x000000037b820000 vaddr 0xffff8003fa9e0000 paddr 0x00000043fa9e0000 align 2**0 filesz
0x0000000004fc0000 memsz 0x0000000004fc0000 flags rwx
LOAD off 0x00000003807e0000 vaddr 0xffff8003ff9b0000 paddr 0x00000043ff9b0000 align 2**0 filesz
0x0000000000010000 memsz 0x0000000000010000 flags rwx
LOAD off 0x00000003807f0000 vaddr 0xffff8003ff9f0000 paddr 0x00000043ff9f0000 align 2**0 filesz
0x0000000000610000 memsz 0x0000000000610000 flags rwx
private flags = 0:
Pratyush Anand
elfcorehdr
EHDR PHDR(CPUp0 PT_NOTE)
..
PHDR(CPUpn PT_NOTE)
PHDR
(vmcoreinfo PT_NOTE)
[optional]
PHDR
(Kernel Text PT_LOAD)
[optional]
PHDR(RAM0 PT_LOAD)
..
PHDR(RAMn PT_LOAD)
- Entry point virtual address
- Program header table file offset
- Section header table file offset
-Segment virtual address
-Segment size in memory
/sys/devices/system/cpu/cpu%d/crash_notes CPU PT_NOTE
/sys/kernel/vmcoreinfo vmcoreinfo
PT_NOTE
/proc/iomem Mem PT_LOAD
Pratyush Anand
Notes
• Crash notes
• A percpu area for storing cpu states in case of system crash
• Has information about current pid and cpu registers
• Vmcoreinfo
• This note section has various kernel debug information like
struct size, symbol values, page size etc.
• Vmcoreinfo is used mainly by makedumpfile application
• include/linux/kexec.h has macros to define a new vmcoreinfo
• VMCOREINFO_PAGESIZE()
• VMCOREINFO_SYMBOL()
• VMCOREINFO_SIZE()
Pratyush Anand
makedumpfile
Pratyush Anand
makedumpfile
• It compresses /proc/vmcore data
• Excludes unnecessary pages like:
• Pages filled with zero
• Cache pages without private flag (non-private cache)
• Cache pages with private flag (private cache)
• User process data pages
• Free pages
• Needs first kernel’s debug information to exclude unnecessary
pages
Pratyush Anand
makedumpfile
• Debug information comes from either VMLINUX or
VMCOREINFO
• Can also erase any specific sensitive kernel symbol
• Output can either be in ELF format or kdump-compressed format
• Typical usage:
• makedumpfile -l --message-level 1 -d 31 /proc/vmcore
makedumpfilecore
• -d to specify the type of unnecessary page for analysis.
• -l compression using lzo
• -c compression using zlib
• -p compression using snappy
Pratyush Anand
Kdump: The Fedora way
Pratyush Anand
Kdump: The Fedora way
• Start/stop/status kdump service:
• systemctl start kdump
• systemctl stop kdump
• systemctl status kdump
• Fedora has some scripts to take care of various use case
scenarios.
• Kdumpctl
• mkdumprd
• Configurations files:
• /etc/sysconfig/kdump:
• Initrd rebuild is not needed after any configuration change
• /etc/kdump.conf:
• Values which can affect initrd rebuild
Pratyush Anand
Debugging Kdump issues
Pratyush Anand
Debugging Kdump issues
• `Kexec -p kernel_image` did not succeed
• Check if crash memory is allocated
• cat /sys/kernel/kexec_crash_size
• Should have none zero value
• If not allocated, then pass proper “crashkernel=” argument
in command line
• If nothing shows up then pass -d in the kexec command
and share debug output with kexec mailing list.
Pratyush Anand
Debugging Kdump issues
• Do not see anything on console after last message from first
kernel (like “bye”):
• Might have second kernel crashed very early
• Pass some earlycon/earlyprintk option for your system to
the second kernel command line
• Share dmesg log of both 1st
and 2nd
kernel with kexec
mailing list.
• Check if `kexec -l kernel_image’ followed by `kexec -e` works
• Might be missing some arch/machine specific options
• Might have purgatory sha verification failed. If your arch does
not support a console in purgatory then it is very difficult to
debug.
Pratyush Anand
What Next
Pratyush Anand
What next
• kexec_file_load() support for unsupported arch
• shrink memory use for kdump initramfs
• move distribution initramfs code to upstream
• simplify kdump setup
THANK YOU
plus.google.com/+RedHat
linkedin.com/company/red-hat
youtube.com/user/RedHatVideos
facebook.com/redhatinc
twitter.com/RedHatNews

More Related Content

PDF
Kdump and the kernel crash dump analysis
PPT
Linux file system
PDF
Part 02 Linux Kernel Module Programming
PDF
Physical Memory Management.pdf
PDF
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
PDF
malloc & vmalloc in Linux
PDF
Physical Memory Models.pdf
PDF
Reverse Mapping (rmap) in Linux Kernel
Kdump and the kernel crash dump analysis
Linux file system
Part 02 Linux Kernel Module Programming
Physical Memory Management.pdf
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
malloc & vmalloc in Linux
Physical Memory Models.pdf
Reverse Mapping (rmap) in Linux Kernel

What's hot (20)

PDF
Arm device tree and linux device drivers
PDF
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
PDF
Linux Profiling at Netflix
PDF
Process Address Space: The way to create virtual address (page table) of user...
PDF
Container Performance Analysis
PDF
LISA2019 Linux Systems Performance
PDF
Linux systems - Linux Commands and Shell Scripting
PDF
Performance Wins with eBPF: Getting Started (2021)
PPT
Linux Crash Dump Capture and Analysis
PDF
Memory Mapping Implementation (mmap) in Linux Kernel
PDF
PDF
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
PDF
Anatomy of the loadable kernel module (lkm)
PPTX
Linux Kernel Booting Process (1) - For NLKB
PPT
Basic command ppt
PPTX
Linux kernel debugging
PDF
Embedded_Linux_Booting
PPTX
Linux Boot Process
PPT
U boot porting guide for SoC
PPT
Unix/Linux Basic Commands and Shell Script
Arm device tree and linux device drivers
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
Linux Profiling at Netflix
Process Address Space: The way to create virtual address (page table) of user...
Container Performance Analysis
LISA2019 Linux Systems Performance
Linux systems - Linux Commands and Shell Scripting
Performance Wins with eBPF: Getting Started (2021)
Linux Crash Dump Capture and Analysis
Memory Mapping Implementation (mmap) in Linux Kernel
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
Anatomy of the loadable kernel module (lkm)
Linux Kernel Booting Process (1) - For NLKB
Basic command ppt
Linux kernel debugging
Embedded_Linux_Booting
Linux Boot Process
U boot porting guide for SoC
Unix/Linux Basic Commands and Shell Script
Ad

Viewers also liked (20)

PDF
From Resilient to Antifragile Chaos Engineering Primer
PDF
点融网区块链即服务实践 - The Practice of Blockchain as a Service in Dianrong
PDF
Linuxcon secureefficientcontainerimagemanagementharbor
PDF
Obstacles & Solutions for Livepatch Support on ARM64 Architecture
PDF
PDF
Simplify Networking for Containers
PDF
OpenDaylight OpenStack Integration
PDF
Hyperledger Technical Community in China.
PDF
Flowchain: A case study on building a Blockchain for the IoT
PDF
Build Robust Blockchain Services with Hyperledger and Containers
PDF
There is NO Open Source Business Model
PDF
How Open Source Communities do Standardization
PDF
Get a Taste of 1 k+ Nodes by a Handful of Servers
PDF
Quickly Debug VM Failures in OpenStack
PDF
Is there still room for innovation in container orchestration and scheduling
PDF
SecurityPI - Hardening your IoT endpoints in Home.
PDF
The Open vSwitch and OVN Projects
From Resilient to Antifragile Chaos Engineering Primer
点融网区块链即服务实践 - The Practice of Blockchain as a Service in Dianrong
Linuxcon secureefficientcontainerimagemanagementharbor
Obstacles & Solutions for Livepatch Support on ARM64 Architecture
Simplify Networking for Containers
OpenDaylight OpenStack Integration
Hyperledger Technical Community in China.
Flowchain: A case study on building a Blockchain for the IoT
Build Robust Blockchain Services with Hyperledger and Containers
There is NO Open Source Business Model
How Open Source Communities do Standardization
Get a Taste of 1 k+ Nodes by a Handful of Servers
Quickly Debug VM Failures in OpenStack
Is there still room for innovation in container orchestration and scheduling
SecurityPI - Hardening your IoT endpoints in Home.
The Open vSwitch and OVN Projects
Ad

Similar to kdump: usage and_internals (20)

PDF
kdump_usage_and internals from redhat engineers
PDF
Kernel Recipes 2015 - Kernel dump analysis
PDF
PPT
Linux Device Driver for Writing a real world driver for embedded Linux
PDF
Basics_of_Kernel_Panic_Hang_and_ Kdump.pdf
PPT
Basic Linux kernel
PDF
Intro to Kernel Debugging - Just make the crashing stop!
PDF
Operating-Systems-Network-System-Lecture 2.pdf
PDF
Porting Android ABS 2011
PDF
Porting Android
PDF
Porting Android
PDF
HKG18-TR14 - Postmortem Debugging with Coresight
PPTX
“Linux Kernel CPU Hotplug in the Multicore System”
PDF
Docker 原理與實作
PPTX
Linux Kernel Tour
PDF
Lecture 6 Kernel Debugging + Ports Development
PDF
MINCS - containers in the shell script (Eng. ver.)
PDF
005 skyeye
PPTX
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
PDF
kexec / kdump implementation in Linux Kernel and Xen hypervisor
kdump_usage_and internals from redhat engineers
Kernel Recipes 2015 - Kernel dump analysis
Linux Device Driver for Writing a real world driver for embedded Linux
Basics_of_Kernel_Panic_Hang_and_ Kdump.pdf
Basic Linux kernel
Intro to Kernel Debugging - Just make the crashing stop!
Operating-Systems-Network-System-Lecture 2.pdf
Porting Android ABS 2011
Porting Android
Porting Android
HKG18-TR14 - Postmortem Debugging with Coresight
“Linux Kernel CPU Hotplug in the Multicore System”
Docker 原理與實作
Linux Kernel Tour
Lecture 6 Kernel Debugging + Ports Development
MINCS - containers in the shell script (Eng. ver.)
005 skyeye
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
kexec / kdump implementation in Linux Kernel and Xen hypervisor

More from LinuxCon ContainerCon CloudOpen China (19)

PDF
Status of Embedded Linux
PDF
Building a Better Thermostat
PDF
Scale Kubernetes to support 50000 services
PDF
Secure Containers with EPT Isolation
PDF
Open Source Software Business Models Redux
PDF
Running Legacy Applications with Containers
PDF
Introduction to OCI Image Technologies Serving Container
PDF
Rebuild - Simplifying Embedded and IoT Development Using Linux Containers
PDF
Policy-based Resource Placement
PDF
PDF
See what happened with real time kvm when building real time cloud pezhang@re...
PDF
PDF
High Performance Linux Virtual Machine on Microsoft Azure: SR-IOV Networking ...
PDF
Fully automated kubernetes deployment and management
PDF
Libvirt API Certification
PDF
Zephyr: Creating a Best-of-Breed, Secure RTOS for IoT
PDF
Releasing a Distribution in the Age of DevOps.
PDF
Linux Kernel Development
Status of Embedded Linux
Building a Better Thermostat
Scale Kubernetes to support 50000 services
Secure Containers with EPT Isolation
Open Source Software Business Models Redux
Running Legacy Applications with Containers
Introduction to OCI Image Technologies Serving Container
Rebuild - Simplifying Embedded and IoT Development Using Linux Containers
Policy-based Resource Placement
See what happened with real time kvm when building real time cloud pezhang@re...
High Performance Linux Virtual Machine on Microsoft Azure: SR-IOV Networking ...
Fully automated kubernetes deployment and management
Libvirt API Certification
Zephyr: Creating a Best-of-Breed, Secure RTOS for IoT
Releasing a Distribution in the Age of DevOps.
Linux Kernel Development

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation theory and applications.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
KodekX | Application Modernization Development
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
cuic standard and advanced reporting.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Modernizing your data center with Dell and AMD
Advanced methodologies resolving dimensionality complications for autism neur...
Building Integrated photovoltaic BIPV_UPV.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Network Security Unit 5.pdf for BCA BBA.
Spectral efficient network and resource selection model in 5G networks
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation theory and applications.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Electronic commerce courselecture one. Pdf
NewMind AI Monthly Chronicles - July 2025
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KodekX | Application Modernization Development
20250228 LYD VKU AI Blended-Learning.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
cuic standard and advanced reporting.pdf

kdump: usage and_internals

  • 1. Pratyush Anand kdump: usage and internals CFP, #LinuxCon, Beijing, June 19-20, 2017 Pratyush Anand(panand@redhat.com)
  • 2. Pratyush Anand Agenda ● kdump from user perspective ● Kernel system calls ● When Kernel crashes… ● vmcore structure ● makedumpfile ● kdump: The Fedora way ● Debugging kdump issues ● What next
  • 3. Pratyush Anand kdump from user perspective
  • 4. Pratyush Anand Overview First Kernel Skips bios/firmware reset stage and boots to second kernel kexec -l kernel.img --initrd=initramfs-image.img –reuse-cmdline kexec -e Primary Kernel (Reserves memory for crash kernel) Boot to crash kernel also known as capture kernel kexec -p kernel.img --initrd=initramfs-image.img –reuse-cmdline Followed by kernel panic(echo c > /proc/sysrq-trigger)
  • 5. Pratyush Anand Different pieces Linux Kernel (git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git) kernel/kexec* arch/…/kernel/machine_kexec*.c Mailing list: kexec@lists.infradead.org kexec_load(), kexec_file_load() and reboot() system call Arch specific code like machine_kexec() and machine_crash_shutdown() etc kexec-tools (git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git) Mailing list: kexec@lists.infradead.org Uses kernel system calls and provides a user command `kexec` Distribution code (like fedora kexec-tools) (git://pkgs.fedoraproject.org/kexec-tools) Mailing list: kexec@lists.fedoraproject.org Specs file and scripts to provide user friendly command/services so that kexec-tools can be automated in different user scenarios makedumpfile (git://git.code.sf.net/p/makedumpfile/code) Mailing list: kexec@lists.infradead.org Used to compress vmcore and erase sensitive information from it
  • 6. Pratyush Anand Kdump : End to end Flow crashkernel=Y@X Perform sha256 verification for all none-purgatory segments Copy vmcore to the disk/network Analyse vmcore using Crash-utility/gdb Reboot to sane(primary) kernel panic() If purgatory Loaded? yes no Primary Kernel (Reserves memory for capture kernel) Loads capture kernel/ Elfcorehdr/ Purgatory/ Initramfs etc into reserved memory Kexec -p Switch to capture kernel Creates /proc/vmcore as per elfcorehdr information received
  • 9. Pratyush Anand Kernel: kexec_load() (1) • The kexec_load() system call loads a new kernel that can be executed later by reboot() • long kexec_load(unsigned long entry, unsigned long nr_segments, struct kexec_segment *segments, unsigned long flags); • User space need to pass segment for different components like kernel, initramfs etc. • struct kexec_segment { void *buf; /* Buffer in user space */ size_t bufsz; /* Buffer length in user space */ void *mem; /* Physical address of kernel */ size_t memsz; /* Physical address length */ };
  • 10. Pratyush Anand Kernel: kexec_load() (2) • reboot(LINUX_REBOOT_CMD_KEXEC); • kexec_load() and above reboot() option is only available when kernel was configured with CONFIG_KEXEC. • Supported architecture: • X86, X86_64, ppc64, ia64, S390x, arm, arm64 • KEXEC_ON_CRASH • A flag which can be passed to kexec_load() • Execute the new kernel automatically on a system crash. • CONFIG_CRASH_DUMP should be configured
  • 11. Pratyush Anand Kernel: kexec_file_load() • CONFIG_KEXEC_FILE should be enabled to use this system call. • It is an in-kernel way of segment preparation. • long kexec_file_load(int kernel_fd, int initrd_fd, unsigned long cmdline_len, const char __user * cmdline_ptr, unsigned long flags); • User space need to pass kernel and initramfs file descriptor. • Only supported for x86 and powerpc
  • 13. Pratyush Anand When Kernel crashes….. • Update vmcoreinfo note (crash_save_vmcoreinfo()) • shutdown non-crashing cpus and save registers (machine_crash_shutdown() & crash_save_cpu()) • Might need to disable interrupt controller here • Perform kexec reboot now (machine_kexec()) • Load/flush kexec segments to memory • Pass control to the execution of entry segment
  • 15. Pratyush Anand Elf Program Headers • Most of the dump cores involved in kdump are in ELF format. • Each elf file has a program header • Which is read by the system loader • Which describes how the program should be loaded into memory. • `Objdump -p elf_file` can be used to look into program headers
  • 16. Pratyush Anand Elf Program Headers # objdump -p vmcore vmcore: file format elf64-littleaarch64 Program Header: NOTE off 0x0000000000010000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**0 filesz 0x00000000000013e8 memsz 0x00000000000013e8 flags --- LOAD off 0x0000000000020000 vaddr 0xffff000008080000 paddr 0x0000004000280000 align 2**0 filesz 0x0000000001460000 memsz 0x0000000001460000 flags rwx LOAD off 0x0000000001480000 vaddr 0xffff800000200000 paddr 0x0000004000200000 align 2**0 filesz 0x000000007fc00000 memsz 0x000000007fc00000 flags rwx LOAD off 0x0000000081080000 vaddr 0xffff8000ffe00000 paddr 0x00000040ffe00000 align 2**0 filesz 0x00000002fa7a0000 memsz 0x00000002fa7a0000 flags rwx LOAD off 0x000000037b820000 vaddr 0xffff8003fa9e0000 paddr 0x00000043fa9e0000 align 2**0 filesz 0x0000000004fc0000 memsz 0x0000000004fc0000 flags rwx LOAD off 0x00000003807e0000 vaddr 0xffff8003ff9b0000 paddr 0x00000043ff9b0000 align 2**0 filesz 0x0000000000010000 memsz 0x0000000000010000 flags rwx LOAD off 0x00000003807f0000 vaddr 0xffff8003ff9f0000 paddr 0x00000043ff9f0000 align 2**0 filesz 0x0000000000610000 memsz 0x0000000000610000 flags rwx private flags = 0:
  • 17. Pratyush Anand elfcorehdr EHDR PHDR(CPUp0 PT_NOTE) .. PHDR(CPUpn PT_NOTE) PHDR (vmcoreinfo PT_NOTE) [optional] PHDR (Kernel Text PT_LOAD) [optional] PHDR(RAM0 PT_LOAD) .. PHDR(RAMn PT_LOAD) - Entry point virtual address - Program header table file offset - Section header table file offset -Segment virtual address -Segment size in memory /sys/devices/system/cpu/cpu%d/crash_notes CPU PT_NOTE /sys/kernel/vmcoreinfo vmcoreinfo PT_NOTE /proc/iomem Mem PT_LOAD
  • 18. Pratyush Anand Notes • Crash notes • A percpu area for storing cpu states in case of system crash • Has information about current pid and cpu registers • Vmcoreinfo • This note section has various kernel debug information like struct size, symbol values, page size etc. • Vmcoreinfo is used mainly by makedumpfile application • include/linux/kexec.h has macros to define a new vmcoreinfo • VMCOREINFO_PAGESIZE() • VMCOREINFO_SYMBOL() • VMCOREINFO_SIZE()
  • 20. Pratyush Anand makedumpfile • It compresses /proc/vmcore data • Excludes unnecessary pages like: • Pages filled with zero • Cache pages without private flag (non-private cache) • Cache pages with private flag (private cache) • User process data pages • Free pages • Needs first kernel’s debug information to exclude unnecessary pages
  • 21. Pratyush Anand makedumpfile • Debug information comes from either VMLINUX or VMCOREINFO • Can also erase any specific sensitive kernel symbol • Output can either be in ELF format or kdump-compressed format • Typical usage: • makedumpfile -l --message-level 1 -d 31 /proc/vmcore makedumpfilecore • -d to specify the type of unnecessary page for analysis. • -l compression using lzo • -c compression using zlib • -p compression using snappy
  • 23. Pratyush Anand Kdump: The Fedora way • Start/stop/status kdump service: • systemctl start kdump • systemctl stop kdump • systemctl status kdump • Fedora has some scripts to take care of various use case scenarios. • Kdumpctl • mkdumprd • Configurations files: • /etc/sysconfig/kdump: • Initrd rebuild is not needed after any configuration change • /etc/kdump.conf: • Values which can affect initrd rebuild
  • 25. Pratyush Anand Debugging Kdump issues • `Kexec -p kernel_image` did not succeed • Check if crash memory is allocated • cat /sys/kernel/kexec_crash_size • Should have none zero value • If not allocated, then pass proper “crashkernel=” argument in command line • If nothing shows up then pass -d in the kexec command and share debug output with kexec mailing list.
  • 26. Pratyush Anand Debugging Kdump issues • Do not see anything on console after last message from first kernel (like “bye”): • Might have second kernel crashed very early • Pass some earlycon/earlyprintk option for your system to the second kernel command line • Share dmesg log of both 1st and 2nd kernel with kexec mailing list. • Check if `kexec -l kernel_image’ followed by `kexec -e` works • Might be missing some arch/machine specific options • Might have purgatory sha verification failed. If your arch does not support a console in purgatory then it is very difficult to debug.
  • 28. Pratyush Anand What next • kexec_file_load() support for unsupported arch • shrink memory use for kdump initramfs • move distribution initramfs code to upstream • simplify kdump setup