162306a36Sopenharmony_ci================================================================ 262306a36Sopenharmony_ciDocumentation for Kdump - The kexec-based Crash Dumping Solution 362306a36Sopenharmony_ci================================================================ 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciThis document includes overview, setup, installation, and analysis 662306a36Sopenharmony_ciinformation. 762306a36Sopenharmony_ci 862306a36Sopenharmony_ciOverview 962306a36Sopenharmony_ci======== 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ciKdump uses kexec to quickly boot to a dump-capture kernel whenever a 1262306a36Sopenharmony_cidump of the system kernel's memory needs to be taken (for example, when 1362306a36Sopenharmony_cithe system panics). The system kernel's memory image is preserved across 1462306a36Sopenharmony_cithe reboot and is accessible to the dump-capture kernel. 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ciYou can use common commands, such as cp, scp or makedumpfile to copy 1762306a36Sopenharmony_cithe memory image to a dump file on the local disk, or across the network 1862306a36Sopenharmony_cito a remote system. 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciKdump and kexec are currently supported on the x86, x86_64, ppc64, ia64, 2162306a36Sopenharmony_cis390x, arm and arm64 architectures. 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ciWhen the system kernel boots, it reserves a small section of memory for 2462306a36Sopenharmony_cithe dump-capture kernel. This ensures that ongoing Direct Memory Access 2562306a36Sopenharmony_ci(DMA) from the system kernel does not corrupt the dump-capture kernel. 2662306a36Sopenharmony_ciThe kexec -p command loads the dump-capture kernel into this reserved 2762306a36Sopenharmony_cimemory. 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciOn x86 machines, the first 640 KB of physical memory is needed for boot, 3062306a36Sopenharmony_ciregardless of where the kernel loads. For simpler handling, the whole 3162306a36Sopenharmony_cilow 1M is reserved to avoid any later kernel or device driver writing 3262306a36Sopenharmony_cidata into this area. Like this, the low 1M can be reused as system RAM 3362306a36Sopenharmony_ciby kdump kernel without extra handling. 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ciOn PPC64 machines first 32KB of physical memory is needed for booting 3662306a36Sopenharmony_ciregardless of where the kernel is loaded and to support 64K page size 3762306a36Sopenharmony_cikexec backs up the first 64KB memory. 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciFor s390x, when kdump is triggered, the crashkernel region is exchanged 4062306a36Sopenharmony_ciwith the region [0, crashkernel region size] and then the kdump kernel 4162306a36Sopenharmony_ciruns in [0, crashkernel region size]. Therefore no relocatable kernel is 4262306a36Sopenharmony_cineeded for s390x. 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciAll of the necessary information about the system kernel's core image is 4562306a36Sopenharmony_ciencoded in the ELF format, and stored in a reserved area of memory 4662306a36Sopenharmony_cibefore a crash. The physical address of the start of the ELF header is 4762306a36Sopenharmony_cipassed to the dump-capture kernel through the elfcorehdr= boot 4862306a36Sopenharmony_ciparameter. Optionally the size of the ELF header can also be passed 4962306a36Sopenharmony_ciwhen using the elfcorehdr=[size[KMG]@]offset[KMG] syntax. 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ciWith the dump-capture kernel, you can access the memory image through 5262306a36Sopenharmony_ci/proc/vmcore. This exports the dump as an ELF-format file that you can 5362306a36Sopenharmony_ciwrite out using file copy commands such as cp or scp. You can also use 5462306a36Sopenharmony_cimakedumpfile utility to analyze and write out filtered contents with 5562306a36Sopenharmony_cioptions, e.g with '-d 31' it will only write out kernel data. Further, 5662306a36Sopenharmony_ciyou can use analysis tools such as the GNU Debugger (GDB) and the Crash 5762306a36Sopenharmony_citool to debug the dump file. This method ensures that the dump pages are 5862306a36Sopenharmony_cicorrectly ordered. 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ciSetup and Installation 6162306a36Sopenharmony_ci====================== 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ciInstall kexec-tools 6462306a36Sopenharmony_ci------------------- 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci1) Login as the root user. 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci2) Download the kexec-tools user-space package from the following URL: 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_cihttp://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools.tar.gz 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ciThis is a symlink to the latest version. 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ciThe latest kexec-tools git tree is available at: 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci- git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git 7762306a36Sopenharmony_ci- http://www.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ciThere is also a gitweb interface available at 8062306a36Sopenharmony_cihttp://www.kernel.org/git/?p=utils/kernel/kexec/kexec-tools.git 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ciMore information about kexec-tools can be found at 8362306a36Sopenharmony_cihttp://horms.net/projects/kexec/ 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci3) Unpack the tarball with the tar command, as follows:: 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci tar xvpzf kexec-tools.tar.gz 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci4) Change to the kexec-tools directory, as follows:: 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci cd kexec-tools-VERSION 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci5) Configure the package, as follows:: 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci ./configure 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci6) Compile the package, as follows:: 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci make 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci7) Install the package, as follows:: 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci make install 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ciBuild the system and dump-capture kernels 10762306a36Sopenharmony_ci----------------------------------------- 10862306a36Sopenharmony_ciThere are two possible methods of using Kdump. 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci1) Build a separate custom dump-capture kernel for capturing the 11162306a36Sopenharmony_ci kernel core dump. 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci2) Or use the system kernel binary itself as dump-capture kernel and there is 11462306a36Sopenharmony_ci no need to build a separate dump-capture kernel. This is possible 11562306a36Sopenharmony_ci only with the architectures which support a relocatable kernel. As 11662306a36Sopenharmony_ci of today, i386, x86_64, ppc64, ia64, arm and arm64 architectures support 11762306a36Sopenharmony_ci relocatable kernel. 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ciBuilding a relocatable kernel is advantageous from the point of view that 12062306a36Sopenharmony_cione does not have to build a second kernel for capturing the dump. But 12162306a36Sopenharmony_ciat the same time one might want to build a custom dump capture kernel 12262306a36Sopenharmony_cisuitable to his needs. 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ciFollowing are the configuration setting required for system and 12562306a36Sopenharmony_cidump-capture kernels for enabling kdump support. 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ciSystem kernel config options 12862306a36Sopenharmony_ci---------------------------- 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci1) Enable "kexec system call" or "kexec file based system call" in 13162306a36Sopenharmony_ci "Processor type and features.":: 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci CONFIG_KEXEC=y or CONFIG_KEXEC_FILE=y 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci And both of them will select KEXEC_CORE:: 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci CONFIG_KEXEC_CORE=y 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci Subsequently, CRASH_CORE is selected by KEXEC_CORE:: 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci CONFIG_CRASH_CORE=y 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci2) Enable "sysfs file system support" in "Filesystem" -> "Pseudo 14462306a36Sopenharmony_ci filesystems." This is usually enabled by default:: 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci CONFIG_SYSFS=y 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci Note that "sysfs file system support" might not appear in the "Pseudo 14962306a36Sopenharmony_ci filesystems" menu if "Configure standard kernel features (expert users)" 15062306a36Sopenharmony_ci is not enabled in "General Setup." In this case, check the .config file 15162306a36Sopenharmony_ci itself to ensure that sysfs is turned on, as follows:: 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci grep 'CONFIG_SYSFS' .config 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci3) Enable "Compile the kernel with debug info" in "Kernel hacking.":: 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci CONFIG_DEBUG_INFO=Y 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci This causes the kernel to be built with debug symbols. The dump 16062306a36Sopenharmony_ci analysis tools require a vmlinux with debug symbols in order to read 16162306a36Sopenharmony_ci and analyze a dump file. 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ciDump-capture kernel config options (Arch Independent) 16462306a36Sopenharmony_ci----------------------------------------------------- 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ci1) Enable "kernel crash dumps" support under "Processor type and 16762306a36Sopenharmony_ci features":: 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci CONFIG_CRASH_DUMP=y 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci2) Enable "/proc/vmcore support" under "Filesystems" -> "Pseudo filesystems":: 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci CONFIG_PROC_VMCORE=y 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci (CONFIG_PROC_VMCORE is set by default when CONFIG_CRASH_DUMP is selected.) 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ciDump-capture kernel config options (Arch Dependent, i386 and x86_64) 17862306a36Sopenharmony_ci-------------------------------------------------------------------- 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci1) On i386, enable high memory support under "Processor type and 18162306a36Sopenharmony_ci features":: 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci CONFIG_HIGHMEM64G=y 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci or:: 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci CONFIG_HIGHMEM4G 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci2) With CONFIG_SMP=y, usually nr_cpus=1 need specified on the kernel 19062306a36Sopenharmony_ci command line when loading the dump-capture kernel because one 19162306a36Sopenharmony_ci CPU is enough for kdump kernel to dump vmcore on most of systems. 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci However, you can also specify nr_cpus=X to enable multiple processors 19462306a36Sopenharmony_ci in kdump kernel. In this case, "disable_cpu_apicid=" is needed to 19562306a36Sopenharmony_ci tell kdump kernel which cpu is 1st kernel's BSP. Please refer to 19662306a36Sopenharmony_ci admin-guide/kernel-parameters.txt for more details. 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci With CONFIG_SMP=n, the above things are not related. 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci3) A relocatable kernel is suggested to be built by default. If not yet, 20162306a36Sopenharmony_ci enable "Build a relocatable kernel" support under "Processor type and 20262306a36Sopenharmony_ci features":: 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci CONFIG_RELOCATABLE=y 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_ci4) Use a suitable value for "Physical address where the kernel is 20762306a36Sopenharmony_ci loaded" (under "Processor type and features"). This only appears when 20862306a36Sopenharmony_ci "kernel crash dumps" is enabled. A suitable value depends upon 20962306a36Sopenharmony_ci whether kernel is relocatable or not. 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci If you are using a relocatable kernel use CONFIG_PHYSICAL_START=0x100000 21262306a36Sopenharmony_ci This will compile the kernel for physical address 1MB, but given the fact 21362306a36Sopenharmony_ci kernel is relocatable, it can be run from any physical address hence 21462306a36Sopenharmony_ci kexec boot loader will load it in memory region reserved for dump-capture 21562306a36Sopenharmony_ci kernel. 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci Otherwise it should be the start of memory region reserved for 21862306a36Sopenharmony_ci second kernel using boot parameter "crashkernel=Y@X". Here X is 21962306a36Sopenharmony_ci start of memory region reserved for dump-capture kernel. 22062306a36Sopenharmony_ci Generally X is 16MB (0x1000000). So you can set 22162306a36Sopenharmony_ci CONFIG_PHYSICAL_START=0x1000000 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci5) Make and install the kernel and its modules. DO NOT add this kernel 22462306a36Sopenharmony_ci to the boot loader configuration files. 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ciDump-capture kernel config options (Arch Dependent, ppc64) 22762306a36Sopenharmony_ci---------------------------------------------------------- 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci1) Enable "Build a kdump crash kernel" support under "Kernel" options:: 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci CONFIG_CRASH_DUMP=y 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci2) Enable "Build a relocatable kernel" support:: 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci CONFIG_RELOCATABLE=y 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci Make and install the kernel and its modules. 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ciDump-capture kernel config options (Arch Dependent, ia64) 24062306a36Sopenharmony_ci---------------------------------------------------------- 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci- No specific options are required to create a dump-capture kernel 24362306a36Sopenharmony_ci for ia64, other than those specified in the arch independent section 24462306a36Sopenharmony_ci above. This means that it is possible to use the system kernel 24562306a36Sopenharmony_ci as a dump-capture kernel if desired. 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ci The crashkernel region can be automatically placed by the system 24862306a36Sopenharmony_ci kernel at runtime. This is done by specifying the base address as 0, 24962306a36Sopenharmony_ci or omitting it all together:: 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_ci crashkernel=256M@0 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci or:: 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci crashkernel=256M 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ciDump-capture kernel config options (Arch Dependent, arm) 25862306a36Sopenharmony_ci---------------------------------------------------------- 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ci- To use a relocatable kernel, 26162306a36Sopenharmony_ci Enable "AUTO_ZRELADDR" support under "Boot" options:: 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci AUTO_ZRELADDR=y 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ciDump-capture kernel config options (Arch Dependent, arm64) 26662306a36Sopenharmony_ci---------------------------------------------------------- 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_ci- Please note that kvm of the dump-capture kernel will not be enabled 26962306a36Sopenharmony_ci on non-VHE systems even if it is configured. This is because the CPU 27062306a36Sopenharmony_ci will not be reset to EL2 on panic. 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_cicrashkernel syntax 27362306a36Sopenharmony_ci=========================== 27462306a36Sopenharmony_ci1) crashkernel=size@offset 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci Here 'size' specifies how much memory to reserve for the dump-capture kernel 27762306a36Sopenharmony_ci and 'offset' specifies the beginning of this reserved memory. For example, 27862306a36Sopenharmony_ci "crashkernel=64M@16M" tells the system kernel to reserve 64 MB of memory 27962306a36Sopenharmony_ci starting at physical address 0x01000000 (16MB) for the dump-capture kernel. 28062306a36Sopenharmony_ci 28162306a36Sopenharmony_ci The crashkernel region can be automatically placed by the system 28262306a36Sopenharmony_ci kernel at run time. This is done by specifying the base address as 0, 28362306a36Sopenharmony_ci or omitting it all together:: 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ci crashkernel=256M@0 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ci or:: 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_ci crashkernel=256M 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci If the start address is specified, note that the start address of the 29262306a36Sopenharmony_ci kernel will be aligned to a value (which is Arch dependent), so if the 29362306a36Sopenharmony_ci start address is not then any space below the alignment point will be 29462306a36Sopenharmony_ci wasted. 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci2) range1:size1[,range2:size2,...][@offset] 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci While the "crashkernel=size[@offset]" syntax is sufficient for most 29962306a36Sopenharmony_ci configurations, sometimes it's handy to have the reserved memory dependent 30062306a36Sopenharmony_ci on the value of System RAM -- that's mostly for distributors that pre-setup 30162306a36Sopenharmony_ci the kernel command line to avoid a unbootable system after some memory has 30262306a36Sopenharmony_ci been removed from the machine. 30362306a36Sopenharmony_ci 30462306a36Sopenharmony_ci The syntax is:: 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ci crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset] 30762306a36Sopenharmony_ci range=start-[end] 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_ci For example:: 31062306a36Sopenharmony_ci 31162306a36Sopenharmony_ci crashkernel=512M-2G:64M,2G-:128M 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ci This would mean: 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci 1) if the RAM is smaller than 512M, then don't reserve anything 31662306a36Sopenharmony_ci (this is the "rescue" case) 31762306a36Sopenharmony_ci 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M 31862306a36Sopenharmony_ci 3) if the RAM size is larger than 2G, then reserve 128M 31962306a36Sopenharmony_ci 32062306a36Sopenharmony_ci3) crashkernel=size,high and crashkernel=size,low 32162306a36Sopenharmony_ci 32262306a36Sopenharmony_ci If memory above 4G is preferred, crashkernel=size,high can be used to 32362306a36Sopenharmony_ci fulfill that. With it, physical memory is allowed to be allocated from top, 32462306a36Sopenharmony_ci so could be above 4G if system has more than 4G RAM installed. Otherwise, 32562306a36Sopenharmony_ci memory region will be allocated below 4G if available. 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci When crashkernel=X,high is passed, kernel could allocate physical memory 32862306a36Sopenharmony_ci region above 4G, low memory under 4G is needed in this case. There are 32962306a36Sopenharmony_ci three ways to get low memory: 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci 1) Kernel will allocate at least 256M memory below 4G automatically 33262306a36Sopenharmony_ci if crashkernel=Y,low is not specified. 33362306a36Sopenharmony_ci 2) Let user specify low memory size instead. 33462306a36Sopenharmony_ci 3) Specified value 0 will disable low memory allocation:: 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci crashkernel=0,low 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ciBoot into System Kernel 33962306a36Sopenharmony_ci----------------------- 34062306a36Sopenharmony_ci1) Update the boot loader (such as grub, yaboot, or lilo) configuration 34162306a36Sopenharmony_ci files as necessary. 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ci2) Boot the system kernel with the boot parameter "crashkernel=Y@X". 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ci On x86 and x86_64, use "crashkernel=Y[@X]". Most of the time, the 34662306a36Sopenharmony_ci start address 'X' is not necessary, kernel will search a suitable 34762306a36Sopenharmony_ci area. Unless an explicit start address is expected. 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci On ppc64, use "crashkernel=128M@32M". 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ci On ia64, 256M@256M is a generous value that typically works. 35262306a36Sopenharmony_ci The region may be automatically placed on ia64, see the 35362306a36Sopenharmony_ci dump-capture kernel config option notes above. 35462306a36Sopenharmony_ci If use sparse memory, the size should be rounded to GRANULE boundaries. 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_ci On s390x, typically use "crashkernel=xxM". The value of xx is dependent 35762306a36Sopenharmony_ci on the memory consumption of the kdump system. In general this is not 35862306a36Sopenharmony_ci dependent on the memory size of the production system. 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci On arm, the use of "crashkernel=Y@X" is no longer necessary; the 36162306a36Sopenharmony_ci kernel will automatically locate the crash kernel image within the 36262306a36Sopenharmony_ci first 512MB of RAM if X is not given. 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci On arm64, use "crashkernel=Y[@X]". Note that the start address of 36562306a36Sopenharmony_ci the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000). 36662306a36Sopenharmony_ci 36762306a36Sopenharmony_ciLoad the Dump-capture Kernel 36862306a36Sopenharmony_ci============================ 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ciAfter booting to the system kernel, dump-capture kernel needs to be 37162306a36Sopenharmony_ciloaded. 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ciBased on the architecture and type of image (relocatable or not), one 37462306a36Sopenharmony_cican choose to load the uncompressed vmlinux or compressed bzImage/vmlinuz 37562306a36Sopenharmony_ciof dump-capture kernel. Following is the summary. 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_ciFor i386 and x86_64: 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci - Use bzImage/vmlinuz if kernel is relocatable. 38062306a36Sopenharmony_ci - Use vmlinux if kernel is not relocatable. 38162306a36Sopenharmony_ci 38262306a36Sopenharmony_ciFor ppc64: 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci - Use vmlinux 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ciFor ia64: 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci - Use vmlinux or vmlinuz.gz 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ciFor s390x: 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_ci - Use image or bzImage 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_ciFor arm: 39562306a36Sopenharmony_ci 39662306a36Sopenharmony_ci - Use zImage 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ciFor arm64: 39962306a36Sopenharmony_ci 40062306a36Sopenharmony_ci - Use vmlinux or Image 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_ciIf you are using an uncompressed vmlinux image then use following command 40362306a36Sopenharmony_cito load dump-capture kernel:: 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci kexec -p <dump-capture-kernel-vmlinux-image> \ 40662306a36Sopenharmony_ci --initrd=<initrd-for-dump-capture-kernel> --args-linux \ 40762306a36Sopenharmony_ci --append="root=<root-dev> <arch-specific-options>" 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_ciIf you are using a compressed bzImage/vmlinuz, then use following command 41062306a36Sopenharmony_cito load dump-capture kernel:: 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ci kexec -p <dump-capture-kernel-bzImage> \ 41362306a36Sopenharmony_ci --initrd=<initrd-for-dump-capture-kernel> \ 41462306a36Sopenharmony_ci --append="root=<root-dev> <arch-specific-options>" 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ciIf you are using a compressed zImage, then use following command 41762306a36Sopenharmony_cito load dump-capture kernel:: 41862306a36Sopenharmony_ci 41962306a36Sopenharmony_ci kexec --type zImage -p <dump-capture-kernel-bzImage> \ 42062306a36Sopenharmony_ci --initrd=<initrd-for-dump-capture-kernel> \ 42162306a36Sopenharmony_ci --dtb=<dtb-for-dump-capture-kernel> \ 42262306a36Sopenharmony_ci --append="root=<root-dev> <arch-specific-options>" 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ciIf you are using an uncompressed Image, then use following command 42562306a36Sopenharmony_cito load dump-capture kernel:: 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_ci kexec -p <dump-capture-kernel-Image> \ 42862306a36Sopenharmony_ci --initrd=<initrd-for-dump-capture-kernel> \ 42962306a36Sopenharmony_ci --append="root=<root-dev> <arch-specific-options>" 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_ciPlease note, that --args-linux does not need to be specified for ia64. 43262306a36Sopenharmony_ciIt is planned to make this a no-op on that architecture, but for now 43362306a36Sopenharmony_ciit should be omitted 43462306a36Sopenharmony_ci 43562306a36Sopenharmony_ciFollowing are the arch specific command line options to be used while 43662306a36Sopenharmony_ciloading dump-capture kernel. 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ciFor i386, x86_64 and ia64: 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ci "1 irqpoll nr_cpus=1 reset_devices" 44162306a36Sopenharmony_ci 44262306a36Sopenharmony_ciFor ppc64: 44362306a36Sopenharmony_ci 44462306a36Sopenharmony_ci "1 maxcpus=1 noirqdistrib reset_devices" 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_ciFor s390x: 44762306a36Sopenharmony_ci 44862306a36Sopenharmony_ci "1 nr_cpus=1 cgroup_disable=memory" 44962306a36Sopenharmony_ci 45062306a36Sopenharmony_ciFor arm: 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ci "1 maxcpus=1 reset_devices" 45362306a36Sopenharmony_ci 45462306a36Sopenharmony_ciFor arm64: 45562306a36Sopenharmony_ci 45662306a36Sopenharmony_ci "1 nr_cpus=1 reset_devices" 45762306a36Sopenharmony_ci 45862306a36Sopenharmony_ciNotes on loading the dump-capture kernel: 45962306a36Sopenharmony_ci 46062306a36Sopenharmony_ci* By default, the ELF headers are stored in ELF64 format to support 46162306a36Sopenharmony_ci systems with more than 4GB memory. On i386, kexec automatically checks if 46262306a36Sopenharmony_ci the physical RAM size exceeds the 4 GB limit and if not, uses ELF32. 46362306a36Sopenharmony_ci So, on non-PAE systems, ELF32 is always used. 46462306a36Sopenharmony_ci 46562306a36Sopenharmony_ci The --elf32-core-headers option can be used to force the generation of ELF32 46662306a36Sopenharmony_ci headers. This is necessary because GDB currently cannot open vmcore files 46762306a36Sopenharmony_ci with ELF64 headers on 32-bit systems. 46862306a36Sopenharmony_ci 46962306a36Sopenharmony_ci* The "irqpoll" boot parameter reduces driver initialization failures 47062306a36Sopenharmony_ci due to shared interrupts in the dump-capture kernel. 47162306a36Sopenharmony_ci 47262306a36Sopenharmony_ci* You must specify <root-dev> in the format corresponding to the root 47362306a36Sopenharmony_ci device name in the output of mount command. 47462306a36Sopenharmony_ci 47562306a36Sopenharmony_ci* Boot parameter "1" boots the dump-capture kernel into single-user 47662306a36Sopenharmony_ci mode without networking. If you want networking, use "3". 47762306a36Sopenharmony_ci 47862306a36Sopenharmony_ci* We generally don't have to bring up a SMP kernel just to capture the 47962306a36Sopenharmony_ci dump. Hence generally it is useful either to build a UP dump-capture 48062306a36Sopenharmony_ci kernel or specify maxcpus=1 option while loading dump-capture kernel. 48162306a36Sopenharmony_ci Note, though maxcpus always works, you had better replace it with 48262306a36Sopenharmony_ci nr_cpus to save memory if supported by the current ARCH, such as x86. 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ci* You should enable multi-cpu support in dump-capture kernel if you intend 48562306a36Sopenharmony_ci to use multi-thread programs with it, such as parallel dump feature of 48662306a36Sopenharmony_ci makedumpfile. Otherwise, the multi-thread program may have a great 48762306a36Sopenharmony_ci performance degradation. To enable multi-cpu support, you should bring up an 48862306a36Sopenharmony_ci SMP dump-capture kernel and specify maxcpus/nr_cpus, disable_cpu_apicid=[X] 48962306a36Sopenharmony_ci options while loading it. 49062306a36Sopenharmony_ci 49162306a36Sopenharmony_ci* For s390x there are two kdump modes: If a ELF header is specified with 49262306a36Sopenharmony_ci the elfcorehdr= kernel parameter, it is used by the kdump kernel as it 49362306a36Sopenharmony_ci is done on all other architectures. If no elfcorehdr= kernel parameter is 49462306a36Sopenharmony_ci specified, the s390x kdump kernel dynamically creates the header. The 49562306a36Sopenharmony_ci second mode has the advantage that for CPU and memory hotplug, kdump has 49662306a36Sopenharmony_ci not to be reloaded with kexec_load(). 49762306a36Sopenharmony_ci 49862306a36Sopenharmony_ci* For s390x systems with many attached devices the "cio_ignore" kernel 49962306a36Sopenharmony_ci parameter should be used for the kdump kernel in order to prevent allocation 50062306a36Sopenharmony_ci of kernel memory for devices that are not relevant for kdump. The same 50162306a36Sopenharmony_ci applies to systems that use SCSI/FCP devices. In that case the 50262306a36Sopenharmony_ci "allow_lun_scan" zfcp module parameter should be set to zero before 50362306a36Sopenharmony_ci setting FCP devices online. 50462306a36Sopenharmony_ci 50562306a36Sopenharmony_ciKernel Panic 50662306a36Sopenharmony_ci============ 50762306a36Sopenharmony_ci 50862306a36Sopenharmony_ciAfter successfully loading the dump-capture kernel as previously 50962306a36Sopenharmony_cidescribed, the system will reboot into the dump-capture kernel if a 51062306a36Sopenharmony_cisystem crash is triggered. Trigger points are located in panic(), 51162306a36Sopenharmony_cidie(), die_nmi() and in the sysrq handler (ALT-SysRq-c). 51262306a36Sopenharmony_ci 51362306a36Sopenharmony_ciThe following conditions will execute a crash trigger point: 51462306a36Sopenharmony_ci 51562306a36Sopenharmony_ciIf a hard lockup is detected and "NMI watchdog" is configured, the system 51662306a36Sopenharmony_ciwill boot into the dump-capture kernel ( die_nmi() ). 51762306a36Sopenharmony_ci 51862306a36Sopenharmony_ciIf die() is called, and it happens to be a thread with pid 0 or 1, or die() 51962306a36Sopenharmony_ciis called inside interrupt context or die() is called and panic_on_oops is set, 52062306a36Sopenharmony_cithe system will boot into the dump-capture kernel. 52162306a36Sopenharmony_ci 52262306a36Sopenharmony_ciOn powerpc systems when a soft-reset is generated, die() is called by all cpus 52362306a36Sopenharmony_ciand the system will boot into the dump-capture kernel. 52462306a36Sopenharmony_ci 52562306a36Sopenharmony_ciFor testing purposes, you can trigger a crash by using "ALT-SysRq-c", 52662306a36Sopenharmony_ci"echo c > /proc/sysrq-trigger" or write a module to force the panic. 52762306a36Sopenharmony_ci 52862306a36Sopenharmony_ciWrite Out the Dump File 52962306a36Sopenharmony_ci======================= 53062306a36Sopenharmony_ci 53162306a36Sopenharmony_ciAfter the dump-capture kernel is booted, write out the dump file with 53262306a36Sopenharmony_cithe following command:: 53362306a36Sopenharmony_ci 53462306a36Sopenharmony_ci cp /proc/vmcore <dump-file> 53562306a36Sopenharmony_ci 53662306a36Sopenharmony_cior use scp to write out the dump file between hosts on a network, e.g:: 53762306a36Sopenharmony_ci 53862306a36Sopenharmony_ci scp /proc/vmcore remote_username@remote_ip:<dump-file> 53962306a36Sopenharmony_ci 54062306a36Sopenharmony_ciYou can also use makedumpfile utility to write out the dump file 54162306a36Sopenharmony_ciwith specified options to filter out unwanted contents, e.g:: 54262306a36Sopenharmony_ci 54362306a36Sopenharmony_ci makedumpfile -l --message-level 1 -d 31 /proc/vmcore <dump-file> 54462306a36Sopenharmony_ci 54562306a36Sopenharmony_ciAnalysis 54662306a36Sopenharmony_ci======== 54762306a36Sopenharmony_ci 54862306a36Sopenharmony_ciBefore analyzing the dump image, you should reboot into a stable kernel. 54962306a36Sopenharmony_ci 55062306a36Sopenharmony_ciYou can do limited analysis using GDB on the dump file copied out of 55162306a36Sopenharmony_ci/proc/vmcore. Use the debug vmlinux built with -g and run the following 55262306a36Sopenharmony_cicommand:: 55362306a36Sopenharmony_ci 55462306a36Sopenharmony_ci gdb vmlinux <dump-file> 55562306a36Sopenharmony_ci 55662306a36Sopenharmony_ciStack trace for the task on processor 0, register display, and memory 55762306a36Sopenharmony_cidisplay work fine. 55862306a36Sopenharmony_ci 55962306a36Sopenharmony_ciNote: GDB cannot analyze core files generated in ELF64 format for x86. 56062306a36Sopenharmony_ciOn systems with a maximum of 4GB of memory, you can generate 56162306a36Sopenharmony_ciELF32-format headers using the --elf32-core-headers kernel option on the 56262306a36Sopenharmony_cidump kernel. 56362306a36Sopenharmony_ci 56462306a36Sopenharmony_ciYou can also use the Crash utility to analyze dump files in Kdump 56562306a36Sopenharmony_ciformat. Crash is available at the following URL: 56662306a36Sopenharmony_ci 56762306a36Sopenharmony_ci https://github.com/crash-utility/crash 56862306a36Sopenharmony_ci 56962306a36Sopenharmony_ciCrash document can be found at: 57062306a36Sopenharmony_ci https://crash-utility.github.io/ 57162306a36Sopenharmony_ci 57262306a36Sopenharmony_ciTrigger Kdump on WARN() 57362306a36Sopenharmony_ci======================= 57462306a36Sopenharmony_ci 57562306a36Sopenharmony_ciThe kernel parameter, panic_on_warn, calls panic() in all WARN() paths. This 57662306a36Sopenharmony_ciwill cause a kdump to occur at the panic() call. In cases where a user wants 57762306a36Sopenharmony_cito specify this during runtime, /proc/sys/kernel/panic_on_warn can be set to 1 57862306a36Sopenharmony_cito achieve the same behaviour. 57962306a36Sopenharmony_ci 58062306a36Sopenharmony_ciTrigger Kdump on add_taint() 58162306a36Sopenharmony_ci============================ 58262306a36Sopenharmony_ci 58362306a36Sopenharmony_ciThe kernel parameter panic_on_taint facilitates a conditional call to panic() 58462306a36Sopenharmony_cifrom within add_taint() whenever the value set in this bitmask matches with the 58562306a36Sopenharmony_cibit flag being set by add_taint(). 58662306a36Sopenharmony_ciThis will cause a kdump to occur at the add_taint()->panic() call. 58762306a36Sopenharmony_ci 58862306a36Sopenharmony_ciContact 58962306a36Sopenharmony_ci======= 59062306a36Sopenharmony_ci 59162306a36Sopenharmony_ci- kexec@lists.infradead.org 59262306a36Sopenharmony_ci 59362306a36Sopenharmony_ciGDB macros 59462306a36Sopenharmony_ci========== 59562306a36Sopenharmony_ci 59662306a36Sopenharmony_ci.. include:: gdbmacros.txt 59762306a36Sopenharmony_ci :literal: 598