1330d4810SMauro Carvalho Chehab================================================================ 2330d4810SMauro Carvalho ChehabDocumentation for Kdump - The kexec-based Crash Dumping Solution 3330d4810SMauro Carvalho Chehab================================================================ 4330d4810SMauro Carvalho Chehab 5b1f4c363SBaoquan HeThis document includes overview, setup, installation, and analysis 6330d4810SMauro Carvalho Chehabinformation. 7330d4810SMauro Carvalho Chehab 8330d4810SMauro Carvalho ChehabOverview 9330d4810SMauro Carvalho Chehab======== 10330d4810SMauro Carvalho Chehab 11330d4810SMauro Carvalho ChehabKdump uses kexec to quickly boot to a dump-capture kernel whenever a 12330d4810SMauro Carvalho Chehabdump of the system kernel's memory needs to be taken (for example, when 13330d4810SMauro Carvalho Chehabthe system panics). The system kernel's memory image is preserved across 14330d4810SMauro Carvalho Chehabthe reboot and is accessible to the dump-capture kernel. 15330d4810SMauro Carvalho Chehab 16b1f4c363SBaoquan HeYou can use common commands, such as cp, scp or makedumpfile to copy 17b1f4c363SBaoquan Hethe memory image to a dump file on the local disk, or across the network 18b1f4c363SBaoquan Heto a remote system. 19330d4810SMauro Carvalho Chehab 20330d4810SMauro Carvalho ChehabKdump and kexec are currently supported on the x86, x86_64, ppc64, ia64, 21330d4810SMauro Carvalho Chehabs390x, arm and arm64 architectures. 22330d4810SMauro Carvalho Chehab 23330d4810SMauro Carvalho ChehabWhen the system kernel boots, it reserves a small section of memory for 24330d4810SMauro Carvalho Chehabthe dump-capture kernel. This ensures that ongoing Direct Memory Access 25330d4810SMauro Carvalho Chehab(DMA) from the system kernel does not corrupt the dump-capture kernel. 26330d4810SMauro Carvalho ChehabThe kexec -p command loads the dump-capture kernel into this reserved 27330d4810SMauro Carvalho Chehabmemory. 28330d4810SMauro Carvalho Chehab 29b1f4c363SBaoquan HeOn x86 machines, the first 640 KB of physical memory is needed for boot, 30b1f4c363SBaoquan Heregardless of where the kernel loads. For simpler handling, the whole 31b1f4c363SBaoquan Helow 1M is reserved to avoid any later kernel or device driver writing 32b1f4c363SBaoquan Hedata into this area. Like this, the low 1M can be reused as system RAM 33b1f4c363SBaoquan Heby kdump kernel without extra handling. 34330d4810SMauro Carvalho Chehab 35b1f4c363SBaoquan HeOn PPC64 machines first 32KB of physical memory is needed for booting 36b1f4c363SBaoquan Heregardless of where the kernel is loaded and to support 64K page size 37b1f4c363SBaoquan Hekexec backs up the first 64KB memory. 38330d4810SMauro Carvalho Chehab 39330d4810SMauro Carvalho ChehabFor s390x, when kdump is triggered, the crashkernel region is exchanged 40330d4810SMauro Carvalho Chehabwith the region [0, crashkernel region size] and then the kdump kernel 41330d4810SMauro Carvalho Chehabruns in [0, crashkernel region size]. Therefore no relocatable kernel is 42330d4810SMauro Carvalho Chehabneeded for s390x. 43330d4810SMauro Carvalho Chehab 44330d4810SMauro Carvalho ChehabAll of the necessary information about the system kernel's core image is 45330d4810SMauro Carvalho Chehabencoded in the ELF format, and stored in a reserved area of memory 46330d4810SMauro Carvalho Chehabbefore a crash. The physical address of the start of the ELF header is 47330d4810SMauro Carvalho Chehabpassed to the dump-capture kernel through the elfcorehdr= boot 48330d4810SMauro Carvalho Chehabparameter. Optionally the size of the ELF header can also be passed 49330d4810SMauro Carvalho Chehabwhen using the elfcorehdr=[size[KMG]@]offset[KMG] syntax. 50330d4810SMauro Carvalho Chehab 51330d4810SMauro Carvalho ChehabWith the dump-capture kernel, you can access the memory image through 52330d4810SMauro Carvalho Chehab/proc/vmcore. This exports the dump as an ELF-format file that you can 53b1f4c363SBaoquan Hewrite out using file copy commands such as cp or scp. You can also use 54b1f4c363SBaoquan Hemakedumpfile utility to analyze and write out filtered contents with 55b1f4c363SBaoquan Heoptions, e.g with '-d 31' it will only write out kernel data. Further, 56b1f4c363SBaoquan Heyou can use analysis tools such as the GNU Debugger (GDB) and the Crash 57b1f4c363SBaoquan Hetool to debug the dump file. This method ensures that the dump pages are 58b1f4c363SBaoquan Hecorrectly ordered. 59330d4810SMauro Carvalho Chehab 60330d4810SMauro Carvalho ChehabSetup and Installation 61330d4810SMauro Carvalho Chehab====================== 62330d4810SMauro Carvalho Chehab 63330d4810SMauro Carvalho ChehabInstall kexec-tools 64330d4810SMauro Carvalho Chehab------------------- 65330d4810SMauro Carvalho Chehab 66330d4810SMauro Carvalho Chehab1) Login as the root user. 67330d4810SMauro Carvalho Chehab 68330d4810SMauro Carvalho Chehab2) Download the kexec-tools user-space package from the following URL: 69330d4810SMauro Carvalho Chehab 70330d4810SMauro Carvalho Chehabhttp://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools.tar.gz 71330d4810SMauro Carvalho Chehab 72330d4810SMauro Carvalho ChehabThis is a symlink to the latest version. 73330d4810SMauro Carvalho Chehab 74330d4810SMauro Carvalho ChehabThe latest kexec-tools git tree is available at: 75330d4810SMauro Carvalho Chehab 76330d4810SMauro Carvalho Chehab- git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git 77330d4810SMauro Carvalho Chehab- http://www.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git 78330d4810SMauro Carvalho Chehab 79330d4810SMauro Carvalho ChehabThere is also a gitweb interface available at 80330d4810SMauro Carvalho Chehabhttp://www.kernel.org/git/?p=utils/kernel/kexec/kexec-tools.git 81330d4810SMauro Carvalho Chehab 82330d4810SMauro Carvalho ChehabMore information about kexec-tools can be found at 83330d4810SMauro Carvalho Chehabhttp://horms.net/projects/kexec/ 84330d4810SMauro Carvalho Chehab 85330d4810SMauro Carvalho Chehab3) Unpack the tarball with the tar command, as follows:: 86330d4810SMauro Carvalho Chehab 87330d4810SMauro Carvalho Chehab tar xvpzf kexec-tools.tar.gz 88330d4810SMauro Carvalho Chehab 89330d4810SMauro Carvalho Chehab4) Change to the kexec-tools directory, as follows:: 90330d4810SMauro Carvalho Chehab 91330d4810SMauro Carvalho Chehab cd kexec-tools-VERSION 92330d4810SMauro Carvalho Chehab 93330d4810SMauro Carvalho Chehab5) Configure the package, as follows:: 94330d4810SMauro Carvalho Chehab 95330d4810SMauro Carvalho Chehab ./configure 96330d4810SMauro Carvalho Chehab 97330d4810SMauro Carvalho Chehab6) Compile the package, as follows:: 98330d4810SMauro Carvalho Chehab 99330d4810SMauro Carvalho Chehab make 100330d4810SMauro Carvalho Chehab 101330d4810SMauro Carvalho Chehab7) Install the package, as follows:: 102330d4810SMauro Carvalho Chehab 103330d4810SMauro Carvalho Chehab make install 104330d4810SMauro Carvalho Chehab 105330d4810SMauro Carvalho Chehab 106330d4810SMauro Carvalho ChehabBuild the system and dump-capture kernels 107330d4810SMauro Carvalho Chehab----------------------------------------- 108330d4810SMauro Carvalho ChehabThere are two possible methods of using Kdump. 109330d4810SMauro Carvalho Chehab 110330d4810SMauro Carvalho Chehab1) Build a separate custom dump-capture kernel for capturing the 111330d4810SMauro Carvalho Chehab kernel core dump. 112330d4810SMauro Carvalho Chehab 113330d4810SMauro Carvalho Chehab2) Or use the system kernel binary itself as dump-capture kernel and there is 114330d4810SMauro Carvalho Chehab no need to build a separate dump-capture kernel. This is possible 115330d4810SMauro Carvalho Chehab only with the architectures which support a relocatable kernel. As 116330d4810SMauro Carvalho Chehab of today, i386, x86_64, ppc64, ia64, arm and arm64 architectures support 117330d4810SMauro Carvalho Chehab relocatable kernel. 118330d4810SMauro Carvalho Chehab 119330d4810SMauro Carvalho ChehabBuilding a relocatable kernel is advantageous from the point of view that 120330d4810SMauro Carvalho Chehabone does not have to build a second kernel for capturing the dump. But 121330d4810SMauro Carvalho Chehabat the same time one might want to build a custom dump capture kernel 122330d4810SMauro Carvalho Chehabsuitable to his needs. 123330d4810SMauro Carvalho Chehab 124330d4810SMauro Carvalho ChehabFollowing are the configuration setting required for system and 125330d4810SMauro Carvalho Chehabdump-capture kernels for enabling kdump support. 126330d4810SMauro Carvalho Chehab 127330d4810SMauro Carvalho ChehabSystem kernel config options 128330d4810SMauro Carvalho Chehab---------------------------- 129330d4810SMauro Carvalho Chehab 130b1f4c363SBaoquan He1) Enable "kexec system call" or "kexec file based system call" in 131b1f4c363SBaoquan He "Processor type and features.":: 132330d4810SMauro Carvalho Chehab 133b1f4c363SBaoquan He CONFIG_KEXEC=y or CONFIG_KEXEC_FILE=y 134b1f4c363SBaoquan He 135b1f4c363SBaoquan He And both of them will select KEXEC_CORE:: 136b1f4c363SBaoquan He 137b1f4c363SBaoquan He CONFIG_KEXEC_CORE=y 138b1f4c363SBaoquan He 139b1f4c363SBaoquan He Subsequently, CRASH_CORE is selected by KEXEC_CORE:: 140b1f4c363SBaoquan He 141b1f4c363SBaoquan He CONFIG_CRASH_CORE=y 142330d4810SMauro Carvalho Chehab 143330d4810SMauro Carvalho Chehab2) Enable "sysfs file system support" in "Filesystem" -> "Pseudo 144330d4810SMauro Carvalho Chehab filesystems." This is usually enabled by default:: 145330d4810SMauro Carvalho Chehab 146330d4810SMauro Carvalho Chehab CONFIG_SYSFS=y 147330d4810SMauro Carvalho Chehab 148330d4810SMauro Carvalho Chehab Note that "sysfs file system support" might not appear in the "Pseudo 149b2377d4bSTiezhu Yang filesystems" menu if "Configure standard kernel features (expert users)" 150b2377d4bSTiezhu Yang is not enabled in "General Setup." In this case, check the .config file 151b2377d4bSTiezhu Yang itself to ensure that sysfs is turned on, as follows:: 152330d4810SMauro Carvalho Chehab 153330d4810SMauro Carvalho Chehab grep 'CONFIG_SYSFS' .config 154330d4810SMauro Carvalho Chehab 155330d4810SMauro Carvalho Chehab3) Enable "Compile the kernel with debug info" in "Kernel hacking.":: 156330d4810SMauro Carvalho Chehab 157330d4810SMauro Carvalho Chehab CONFIG_DEBUG_INFO=Y 158330d4810SMauro Carvalho Chehab 159330d4810SMauro Carvalho Chehab This causes the kernel to be built with debug symbols. The dump 160330d4810SMauro Carvalho Chehab analysis tools require a vmlinux with debug symbols in order to read 161330d4810SMauro Carvalho Chehab and analyze a dump file. 162330d4810SMauro Carvalho Chehab 163330d4810SMauro Carvalho ChehabDump-capture kernel config options (Arch Independent) 164330d4810SMauro Carvalho Chehab----------------------------------------------------- 165330d4810SMauro Carvalho Chehab 166330d4810SMauro Carvalho Chehab1) Enable "kernel crash dumps" support under "Processor type and 167330d4810SMauro Carvalho Chehab features":: 168330d4810SMauro Carvalho Chehab 169330d4810SMauro Carvalho Chehab CONFIG_CRASH_DUMP=y 170330d4810SMauro Carvalho Chehab 171330d4810SMauro Carvalho Chehab2) Enable "/proc/vmcore support" under "Filesystems" -> "Pseudo filesystems":: 172330d4810SMauro Carvalho Chehab 173330d4810SMauro Carvalho Chehab CONFIG_PROC_VMCORE=y 174330d4810SMauro Carvalho Chehab 175330d4810SMauro Carvalho Chehab (CONFIG_PROC_VMCORE is set by default when CONFIG_CRASH_DUMP is selected.) 176330d4810SMauro Carvalho Chehab 177330d4810SMauro Carvalho ChehabDump-capture kernel config options (Arch Dependent, i386 and x86_64) 178330d4810SMauro Carvalho Chehab-------------------------------------------------------------------- 179330d4810SMauro Carvalho Chehab 180330d4810SMauro Carvalho Chehab1) On i386, enable high memory support under "Processor type and 181330d4810SMauro Carvalho Chehab features":: 182330d4810SMauro Carvalho Chehab 183330d4810SMauro Carvalho Chehab CONFIG_HIGHMEM64G=y 184330d4810SMauro Carvalho Chehab 185330d4810SMauro Carvalho Chehab or:: 186330d4810SMauro Carvalho Chehab 187330d4810SMauro Carvalho Chehab CONFIG_HIGHMEM4G 188330d4810SMauro Carvalho Chehab 189b1f4c363SBaoquan He2) With CONFIG_SMP=y, usually nr_cpus=1 need specified on the kernel 190b1f4c363SBaoquan He command line when loading the dump-capture kernel because one 191b1f4c363SBaoquan He CPU is enough for kdump kernel to dump vmcore on most of systems. 192330d4810SMauro Carvalho Chehab 193b1f4c363SBaoquan He However, you can also specify nr_cpus=X to enable multiple processors 194b1f4c363SBaoquan He in kdump kernel. In this case, "disable_cpu_apicid=" is needed to 195b1f4c363SBaoquan He tell kdump kernel which cpu is 1st kernel's BSP. Please refer to 196b1f4c363SBaoquan He admin-guide/kernel-parameters.txt for more details. 197330d4810SMauro Carvalho Chehab 198b1f4c363SBaoquan He With CONFIG_SMP=n, the above things are not related. 199330d4810SMauro Carvalho Chehab 200b1f4c363SBaoquan He3) A relocatable kernel is suggested to be built by default. If not yet, 201b1f4c363SBaoquan He enable "Build a relocatable kernel" support under "Processor type and 202330d4810SMauro Carvalho Chehab features":: 203330d4810SMauro Carvalho Chehab 204330d4810SMauro Carvalho Chehab CONFIG_RELOCATABLE=y 205330d4810SMauro Carvalho Chehab 206330d4810SMauro Carvalho Chehab4) Use a suitable value for "Physical address where the kernel is 207330d4810SMauro Carvalho Chehab loaded" (under "Processor type and features"). This only appears when 208330d4810SMauro Carvalho Chehab "kernel crash dumps" is enabled. A suitable value depends upon 209330d4810SMauro Carvalho Chehab whether kernel is relocatable or not. 210330d4810SMauro Carvalho Chehab 211330d4810SMauro Carvalho Chehab If you are using a relocatable kernel use CONFIG_PHYSICAL_START=0x100000 212330d4810SMauro Carvalho Chehab This will compile the kernel for physical address 1MB, but given the fact 213330d4810SMauro Carvalho Chehab kernel is relocatable, it can be run from any physical address hence 214330d4810SMauro Carvalho Chehab kexec boot loader will load it in memory region reserved for dump-capture 215330d4810SMauro Carvalho Chehab kernel. 216330d4810SMauro Carvalho Chehab 217330d4810SMauro Carvalho Chehab Otherwise it should be the start of memory region reserved for 218330d4810SMauro Carvalho Chehab second kernel using boot parameter "crashkernel=Y@X". Here X is 219330d4810SMauro Carvalho Chehab start of memory region reserved for dump-capture kernel. 220330d4810SMauro Carvalho Chehab Generally X is 16MB (0x1000000). So you can set 221330d4810SMauro Carvalho Chehab CONFIG_PHYSICAL_START=0x1000000 222330d4810SMauro Carvalho Chehab 223330d4810SMauro Carvalho Chehab5) Make and install the kernel and its modules. DO NOT add this kernel 224330d4810SMauro Carvalho Chehab to the boot loader configuration files. 225330d4810SMauro Carvalho Chehab 226330d4810SMauro Carvalho ChehabDump-capture kernel config options (Arch Dependent, ppc64) 227330d4810SMauro Carvalho Chehab---------------------------------------------------------- 228330d4810SMauro Carvalho Chehab 229330d4810SMauro Carvalho Chehab1) Enable "Build a kdump crash kernel" support under "Kernel" options:: 230330d4810SMauro Carvalho Chehab 231330d4810SMauro Carvalho Chehab CONFIG_CRASH_DUMP=y 232330d4810SMauro Carvalho Chehab 233330d4810SMauro Carvalho Chehab2) Enable "Build a relocatable kernel" support:: 234330d4810SMauro Carvalho Chehab 235330d4810SMauro Carvalho Chehab CONFIG_RELOCATABLE=y 236330d4810SMauro Carvalho Chehab 237330d4810SMauro Carvalho Chehab Make and install the kernel and its modules. 238330d4810SMauro Carvalho Chehab 239330d4810SMauro Carvalho ChehabDump-capture kernel config options (Arch Dependent, ia64) 240330d4810SMauro Carvalho Chehab---------------------------------------------------------- 241330d4810SMauro Carvalho Chehab 242330d4810SMauro Carvalho Chehab- No specific options are required to create a dump-capture kernel 243330d4810SMauro Carvalho Chehab for ia64, other than those specified in the arch independent section 244330d4810SMauro Carvalho Chehab above. This means that it is possible to use the system kernel 245330d4810SMauro Carvalho Chehab as a dump-capture kernel if desired. 246330d4810SMauro Carvalho Chehab 247330d4810SMauro Carvalho Chehab The crashkernel region can be automatically placed by the system 248330d4810SMauro Carvalho Chehab kernel at runtime. This is done by specifying the base address as 0, 249330d4810SMauro Carvalho Chehab or omitting it all together:: 250330d4810SMauro Carvalho Chehab 251330d4810SMauro Carvalho Chehab crashkernel=256M@0 252330d4810SMauro Carvalho Chehab 253330d4810SMauro Carvalho Chehab or:: 254330d4810SMauro Carvalho Chehab 255330d4810SMauro Carvalho Chehab crashkernel=256M 256330d4810SMauro Carvalho Chehab 257330d4810SMauro Carvalho ChehabDump-capture kernel config options (Arch Dependent, arm) 258330d4810SMauro Carvalho Chehab---------------------------------------------------------- 259330d4810SMauro Carvalho Chehab 260330d4810SMauro Carvalho Chehab- To use a relocatable kernel, 261330d4810SMauro Carvalho Chehab Enable "AUTO_ZRELADDR" support under "Boot" options:: 262330d4810SMauro Carvalho Chehab 263330d4810SMauro Carvalho Chehab AUTO_ZRELADDR=y 264330d4810SMauro Carvalho Chehab 265330d4810SMauro Carvalho ChehabDump-capture kernel config options (Arch Dependent, arm64) 266330d4810SMauro Carvalho Chehab---------------------------------------------------------- 267330d4810SMauro Carvalho Chehab 268330d4810SMauro Carvalho Chehab- Please note that kvm of the dump-capture kernel will not be enabled 269330d4810SMauro Carvalho Chehab on non-VHE systems even if it is configured. This is because the CPU 270330d4810SMauro Carvalho Chehab will not be reset to EL2 on panic. 271330d4810SMauro Carvalho Chehab 272b1f4c363SBaoquan Hecrashkernel syntax 273330d4810SMauro Carvalho Chehab=========================== 274b1f4c363SBaoquan He1) crashkernel=size@offset 275b1f4c363SBaoquan He 276b1f4c363SBaoquan He Here 'size' specifies how much memory to reserve for the dump-capture kernel 277b1f4c363SBaoquan He and 'offset' specifies the beginning of this reserved memory. For example, 278b1f4c363SBaoquan He "crashkernel=64M@16M" tells the system kernel to reserve 64 MB of memory 279b1f4c363SBaoquan He starting at physical address 0x01000000 (16MB) for the dump-capture kernel. 280b1f4c363SBaoquan He 281b1f4c363SBaoquan He The crashkernel region can be automatically placed by the system 282b1f4c363SBaoquan He kernel at run time. This is done by specifying the base address as 0, 283b1f4c363SBaoquan He or omitting it all together:: 284b1f4c363SBaoquan He 285b1f4c363SBaoquan He crashkernel=256M@0 286b1f4c363SBaoquan He 287b1f4c363SBaoquan He or:: 288b1f4c363SBaoquan He 289b1f4c363SBaoquan He crashkernel=256M 290b1f4c363SBaoquan He 291b1f4c363SBaoquan He If the start address is specified, note that the start address of the 292b1f4c363SBaoquan He kernel will be aligned to a value (which is Arch dependent), so if the 293b1f4c363SBaoquan He start address is not then any space below the alignment point will be 294b1f4c363SBaoquan He wasted. 295b1f4c363SBaoquan He 296b1f4c363SBaoquan He2) range1:size1[,range2:size2,...][@offset] 297330d4810SMauro Carvalho Chehab 298330d4810SMauro Carvalho Chehab While the "crashkernel=size[@offset]" syntax is sufficient for most 299330d4810SMauro Carvalho Chehab configurations, sometimes it's handy to have the reserved memory dependent 300330d4810SMauro Carvalho Chehab on the value of System RAM -- that's mostly for distributors that pre-setup 301330d4810SMauro Carvalho Chehab the kernel command line to avoid a unbootable system after some memory has 302330d4810SMauro Carvalho Chehab been removed from the machine. 303330d4810SMauro Carvalho Chehab 304330d4810SMauro Carvalho Chehab The syntax is:: 305330d4810SMauro Carvalho Chehab 306330d4810SMauro Carvalho Chehab crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset] 307330d4810SMauro Carvalho Chehab range=start-[end] 308330d4810SMauro Carvalho Chehab 309330d4810SMauro Carvalho Chehab For example:: 310330d4810SMauro Carvalho Chehab 311330d4810SMauro Carvalho Chehab crashkernel=512M-2G:64M,2G-:128M 312330d4810SMauro Carvalho Chehab 313330d4810SMauro Carvalho Chehab This would mean: 314330d4810SMauro Carvalho Chehab 315330d4810SMauro Carvalho Chehab 1) if the RAM is smaller than 512M, then don't reserve anything 316330d4810SMauro Carvalho Chehab (this is the "rescue" case) 317330d4810SMauro Carvalho Chehab 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M 318330d4810SMauro Carvalho Chehab 3) if the RAM size is larger than 2G, then reserve 128M 319330d4810SMauro Carvalho Chehab 320b1f4c363SBaoquan He3) crashkernel=size,high and crashkernel=size,low 321330d4810SMauro Carvalho Chehab 322b1f4c363SBaoquan He If memory above 4G is preferred, crashkernel=size,high can be used to 323b1f4c363SBaoquan He fulfill that. With it, physical memory is allowed to be allocated from top, 324b1f4c363SBaoquan He so could be above 4G if system has more than 4G RAM installed. Otherwise, 325b1f4c363SBaoquan He memory region will be allocated below 4G if available. 326b1f4c363SBaoquan He 327b1f4c363SBaoquan He When crashkernel=X,high is passed, kernel could allocate physical memory 328b1f4c363SBaoquan He region above 4G, low memory under 4G is needed in this case. There are 329b1f4c363SBaoquan He three ways to get low memory: 330b1f4c363SBaoquan He 331b1f4c363SBaoquan He 1) Kernel will allocate at least 256M memory below 4G automatically 332b1f4c363SBaoquan He if crashkernel=Y,low is not specified. 333b1f4c363SBaoquan He 2) Let user specify low memory size instead. 334b1f4c363SBaoquan He 3) Specified value 0 will disable low memory allocation:: 335b1f4c363SBaoquan He 336b1f4c363SBaoquan He crashkernel=0,low 337330d4810SMauro Carvalho Chehab 338330d4810SMauro Carvalho ChehabBoot into System Kernel 339b1f4c363SBaoquan He----------------------- 340330d4810SMauro Carvalho Chehab1) Update the boot loader (such as grub, yaboot, or lilo) configuration 341330d4810SMauro Carvalho Chehab files as necessary. 342330d4810SMauro Carvalho Chehab 343b1f4c363SBaoquan He2) Boot the system kernel with the boot parameter "crashkernel=Y@X". 344330d4810SMauro Carvalho Chehab 345b1f4c363SBaoquan He On x86 and x86_64, use "crashkernel=Y[@X]". Most of the time, the 346b1f4c363SBaoquan He start address 'X' is not necessary, kernel will search a suitable 347b1f4c363SBaoquan He area. Unless an explicit start address is expected. 348330d4810SMauro Carvalho Chehab 349330d4810SMauro Carvalho Chehab On ppc64, use "crashkernel=128M@32M". 350330d4810SMauro Carvalho Chehab 351330d4810SMauro Carvalho Chehab On ia64, 256M@256M is a generous value that typically works. 352330d4810SMauro Carvalho Chehab The region may be automatically placed on ia64, see the 353330d4810SMauro Carvalho Chehab dump-capture kernel config option notes above. 354330d4810SMauro Carvalho Chehab If use sparse memory, the size should be rounded to GRANULE boundaries. 355330d4810SMauro Carvalho Chehab 356330d4810SMauro Carvalho Chehab On s390x, typically use "crashkernel=xxM". The value of xx is dependent 357330d4810SMauro Carvalho Chehab on the memory consumption of the kdump system. In general this is not 358330d4810SMauro Carvalho Chehab dependent on the memory size of the production system. 359330d4810SMauro Carvalho Chehab 360330d4810SMauro Carvalho Chehab On arm, the use of "crashkernel=Y@X" is no longer necessary; the 361330d4810SMauro Carvalho Chehab kernel will automatically locate the crash kernel image within the 362330d4810SMauro Carvalho Chehab first 512MB of RAM if X is not given. 363330d4810SMauro Carvalho Chehab 364330d4810SMauro Carvalho Chehab On arm64, use "crashkernel=Y[@X]". Note that the start address of 365330d4810SMauro Carvalho Chehab the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000). 366330d4810SMauro Carvalho Chehab 367330d4810SMauro Carvalho ChehabLoad the Dump-capture Kernel 368330d4810SMauro Carvalho Chehab============================ 369330d4810SMauro Carvalho Chehab 370330d4810SMauro Carvalho ChehabAfter booting to the system kernel, dump-capture kernel needs to be 371330d4810SMauro Carvalho Chehabloaded. 372330d4810SMauro Carvalho Chehab 373330d4810SMauro Carvalho ChehabBased on the architecture and type of image (relocatable or not), one 374330d4810SMauro Carvalho Chehabcan choose to load the uncompressed vmlinux or compressed bzImage/vmlinuz 375330d4810SMauro Carvalho Chehabof dump-capture kernel. Following is the summary. 376330d4810SMauro Carvalho Chehab 377330d4810SMauro Carvalho ChehabFor i386 and x86_64: 378330d4810SMauro Carvalho Chehab 379330d4810SMauro Carvalho Chehab - Use bzImage/vmlinuz if kernel is relocatable. 380b1f4c363SBaoquan He - Use vmlinux if kernel is not relocatable. 381330d4810SMauro Carvalho Chehab 382330d4810SMauro Carvalho ChehabFor ppc64: 383330d4810SMauro Carvalho Chehab 384330d4810SMauro Carvalho Chehab - Use vmlinux 385330d4810SMauro Carvalho Chehab 386330d4810SMauro Carvalho ChehabFor ia64: 387330d4810SMauro Carvalho Chehab 388330d4810SMauro Carvalho Chehab - Use vmlinux or vmlinuz.gz 389330d4810SMauro Carvalho Chehab 390330d4810SMauro Carvalho ChehabFor s390x: 391330d4810SMauro Carvalho Chehab 392330d4810SMauro Carvalho Chehab - Use image or bzImage 393330d4810SMauro Carvalho Chehab 394330d4810SMauro Carvalho ChehabFor arm: 395330d4810SMauro Carvalho Chehab 396330d4810SMauro Carvalho Chehab - Use zImage 397330d4810SMauro Carvalho Chehab 398330d4810SMauro Carvalho ChehabFor arm64: 399330d4810SMauro Carvalho Chehab 400330d4810SMauro Carvalho Chehab - Use vmlinux or Image 401330d4810SMauro Carvalho Chehab 402330d4810SMauro Carvalho ChehabIf you are using an uncompressed vmlinux image then use following command 403330d4810SMauro Carvalho Chehabto load dump-capture kernel:: 404330d4810SMauro Carvalho Chehab 405330d4810SMauro Carvalho Chehab kexec -p <dump-capture-kernel-vmlinux-image> \ 406330d4810SMauro Carvalho Chehab --initrd=<initrd-for-dump-capture-kernel> --args-linux \ 407330d4810SMauro Carvalho Chehab --append="root=<root-dev> <arch-specific-options>" 408330d4810SMauro Carvalho Chehab 409330d4810SMauro Carvalho ChehabIf you are using a compressed bzImage/vmlinuz, then use following command 410330d4810SMauro Carvalho Chehabto load dump-capture kernel:: 411330d4810SMauro Carvalho Chehab 412330d4810SMauro Carvalho Chehab kexec -p <dump-capture-kernel-bzImage> \ 413330d4810SMauro Carvalho Chehab --initrd=<initrd-for-dump-capture-kernel> \ 414330d4810SMauro Carvalho Chehab --append="root=<root-dev> <arch-specific-options>" 415330d4810SMauro Carvalho Chehab 416330d4810SMauro Carvalho ChehabIf you are using a compressed zImage, then use following command 417330d4810SMauro Carvalho Chehabto load dump-capture kernel:: 418330d4810SMauro Carvalho Chehab 419330d4810SMauro Carvalho Chehab kexec --type zImage -p <dump-capture-kernel-bzImage> \ 420330d4810SMauro Carvalho Chehab --initrd=<initrd-for-dump-capture-kernel> \ 421330d4810SMauro Carvalho Chehab --dtb=<dtb-for-dump-capture-kernel> \ 422330d4810SMauro Carvalho Chehab --append="root=<root-dev> <arch-specific-options>" 423330d4810SMauro Carvalho Chehab 424330d4810SMauro Carvalho ChehabIf you are using an uncompressed Image, then use following command 425330d4810SMauro Carvalho Chehabto load dump-capture kernel:: 426330d4810SMauro Carvalho Chehab 427330d4810SMauro Carvalho Chehab kexec -p <dump-capture-kernel-Image> \ 428330d4810SMauro Carvalho Chehab --initrd=<initrd-for-dump-capture-kernel> \ 429330d4810SMauro Carvalho Chehab --append="root=<root-dev> <arch-specific-options>" 430330d4810SMauro Carvalho Chehab 431330d4810SMauro Carvalho ChehabPlease note, that --args-linux does not need to be specified for ia64. 432330d4810SMauro Carvalho ChehabIt is planned to make this a no-op on that architecture, but for now 433330d4810SMauro Carvalho Chehabit should be omitted 434330d4810SMauro Carvalho Chehab 435330d4810SMauro Carvalho ChehabFollowing are the arch specific command line options to be used while 436330d4810SMauro Carvalho Chehabloading dump-capture kernel. 437330d4810SMauro Carvalho Chehab 438330d4810SMauro Carvalho ChehabFor i386, x86_64 and ia64: 439330d4810SMauro Carvalho Chehab 440b1f4c363SBaoquan He "1 irqpoll nr_cpus=1 reset_devices" 441330d4810SMauro Carvalho Chehab 442330d4810SMauro Carvalho ChehabFor ppc64: 443330d4810SMauro Carvalho Chehab 444330d4810SMauro Carvalho Chehab "1 maxcpus=1 noirqdistrib reset_devices" 445330d4810SMauro Carvalho Chehab 446330d4810SMauro Carvalho ChehabFor s390x: 447330d4810SMauro Carvalho Chehab 448b1f4c363SBaoquan He "1 nr_cpus=1 cgroup_disable=memory" 449330d4810SMauro Carvalho Chehab 450330d4810SMauro Carvalho ChehabFor arm: 451330d4810SMauro Carvalho Chehab 452330d4810SMauro Carvalho Chehab "1 maxcpus=1 reset_devices" 453330d4810SMauro Carvalho Chehab 454330d4810SMauro Carvalho ChehabFor arm64: 455330d4810SMauro Carvalho Chehab 456b1f4c363SBaoquan He "1 nr_cpus=1 reset_devices" 457330d4810SMauro Carvalho Chehab 458330d4810SMauro Carvalho ChehabNotes on loading the dump-capture kernel: 459330d4810SMauro Carvalho Chehab 460330d4810SMauro Carvalho Chehab* By default, the ELF headers are stored in ELF64 format to support 461330d4810SMauro Carvalho Chehab systems with more than 4GB memory. On i386, kexec automatically checks if 462330d4810SMauro Carvalho Chehab the physical RAM size exceeds the 4 GB limit and if not, uses ELF32. 463330d4810SMauro Carvalho Chehab So, on non-PAE systems, ELF32 is always used. 464330d4810SMauro Carvalho Chehab 465330d4810SMauro Carvalho Chehab The --elf32-core-headers option can be used to force the generation of ELF32 466330d4810SMauro Carvalho Chehab headers. This is necessary because GDB currently cannot open vmcore files 467330d4810SMauro Carvalho Chehab with ELF64 headers on 32-bit systems. 468330d4810SMauro Carvalho Chehab 469330d4810SMauro Carvalho Chehab* The "irqpoll" boot parameter reduces driver initialization failures 470330d4810SMauro Carvalho Chehab due to shared interrupts in the dump-capture kernel. 471330d4810SMauro Carvalho Chehab 472330d4810SMauro Carvalho Chehab* You must specify <root-dev> in the format corresponding to the root 473330d4810SMauro Carvalho Chehab device name in the output of mount command. 474330d4810SMauro Carvalho Chehab 475330d4810SMauro Carvalho Chehab* Boot parameter "1" boots the dump-capture kernel into single-user 476330d4810SMauro Carvalho Chehab mode without networking. If you want networking, use "3". 477330d4810SMauro Carvalho Chehab 478330d4810SMauro Carvalho Chehab* We generally don't have to bring up a SMP kernel just to capture the 479330d4810SMauro Carvalho Chehab dump. Hence generally it is useful either to build a UP dump-capture 480330d4810SMauro Carvalho Chehab kernel or specify maxcpus=1 option while loading dump-capture kernel. 481330d4810SMauro Carvalho Chehab Note, though maxcpus always works, you had better replace it with 482330d4810SMauro Carvalho Chehab nr_cpus to save memory if supported by the current ARCH, such as x86. 483330d4810SMauro Carvalho Chehab 484330d4810SMauro Carvalho Chehab* You should enable multi-cpu support in dump-capture kernel if you intend 485330d4810SMauro Carvalho Chehab to use multi-thread programs with it, such as parallel dump feature of 486330d4810SMauro Carvalho Chehab makedumpfile. Otherwise, the multi-thread program may have a great 487330d4810SMauro Carvalho Chehab performance degradation. To enable multi-cpu support, you should bring up an 488330d4810SMauro Carvalho Chehab SMP dump-capture kernel and specify maxcpus/nr_cpus, disable_cpu_apicid=[X] 489330d4810SMauro Carvalho Chehab options while loading it. 490330d4810SMauro Carvalho Chehab 491330d4810SMauro Carvalho Chehab* For s390x there are two kdump modes: If a ELF header is specified with 492330d4810SMauro Carvalho Chehab the elfcorehdr= kernel parameter, it is used by the kdump kernel as it 493330d4810SMauro Carvalho Chehab is done on all other architectures. If no elfcorehdr= kernel parameter is 494330d4810SMauro Carvalho Chehab specified, the s390x kdump kernel dynamically creates the header. The 495330d4810SMauro Carvalho Chehab second mode has the advantage that for CPU and memory hotplug, kdump has 496330d4810SMauro Carvalho Chehab not to be reloaded with kexec_load(). 497330d4810SMauro Carvalho Chehab 498330d4810SMauro Carvalho Chehab* For s390x systems with many attached devices the "cio_ignore" kernel 499330d4810SMauro Carvalho Chehab parameter should be used for the kdump kernel in order to prevent allocation 500330d4810SMauro Carvalho Chehab of kernel memory for devices that are not relevant for kdump. The same 501330d4810SMauro Carvalho Chehab applies to systems that use SCSI/FCP devices. In that case the 502330d4810SMauro Carvalho Chehab "allow_lun_scan" zfcp module parameter should be set to zero before 503330d4810SMauro Carvalho Chehab setting FCP devices online. 504330d4810SMauro Carvalho Chehab 505330d4810SMauro Carvalho ChehabKernel Panic 506330d4810SMauro Carvalho Chehab============ 507330d4810SMauro Carvalho Chehab 508330d4810SMauro Carvalho ChehabAfter successfully loading the dump-capture kernel as previously 509330d4810SMauro Carvalho Chehabdescribed, the system will reboot into the dump-capture kernel if a 510330d4810SMauro Carvalho Chehabsystem crash is triggered. Trigger points are located in panic(), 511330d4810SMauro Carvalho Chehabdie(), die_nmi() and in the sysrq handler (ALT-SysRq-c). 512330d4810SMauro Carvalho Chehab 513330d4810SMauro Carvalho ChehabThe following conditions will execute a crash trigger point: 514330d4810SMauro Carvalho Chehab 515330d4810SMauro Carvalho ChehabIf a hard lockup is detected and "NMI watchdog" is configured, the system 516330d4810SMauro Carvalho Chehabwill boot into the dump-capture kernel ( die_nmi() ). 517330d4810SMauro Carvalho Chehab 518330d4810SMauro Carvalho ChehabIf die() is called, and it happens to be a thread with pid 0 or 1, or die() 519330d4810SMauro Carvalho Chehabis called inside interrupt context or die() is called and panic_on_oops is set, 520330d4810SMauro Carvalho Chehabthe system will boot into the dump-capture kernel. 521330d4810SMauro Carvalho Chehab 522330d4810SMauro Carvalho ChehabOn powerpc systems when a soft-reset is generated, die() is called by all cpus 523330d4810SMauro Carvalho Chehaband the system will boot into the dump-capture kernel. 524330d4810SMauro Carvalho Chehab 525330d4810SMauro Carvalho ChehabFor testing purposes, you can trigger a crash by using "ALT-SysRq-c", 526330d4810SMauro Carvalho Chehab"echo c > /proc/sysrq-trigger" or write a module to force the panic. 527330d4810SMauro Carvalho Chehab 528330d4810SMauro Carvalho ChehabWrite Out the Dump File 529330d4810SMauro Carvalho Chehab======================= 530330d4810SMauro Carvalho Chehab 531330d4810SMauro Carvalho ChehabAfter the dump-capture kernel is booted, write out the dump file with 532330d4810SMauro Carvalho Chehabthe following command:: 533330d4810SMauro Carvalho Chehab 534330d4810SMauro Carvalho Chehab cp /proc/vmcore <dump-file> 535330d4810SMauro Carvalho Chehab 536*ae6694c1STiezhu Yangor use scp to write out the dump file between hosts on a network, e.g:: 537*ae6694c1STiezhu Yang 538*ae6694c1STiezhu Yang scp /proc/vmcore remote_username@remote_ip:<dump-file> 539*ae6694c1STiezhu Yang 540b1f4c363SBaoquan HeYou can also use makedumpfile utility to write out the dump file 541b1f4c363SBaoquan Hewith specified options to filter out unwanted contents, e.g:: 542b1f4c363SBaoquan He 543b1f4c363SBaoquan He makedumpfile -l --message-level 1 -d 31 /proc/vmcore <dump-file> 544330d4810SMauro Carvalho Chehab 545330d4810SMauro Carvalho ChehabAnalysis 546330d4810SMauro Carvalho Chehab======== 547330d4810SMauro Carvalho Chehab 548330d4810SMauro Carvalho ChehabBefore analyzing the dump image, you should reboot into a stable kernel. 549330d4810SMauro Carvalho Chehab 550330d4810SMauro Carvalho ChehabYou can do limited analysis using GDB on the dump file copied out of 551330d4810SMauro Carvalho Chehab/proc/vmcore. Use the debug vmlinux built with -g and run the following 552330d4810SMauro Carvalho Chehabcommand:: 553330d4810SMauro Carvalho Chehab 554330d4810SMauro Carvalho Chehab gdb vmlinux <dump-file> 555330d4810SMauro Carvalho Chehab 556330d4810SMauro Carvalho ChehabStack trace for the task on processor 0, register display, and memory 557330d4810SMauro Carvalho Chehabdisplay work fine. 558330d4810SMauro Carvalho Chehab 559330d4810SMauro Carvalho ChehabNote: GDB cannot analyze core files generated in ELF64 format for x86. 560330d4810SMauro Carvalho ChehabOn systems with a maximum of 4GB of memory, you can generate 561330d4810SMauro Carvalho ChehabELF32-format headers using the --elf32-core-headers kernel option on the 562330d4810SMauro Carvalho Chehabdump kernel. 563330d4810SMauro Carvalho Chehab 564330d4810SMauro Carvalho ChehabYou can also use the Crash utility to analyze dump files in Kdump 5651d11c35eSlijiangformat. Crash is available at the following URL: 566330d4810SMauro Carvalho Chehab 5671d11c35eSlijiang https://github.com/crash-utility/crash 5681d11c35eSlijiang 5691d11c35eSlijiangCrash document can be found at: 5701d11c35eSlijiang https://crash-utility.github.io/ 571330d4810SMauro Carvalho Chehab 572330d4810SMauro Carvalho ChehabTrigger Kdump on WARN() 573330d4810SMauro Carvalho Chehab======================= 574330d4810SMauro Carvalho Chehab 575330d4810SMauro Carvalho ChehabThe kernel parameter, panic_on_warn, calls panic() in all WARN() paths. This 576330d4810SMauro Carvalho Chehabwill cause a kdump to occur at the panic() call. In cases where a user wants 577330d4810SMauro Carvalho Chehabto specify this during runtime, /proc/sys/kernel/panic_on_warn can be set to 1 578330d4810SMauro Carvalho Chehabto achieve the same behaviour. 579330d4810SMauro Carvalho Chehab 580db38d5c1SRafael AquiniTrigger Kdump on add_taint() 581db38d5c1SRafael Aquini============================ 582db38d5c1SRafael Aquini 583db38d5c1SRafael AquiniThe kernel parameter panic_on_taint facilitates a conditional call to panic() 584db38d5c1SRafael Aquinifrom within add_taint() whenever the value set in this bitmask matches with the 585db38d5c1SRafael Aquinibit flag being set by add_taint(). 586db38d5c1SRafael AquiniThis will cause a kdump to occur at the add_taint()->panic() call. 587db38d5c1SRafael Aquini 588330d4810SMauro Carvalho ChehabContact 589330d4810SMauro Carvalho Chehab======= 590330d4810SMauro Carvalho Chehab 591b1f4c363SBaoquan He- kexec@lists.infradead.org 592330d4810SMauro Carvalho Chehab 593330d4810SMauro Carvalho ChehabGDB macros 594330d4810SMauro Carvalho Chehab========== 595330d4810SMauro Carvalho Chehab 596330d4810SMauro Carvalho Chehab.. include:: gdbmacros.txt 597330d4810SMauro Carvalho Chehab :literal: 598