xref: /OK3568_Linux_fs/kernel/Documentation/admin-guide/kdump/kdump.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun================================================================
2*4882a593SmuzhiyunDocumentation for Kdump - The kexec-based Crash Dumping Solution
3*4882a593Smuzhiyun================================================================
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunThis document includes overview, setup and installation, and analysis
6*4882a593Smuzhiyuninformation.
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunOverview
9*4882a593Smuzhiyun========
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunKdump uses kexec to quickly boot to a dump-capture kernel whenever a
12*4882a593Smuzhiyundump of the system kernel's memory needs to be taken (for example, when
13*4882a593Smuzhiyunthe system panics). The system kernel's memory image is preserved across
14*4882a593Smuzhiyunthe reboot and is accessible to the dump-capture kernel.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunYou can use common commands, such as cp and scp, to copy the
17*4882a593Smuzhiyunmemory image to a dump file on the local disk, or across the network to
18*4882a593Smuzhiyuna remote system.
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunKdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
21*4882a593Smuzhiyuns390x, arm and arm64 architectures.
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunWhen the system kernel boots, it reserves a small section of memory for
24*4882a593Smuzhiyunthe dump-capture kernel. This ensures that ongoing Direct Memory Access
25*4882a593Smuzhiyun(DMA) from the system kernel does not corrupt the dump-capture kernel.
26*4882a593SmuzhiyunThe kexec -p command loads the dump-capture kernel into this reserved
27*4882a593Smuzhiyunmemory.
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunOn x86 machines, the first 640 KB of physical memory is needed to boot,
30*4882a593Smuzhiyunregardless of where the kernel loads. Therefore, kexec backs up this
31*4882a593Smuzhiyunregion just before rebooting into the dump-capture kernel.
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunSimilarly on PPC64 machines first 32KB of physical memory is needed for
34*4882a593Smuzhiyunbooting regardless of where the kernel is loaded and to support 64K page
35*4882a593Smuzhiyunsize kexec backs up the first 64KB memory.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunFor s390x, when kdump is triggered, the crashkernel region is exchanged
38*4882a593Smuzhiyunwith the region [0, crashkernel region size] and then the kdump kernel
39*4882a593Smuzhiyunruns in [0, crashkernel region size]. Therefore no relocatable kernel is
40*4882a593Smuzhiyunneeded for s390x.
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunAll of the necessary information about the system kernel's core image is
43*4882a593Smuzhiyunencoded in the ELF format, and stored in a reserved area of memory
44*4882a593Smuzhiyunbefore a crash. The physical address of the start of the ELF header is
45*4882a593Smuzhiyunpassed to the dump-capture kernel through the elfcorehdr= boot
46*4882a593Smuzhiyunparameter. Optionally the size of the ELF header can also be passed
47*4882a593Smuzhiyunwhen using the elfcorehdr=[size[KMG]@]offset[KMG] syntax.
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunWith the dump-capture kernel, you can access the memory image through
51*4882a593Smuzhiyun/proc/vmcore. This exports the dump as an ELF-format file that you can
52*4882a593Smuzhiyunwrite out using file copy commands such as cp or scp. Further, you can
53*4882a593Smuzhiyunuse analysis tools such as the GNU Debugger (GDB) and the Crash tool to
54*4882a593Smuzhiyundebug the dump file. This method ensures that the dump pages are correctly
55*4882a593Smuzhiyunordered.
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun
58*4882a593SmuzhiyunSetup and Installation
59*4882a593Smuzhiyun======================
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunInstall kexec-tools
62*4882a593Smuzhiyun-------------------
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun1) Login as the root user.
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun2) Download the kexec-tools user-space package from the following URL:
67*4882a593Smuzhiyun
68*4882a593Smuzhiyunhttp://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools.tar.gz
69*4882a593Smuzhiyun
70*4882a593SmuzhiyunThis is a symlink to the latest version.
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunThe latest kexec-tools git tree is available at:
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun- git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
75*4882a593Smuzhiyun- http://www.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
76*4882a593Smuzhiyun
77*4882a593SmuzhiyunThere is also a gitweb interface available at
78*4882a593Smuzhiyunhttp://www.kernel.org/git/?p=utils/kernel/kexec/kexec-tools.git
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunMore information about kexec-tools can be found at
81*4882a593Smuzhiyunhttp://horms.net/projects/kexec/
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun3) Unpack the tarball with the tar command, as follows::
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun	tar xvpzf kexec-tools.tar.gz
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun4) Change to the kexec-tools directory, as follows::
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun	cd kexec-tools-VERSION
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun5) Configure the package, as follows::
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun	./configure
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun6) Compile the package, as follows::
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun	make
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun7) Install the package, as follows::
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun	make install
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun
104*4882a593SmuzhiyunBuild the system and dump-capture kernels
105*4882a593Smuzhiyun-----------------------------------------
106*4882a593SmuzhiyunThere are two possible methods of using Kdump.
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun1) Build a separate custom dump-capture kernel for capturing the
109*4882a593Smuzhiyun   kernel core dump.
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun2) Or use the system kernel binary itself as dump-capture kernel and there is
112*4882a593Smuzhiyun   no need to build a separate dump-capture kernel. This is possible
113*4882a593Smuzhiyun   only with the architectures which support a relocatable kernel. As
114*4882a593Smuzhiyun   of today, i386, x86_64, ppc64, ia64, arm and arm64 architectures support
115*4882a593Smuzhiyun   relocatable kernel.
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunBuilding a relocatable kernel is advantageous from the point of view that
118*4882a593Smuzhiyunone does not have to build a second kernel for capturing the dump. But
119*4882a593Smuzhiyunat the same time one might want to build a custom dump capture kernel
120*4882a593Smuzhiyunsuitable to his needs.
121*4882a593Smuzhiyun
122*4882a593SmuzhiyunFollowing are the configuration setting required for system and
123*4882a593Smuzhiyundump-capture kernels for enabling kdump support.
124*4882a593Smuzhiyun
125*4882a593SmuzhiyunSystem kernel config options
126*4882a593Smuzhiyun----------------------------
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun1) Enable "kexec system call" in "Processor type and features."::
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun	CONFIG_KEXEC=y
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun2) Enable "sysfs file system support" in "Filesystem" -> "Pseudo
133*4882a593Smuzhiyun   filesystems." This is usually enabled by default::
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun	CONFIG_SYSFS=y
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun   Note that "sysfs file system support" might not appear in the "Pseudo
138*4882a593Smuzhiyun   filesystems" menu if "Configure standard kernel features (for small
139*4882a593Smuzhiyun   systems)" is not enabled in "General Setup." In this case, check the
140*4882a593Smuzhiyun   .config file itself to ensure that sysfs is turned on, as follows::
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun	grep 'CONFIG_SYSFS' .config
143*4882a593Smuzhiyun
144*4882a593Smuzhiyun3) Enable "Compile the kernel with debug info" in "Kernel hacking."::
145*4882a593Smuzhiyun
146*4882a593Smuzhiyun	CONFIG_DEBUG_INFO=Y
147*4882a593Smuzhiyun
148*4882a593Smuzhiyun   This causes the kernel to be built with debug symbols. The dump
149*4882a593Smuzhiyun   analysis tools require a vmlinux with debug symbols in order to read
150*4882a593Smuzhiyun   and analyze a dump file.
151*4882a593Smuzhiyun
152*4882a593SmuzhiyunDump-capture kernel config options (Arch Independent)
153*4882a593Smuzhiyun-----------------------------------------------------
154*4882a593Smuzhiyun
155*4882a593Smuzhiyun1) Enable "kernel crash dumps" support under "Processor type and
156*4882a593Smuzhiyun   features"::
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun	CONFIG_CRASH_DUMP=y
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun2) Enable "/proc/vmcore support" under "Filesystems" -> "Pseudo filesystems"::
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun	CONFIG_PROC_VMCORE=y
163*4882a593Smuzhiyun
164*4882a593Smuzhiyun   (CONFIG_PROC_VMCORE is set by default when CONFIG_CRASH_DUMP is selected.)
165*4882a593Smuzhiyun
166*4882a593SmuzhiyunDump-capture kernel config options (Arch Dependent, i386 and x86_64)
167*4882a593Smuzhiyun--------------------------------------------------------------------
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun1) On i386, enable high memory support under "Processor type and
170*4882a593Smuzhiyun   features"::
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun	CONFIG_HIGHMEM64G=y
173*4882a593Smuzhiyun
174*4882a593Smuzhiyun   or::
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun	CONFIG_HIGHMEM4G
177*4882a593Smuzhiyun
178*4882a593Smuzhiyun2) On i386 and x86_64, disable symmetric multi-processing support
179*4882a593Smuzhiyun   under "Processor type and features"::
180*4882a593Smuzhiyun
181*4882a593Smuzhiyun	CONFIG_SMP=n
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun   (If CONFIG_SMP=y, then specify maxcpus=1 on the kernel command line
184*4882a593Smuzhiyun   when loading the dump-capture kernel, see section "Load the Dump-capture
185*4882a593Smuzhiyun   Kernel".)
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun3) If one wants to build and use a relocatable kernel,
188*4882a593Smuzhiyun   Enable "Build a relocatable kernel" support under "Processor type and
189*4882a593Smuzhiyun   features"::
190*4882a593Smuzhiyun
191*4882a593Smuzhiyun	CONFIG_RELOCATABLE=y
192*4882a593Smuzhiyun
193*4882a593Smuzhiyun4) Use a suitable value for "Physical address where the kernel is
194*4882a593Smuzhiyun   loaded" (under "Processor type and features"). This only appears when
195*4882a593Smuzhiyun   "kernel crash dumps" is enabled. A suitable value depends upon
196*4882a593Smuzhiyun   whether kernel is relocatable or not.
197*4882a593Smuzhiyun
198*4882a593Smuzhiyun   If you are using a relocatable kernel use CONFIG_PHYSICAL_START=0x100000
199*4882a593Smuzhiyun   This will compile the kernel for physical address 1MB, but given the fact
200*4882a593Smuzhiyun   kernel is relocatable, it can be run from any physical address hence
201*4882a593Smuzhiyun   kexec boot loader will load it in memory region reserved for dump-capture
202*4882a593Smuzhiyun   kernel.
203*4882a593Smuzhiyun
204*4882a593Smuzhiyun   Otherwise it should be the start of memory region reserved for
205*4882a593Smuzhiyun   second kernel using boot parameter "crashkernel=Y@X". Here X is
206*4882a593Smuzhiyun   start of memory region reserved for dump-capture kernel.
207*4882a593Smuzhiyun   Generally X is 16MB (0x1000000). So you can set
208*4882a593Smuzhiyun   CONFIG_PHYSICAL_START=0x1000000
209*4882a593Smuzhiyun
210*4882a593Smuzhiyun5) Make and install the kernel and its modules. DO NOT add this kernel
211*4882a593Smuzhiyun   to the boot loader configuration files.
212*4882a593Smuzhiyun
213*4882a593SmuzhiyunDump-capture kernel config options (Arch Dependent, ppc64)
214*4882a593Smuzhiyun----------------------------------------------------------
215*4882a593Smuzhiyun
216*4882a593Smuzhiyun1) Enable "Build a kdump crash kernel" support under "Kernel" options::
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun	CONFIG_CRASH_DUMP=y
219*4882a593Smuzhiyun
220*4882a593Smuzhiyun2)   Enable "Build a relocatable kernel" support::
221*4882a593Smuzhiyun
222*4882a593Smuzhiyun	CONFIG_RELOCATABLE=y
223*4882a593Smuzhiyun
224*4882a593Smuzhiyun   Make and install the kernel and its modules.
225*4882a593Smuzhiyun
226*4882a593SmuzhiyunDump-capture kernel config options (Arch Dependent, ia64)
227*4882a593Smuzhiyun----------------------------------------------------------
228*4882a593Smuzhiyun
229*4882a593Smuzhiyun- No specific options are required to create a dump-capture kernel
230*4882a593Smuzhiyun  for ia64, other than those specified in the arch independent section
231*4882a593Smuzhiyun  above. This means that it is possible to use the system kernel
232*4882a593Smuzhiyun  as a dump-capture kernel if desired.
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun  The crashkernel region can be automatically placed by the system
235*4882a593Smuzhiyun  kernel at run time. This is done by specifying the base address as 0,
236*4882a593Smuzhiyun  or omitting it all together::
237*4882a593Smuzhiyun
238*4882a593Smuzhiyun	crashkernel=256M@0
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun  or::
241*4882a593Smuzhiyun
242*4882a593Smuzhiyun	crashkernel=256M
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun  If the start address is specified, note that the start address of the
245*4882a593Smuzhiyun  kernel will be aligned to 64Mb, so if the start address is not then
246*4882a593Smuzhiyun  any space below the alignment point will be wasted.
247*4882a593Smuzhiyun
248*4882a593SmuzhiyunDump-capture kernel config options (Arch Dependent, arm)
249*4882a593Smuzhiyun----------------------------------------------------------
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun-   To use a relocatable kernel,
252*4882a593Smuzhiyun    Enable "AUTO_ZRELADDR" support under "Boot" options::
253*4882a593Smuzhiyun
254*4882a593Smuzhiyun	AUTO_ZRELADDR=y
255*4882a593Smuzhiyun
256*4882a593SmuzhiyunDump-capture kernel config options (Arch Dependent, arm64)
257*4882a593Smuzhiyun----------------------------------------------------------
258*4882a593Smuzhiyun
259*4882a593Smuzhiyun- Please note that kvm of the dump-capture kernel will not be enabled
260*4882a593Smuzhiyun  on non-VHE systems even if it is configured. This is because the CPU
261*4882a593Smuzhiyun  will not be reset to EL2 on panic.
262*4882a593Smuzhiyun
263*4882a593SmuzhiyunExtended crashkernel syntax
264*4882a593Smuzhiyun===========================
265*4882a593Smuzhiyun
266*4882a593SmuzhiyunWhile the "crashkernel=size[@offset]" syntax is sufficient for most
267*4882a593Smuzhiyunconfigurations, sometimes it's handy to have the reserved memory dependent
268*4882a593Smuzhiyunon the value of System RAM -- that's mostly for distributors that pre-setup
269*4882a593Smuzhiyunthe kernel command line to avoid a unbootable system after some memory has
270*4882a593Smuzhiyunbeen removed from the machine.
271*4882a593Smuzhiyun
272*4882a593SmuzhiyunThe syntax is::
273*4882a593Smuzhiyun
274*4882a593Smuzhiyun    crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset]
275*4882a593Smuzhiyun    range=start-[end]
276*4882a593Smuzhiyun
277*4882a593SmuzhiyunFor example::
278*4882a593Smuzhiyun
279*4882a593Smuzhiyun    crashkernel=512M-2G:64M,2G-:128M
280*4882a593Smuzhiyun
281*4882a593SmuzhiyunThis would mean:
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun    1) if the RAM is smaller than 512M, then don't reserve anything
284*4882a593Smuzhiyun       (this is the "rescue" case)
285*4882a593Smuzhiyun    2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M
286*4882a593Smuzhiyun    3) if the RAM size is larger than 2G, then reserve 128M
287*4882a593Smuzhiyun
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun
290*4882a593SmuzhiyunBoot into System Kernel
291*4882a593Smuzhiyun=======================
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun1) Update the boot loader (such as grub, yaboot, or lilo) configuration
294*4882a593Smuzhiyun   files as necessary.
295*4882a593Smuzhiyun
296*4882a593Smuzhiyun2) Boot the system kernel with the boot parameter "crashkernel=Y@X",
297*4882a593Smuzhiyun   where Y specifies how much memory to reserve for the dump-capture kernel
298*4882a593Smuzhiyun   and X specifies the beginning of this reserved memory. For example,
299*4882a593Smuzhiyun   "crashkernel=64M@16M" tells the system kernel to reserve 64 MB of memory
300*4882a593Smuzhiyun   starting at physical address 0x01000000 (16MB) for the dump-capture kernel.
301*4882a593Smuzhiyun
302*4882a593Smuzhiyun   On x86 and x86_64, use "crashkernel=64M@16M".
303*4882a593Smuzhiyun
304*4882a593Smuzhiyun   On ppc64, use "crashkernel=128M@32M".
305*4882a593Smuzhiyun
306*4882a593Smuzhiyun   On ia64, 256M@256M is a generous value that typically works.
307*4882a593Smuzhiyun   The region may be automatically placed on ia64, see the
308*4882a593Smuzhiyun   dump-capture kernel config option notes above.
309*4882a593Smuzhiyun   If use sparse memory, the size should be rounded to GRANULE boundaries.
310*4882a593Smuzhiyun
311*4882a593Smuzhiyun   On s390x, typically use "crashkernel=xxM". The value of xx is dependent
312*4882a593Smuzhiyun   on the memory consumption of the kdump system. In general this is not
313*4882a593Smuzhiyun   dependent on the memory size of the production system.
314*4882a593Smuzhiyun
315*4882a593Smuzhiyun   On arm, the use of "crashkernel=Y@X" is no longer necessary; the
316*4882a593Smuzhiyun   kernel will automatically locate the crash kernel image within the
317*4882a593Smuzhiyun   first 512MB of RAM if X is not given.
318*4882a593Smuzhiyun
319*4882a593Smuzhiyun   On arm64, use "crashkernel=Y[@X]".  Note that the start address of
320*4882a593Smuzhiyun   the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000).
321*4882a593Smuzhiyun
322*4882a593SmuzhiyunLoad the Dump-capture Kernel
323*4882a593Smuzhiyun============================
324*4882a593Smuzhiyun
325*4882a593SmuzhiyunAfter booting to the system kernel, dump-capture kernel needs to be
326*4882a593Smuzhiyunloaded.
327*4882a593Smuzhiyun
328*4882a593SmuzhiyunBased on the architecture and type of image (relocatable or not), one
329*4882a593Smuzhiyuncan choose to load the uncompressed vmlinux or compressed bzImage/vmlinuz
330*4882a593Smuzhiyunof dump-capture kernel. Following is the summary.
331*4882a593Smuzhiyun
332*4882a593SmuzhiyunFor i386 and x86_64:
333*4882a593Smuzhiyun
334*4882a593Smuzhiyun	- Use vmlinux if kernel is not relocatable.
335*4882a593Smuzhiyun	- Use bzImage/vmlinuz if kernel is relocatable.
336*4882a593Smuzhiyun
337*4882a593SmuzhiyunFor ppc64:
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun	- Use vmlinux
340*4882a593Smuzhiyun
341*4882a593SmuzhiyunFor ia64:
342*4882a593Smuzhiyun
343*4882a593Smuzhiyun	- Use vmlinux or vmlinuz.gz
344*4882a593Smuzhiyun
345*4882a593SmuzhiyunFor s390x:
346*4882a593Smuzhiyun
347*4882a593Smuzhiyun	- Use image or bzImage
348*4882a593Smuzhiyun
349*4882a593SmuzhiyunFor arm:
350*4882a593Smuzhiyun
351*4882a593Smuzhiyun	- Use zImage
352*4882a593Smuzhiyun
353*4882a593SmuzhiyunFor arm64:
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun	- Use vmlinux or Image
356*4882a593Smuzhiyun
357*4882a593SmuzhiyunIf you are using an uncompressed vmlinux image then use following command
358*4882a593Smuzhiyunto load dump-capture kernel::
359*4882a593Smuzhiyun
360*4882a593Smuzhiyun   kexec -p <dump-capture-kernel-vmlinux-image> \
361*4882a593Smuzhiyun   --initrd=<initrd-for-dump-capture-kernel> --args-linux \
362*4882a593Smuzhiyun   --append="root=<root-dev> <arch-specific-options>"
363*4882a593Smuzhiyun
364*4882a593SmuzhiyunIf you are using a compressed bzImage/vmlinuz, then use following command
365*4882a593Smuzhiyunto load dump-capture kernel::
366*4882a593Smuzhiyun
367*4882a593Smuzhiyun   kexec -p <dump-capture-kernel-bzImage> \
368*4882a593Smuzhiyun   --initrd=<initrd-for-dump-capture-kernel> \
369*4882a593Smuzhiyun   --append="root=<root-dev> <arch-specific-options>"
370*4882a593Smuzhiyun
371*4882a593SmuzhiyunIf you are using a compressed zImage, then use following command
372*4882a593Smuzhiyunto load dump-capture kernel::
373*4882a593Smuzhiyun
374*4882a593Smuzhiyun   kexec --type zImage -p <dump-capture-kernel-bzImage> \
375*4882a593Smuzhiyun   --initrd=<initrd-for-dump-capture-kernel> \
376*4882a593Smuzhiyun   --dtb=<dtb-for-dump-capture-kernel> \
377*4882a593Smuzhiyun   --append="root=<root-dev> <arch-specific-options>"
378*4882a593Smuzhiyun
379*4882a593SmuzhiyunIf you are using an uncompressed Image, then use following command
380*4882a593Smuzhiyunto load dump-capture kernel::
381*4882a593Smuzhiyun
382*4882a593Smuzhiyun   kexec -p <dump-capture-kernel-Image> \
383*4882a593Smuzhiyun   --initrd=<initrd-for-dump-capture-kernel> \
384*4882a593Smuzhiyun   --append="root=<root-dev> <arch-specific-options>"
385*4882a593Smuzhiyun
386*4882a593SmuzhiyunPlease note, that --args-linux does not need to be specified for ia64.
387*4882a593SmuzhiyunIt is planned to make this a no-op on that architecture, but for now
388*4882a593Smuzhiyunit should be omitted
389*4882a593Smuzhiyun
390*4882a593SmuzhiyunFollowing are the arch specific command line options to be used while
391*4882a593Smuzhiyunloading dump-capture kernel.
392*4882a593Smuzhiyun
393*4882a593SmuzhiyunFor i386, x86_64 and ia64:
394*4882a593Smuzhiyun
395*4882a593Smuzhiyun	"1 irqpoll maxcpus=1 reset_devices"
396*4882a593Smuzhiyun
397*4882a593SmuzhiyunFor ppc64:
398*4882a593Smuzhiyun
399*4882a593Smuzhiyun	"1 maxcpus=1 noirqdistrib reset_devices"
400*4882a593Smuzhiyun
401*4882a593SmuzhiyunFor s390x:
402*4882a593Smuzhiyun
403*4882a593Smuzhiyun	"1 maxcpus=1 cgroup_disable=memory"
404*4882a593Smuzhiyun
405*4882a593SmuzhiyunFor arm:
406*4882a593Smuzhiyun
407*4882a593Smuzhiyun	"1 maxcpus=1 reset_devices"
408*4882a593Smuzhiyun
409*4882a593SmuzhiyunFor arm64:
410*4882a593Smuzhiyun
411*4882a593Smuzhiyun	"1 maxcpus=1 reset_devices"
412*4882a593Smuzhiyun
413*4882a593SmuzhiyunNotes on loading the dump-capture kernel:
414*4882a593Smuzhiyun
415*4882a593Smuzhiyun* By default, the ELF headers are stored in ELF64 format to support
416*4882a593Smuzhiyun  systems with more than 4GB memory. On i386, kexec automatically checks if
417*4882a593Smuzhiyun  the physical RAM size exceeds the 4 GB limit and if not, uses ELF32.
418*4882a593Smuzhiyun  So, on non-PAE systems, ELF32 is always used.
419*4882a593Smuzhiyun
420*4882a593Smuzhiyun  The --elf32-core-headers option can be used to force the generation of ELF32
421*4882a593Smuzhiyun  headers. This is necessary because GDB currently cannot open vmcore files
422*4882a593Smuzhiyun  with ELF64 headers on 32-bit systems.
423*4882a593Smuzhiyun
424*4882a593Smuzhiyun* The "irqpoll" boot parameter reduces driver initialization failures
425*4882a593Smuzhiyun  due to shared interrupts in the dump-capture kernel.
426*4882a593Smuzhiyun
427*4882a593Smuzhiyun* You must specify <root-dev> in the format corresponding to the root
428*4882a593Smuzhiyun  device name in the output of mount command.
429*4882a593Smuzhiyun
430*4882a593Smuzhiyun* Boot parameter "1" boots the dump-capture kernel into single-user
431*4882a593Smuzhiyun  mode without networking. If you want networking, use "3".
432*4882a593Smuzhiyun
433*4882a593Smuzhiyun* We generally don't have to bring up a SMP kernel just to capture the
434*4882a593Smuzhiyun  dump. Hence generally it is useful either to build a UP dump-capture
435*4882a593Smuzhiyun  kernel or specify maxcpus=1 option while loading dump-capture kernel.
436*4882a593Smuzhiyun  Note, though maxcpus always works, you had better replace it with
437*4882a593Smuzhiyun  nr_cpus to save memory if supported by the current ARCH, such as x86.
438*4882a593Smuzhiyun
439*4882a593Smuzhiyun* You should enable multi-cpu support in dump-capture kernel if you intend
440*4882a593Smuzhiyun  to use multi-thread programs with it, such as parallel dump feature of
441*4882a593Smuzhiyun  makedumpfile. Otherwise, the multi-thread program may have a great
442*4882a593Smuzhiyun  performance degradation. To enable multi-cpu support, you should bring up an
443*4882a593Smuzhiyun  SMP dump-capture kernel and specify maxcpus/nr_cpus, disable_cpu_apicid=[X]
444*4882a593Smuzhiyun  options while loading it.
445*4882a593Smuzhiyun
446*4882a593Smuzhiyun* For s390x there are two kdump modes: If a ELF header is specified with
447*4882a593Smuzhiyun  the elfcorehdr= kernel parameter, it is used by the kdump kernel as it
448*4882a593Smuzhiyun  is done on all other architectures. If no elfcorehdr= kernel parameter is
449*4882a593Smuzhiyun  specified, the s390x kdump kernel dynamically creates the header. The
450*4882a593Smuzhiyun  second mode has the advantage that for CPU and memory hotplug, kdump has
451*4882a593Smuzhiyun  not to be reloaded with kexec_load().
452*4882a593Smuzhiyun
453*4882a593Smuzhiyun* For s390x systems with many attached devices the "cio_ignore" kernel
454*4882a593Smuzhiyun  parameter should be used for the kdump kernel in order to prevent allocation
455*4882a593Smuzhiyun  of kernel memory for devices that are not relevant for kdump. The same
456*4882a593Smuzhiyun  applies to systems that use SCSI/FCP devices. In that case the
457*4882a593Smuzhiyun  "allow_lun_scan" zfcp module parameter should be set to zero before
458*4882a593Smuzhiyun  setting FCP devices online.
459*4882a593Smuzhiyun
460*4882a593SmuzhiyunKernel Panic
461*4882a593Smuzhiyun============
462*4882a593Smuzhiyun
463*4882a593SmuzhiyunAfter successfully loading the dump-capture kernel as previously
464*4882a593Smuzhiyundescribed, the system will reboot into the dump-capture kernel if a
465*4882a593Smuzhiyunsystem crash is triggered.  Trigger points are located in panic(),
466*4882a593Smuzhiyundie(), die_nmi() and in the sysrq handler (ALT-SysRq-c).
467*4882a593Smuzhiyun
468*4882a593SmuzhiyunThe following conditions will execute a crash trigger point:
469*4882a593Smuzhiyun
470*4882a593SmuzhiyunIf a hard lockup is detected and "NMI watchdog" is configured, the system
471*4882a593Smuzhiyunwill boot into the dump-capture kernel ( die_nmi() ).
472*4882a593Smuzhiyun
473*4882a593SmuzhiyunIf die() is called, and it happens to be a thread with pid 0 or 1, or die()
474*4882a593Smuzhiyunis called inside interrupt context or die() is called and panic_on_oops is set,
475*4882a593Smuzhiyunthe system will boot into the dump-capture kernel.
476*4882a593Smuzhiyun
477*4882a593SmuzhiyunOn powerpc systems when a soft-reset is generated, die() is called by all cpus
478*4882a593Smuzhiyunand the system will boot into the dump-capture kernel.
479*4882a593Smuzhiyun
480*4882a593SmuzhiyunFor testing purposes, you can trigger a crash by using "ALT-SysRq-c",
481*4882a593Smuzhiyun"echo c > /proc/sysrq-trigger" or write a module to force the panic.
482*4882a593Smuzhiyun
483*4882a593SmuzhiyunWrite Out the Dump File
484*4882a593Smuzhiyun=======================
485*4882a593Smuzhiyun
486*4882a593SmuzhiyunAfter the dump-capture kernel is booted, write out the dump file with
487*4882a593Smuzhiyunthe following command::
488*4882a593Smuzhiyun
489*4882a593Smuzhiyun   cp /proc/vmcore <dump-file>
490*4882a593Smuzhiyun
491*4882a593Smuzhiyun
492*4882a593SmuzhiyunAnalysis
493*4882a593Smuzhiyun========
494*4882a593Smuzhiyun
495*4882a593SmuzhiyunBefore analyzing the dump image, you should reboot into a stable kernel.
496*4882a593Smuzhiyun
497*4882a593SmuzhiyunYou can do limited analysis using GDB on the dump file copied out of
498*4882a593Smuzhiyun/proc/vmcore. Use the debug vmlinux built with -g and run the following
499*4882a593Smuzhiyuncommand::
500*4882a593Smuzhiyun
501*4882a593Smuzhiyun   gdb vmlinux <dump-file>
502*4882a593Smuzhiyun
503*4882a593SmuzhiyunStack trace for the task on processor 0, register display, and memory
504*4882a593Smuzhiyundisplay work fine.
505*4882a593Smuzhiyun
506*4882a593SmuzhiyunNote: GDB cannot analyze core files generated in ELF64 format for x86.
507*4882a593SmuzhiyunOn systems with a maximum of 4GB of memory, you can generate
508*4882a593SmuzhiyunELF32-format headers using the --elf32-core-headers kernel option on the
509*4882a593Smuzhiyundump kernel.
510*4882a593Smuzhiyun
511*4882a593SmuzhiyunYou can also use the Crash utility to analyze dump files in Kdump
512*4882a593Smuzhiyunformat. Crash is available at the following URL:
513*4882a593Smuzhiyun
514*4882a593Smuzhiyun   https://github.com/crash-utility/crash
515*4882a593Smuzhiyun
516*4882a593SmuzhiyunCrash document can be found at:
517*4882a593Smuzhiyun   https://crash-utility.github.io/
518*4882a593Smuzhiyun
519*4882a593SmuzhiyunTrigger Kdump on WARN()
520*4882a593Smuzhiyun=======================
521*4882a593Smuzhiyun
522*4882a593SmuzhiyunThe kernel parameter, panic_on_warn, calls panic() in all WARN() paths.  This
523*4882a593Smuzhiyunwill cause a kdump to occur at the panic() call.  In cases where a user wants
524*4882a593Smuzhiyunto specify this during runtime, /proc/sys/kernel/panic_on_warn can be set to 1
525*4882a593Smuzhiyunto achieve the same behaviour.
526*4882a593Smuzhiyun
527*4882a593SmuzhiyunTrigger Kdump on add_taint()
528*4882a593Smuzhiyun============================
529*4882a593Smuzhiyun
530*4882a593SmuzhiyunThe kernel parameter panic_on_taint facilitates a conditional call to panic()
531*4882a593Smuzhiyunfrom within add_taint() whenever the value set in this bitmask matches with the
532*4882a593Smuzhiyunbit flag being set by add_taint().
533*4882a593SmuzhiyunThis will cause a kdump to occur at the add_taint()->panic() call.
534*4882a593Smuzhiyun
535*4882a593SmuzhiyunContact
536*4882a593Smuzhiyun=======
537*4882a593Smuzhiyun
538*4882a593Smuzhiyun- Vivek Goyal (vgoyal@redhat.com)
539*4882a593Smuzhiyun- Maneesh Soni (maneesh@in.ibm.com)
540*4882a593Smuzhiyun
541*4882a593SmuzhiyunGDB macros
542*4882a593Smuzhiyun==========
543*4882a593Smuzhiyun
544*4882a593Smuzhiyun.. include:: gdbmacros.txt
545*4882a593Smuzhiyun   :literal:
546