firmware-assisted-dump.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. Firmware-Assisted Dump
  2. ------------------------
  3. July 2011
  4. The goal of firmware-assisted dump is to enable the dump of
  5. a crashed system, and to do so from a fully-reset system, and
  6. to minimize the total elapsed time until the system is back
  7. in production use.
  8. - Firmware assisted dump (fadump) infrastructure is intended to replace
  9. the existing phyp assisted dump.
  10. - Fadump uses the same firmware interfaces and memory reservation model
  11. as phyp assisted dump.
  12. - Unlike phyp dump, fadump exports the memory dump through /proc/vmcore
  13. in the ELF format in the same way as kdump. This helps us reuse the
  14. kdump infrastructure for dump capture and filtering.
  15. - Unlike phyp dump, userspace tool does not need to refer any sysfs
  16. interface while reading /proc/vmcore.
  17. - Unlike phyp dump, fadump allows user to release all the memory reserved
  18. for dump, with a single operation of echo 1 > /sys/kernel/fadump_release_mem.
  19. - Once enabled through kernel boot parameter, fadump can be
  20. started/stopped through /sys/kernel/fadump_registered interface (see
  21. sysfs files section below) and can be easily integrated with kdump
  22. service start/stop init scripts.
  23. Comparing with kdump or other strategies, firmware-assisted
  24. dump offers several strong, practical advantages:
  25. -- Unlike kdump, the system has been reset, and loaded
  26. with a fresh copy of the kernel. In particular,
  27. PCI and I/O devices have been reinitialized and are
  28. in a clean, consistent state.
  29. -- Once the dump is copied out, the memory that held the dump
  30. is immediately available to the running kernel. And therefore,
  31. unlike kdump, fadump doesn't need a 2nd reboot to get back
  32. the system to the production configuration.
  33. The above can only be accomplished by coordination with,
  34. and assistance from the Power firmware. The procedure is
  35. as follows:
  36. -- The first kernel registers the sections of memory with the
  37. Power firmware for dump preservation during OS initialization.
  38. These registered sections of memory are reserved by the first
  39. kernel during early boot.
  40. -- When a system crashes, the Power firmware will save
  41. the low memory (boot memory of size larger of 5% of system RAM
  42. or 256MB) of RAM to the previous registered region. It will
  43. also save system registers, and hardware PTE's.
  44. NOTE: The term 'boot memory' means size of the low memory chunk
  45. that is required for a kernel to boot successfully when
  46. booted with restricted memory. By default, the boot memory
  47. size will be the larger of 5% of system RAM or 256MB.
  48. Alternatively, user can also specify boot memory size
  49. through boot parameter 'crashkernel=' which will override
  50. the default calculated size. Use this option if default
  51. boot memory size is not sufficient for second kernel to
  52. boot successfully. For syntax of crashkernel= parameter,
  53. refer to Documentation/kdump/kdump.txt. If any offset is
  54. provided in crashkernel= parameter, it will be ignored
  55. as fadump uses a predefined offset to reserve memory
  56. for boot memory dump preservation in case of a crash.
  57. -- After the low memory (boot memory) area has been saved, the
  58. firmware will reset PCI and other hardware state. It will
  59. *not* clear the RAM. It will then launch the bootloader, as
  60. normal.
  61. -- The freshly booted kernel will notice that there is a new
  62. node (ibm,dump-kernel) in the device tree, indicating that
  63. there is crash data available from a previous boot. During
  64. the early boot OS will reserve rest of the memory above
  65. boot memory size effectively booting with restricted memory
  66. size. This will make sure that the second kernel will not
  67. touch any of the dump memory area.
  68. -- User-space tools will read /proc/vmcore to obtain the contents
  69. of memory, which holds the previous crashed kernel dump in ELF
  70. format. The userspace tools may copy this info to disk, or
  71. network, nas, san, iscsi, etc. as desired.
  72. -- Once the userspace tool is done saving dump, it will echo
  73. '1' to /sys/kernel/fadump_release_mem to release the reserved
  74. memory back to general use, except the memory required for
  75. next firmware-assisted dump registration.
  76. e.g.
  77. # echo 1 > /sys/kernel/fadump_release_mem
  78. Please note that the firmware-assisted dump feature
  79. is only available on Power6 and above systems with recent
  80. firmware versions.
  81. Implementation details:
  82. ----------------------
  83. During boot, a check is made to see if firmware supports
  84. this feature on that particular machine. If it does, then
  85. we check to see if an active dump is waiting for us. If yes
  86. then everything but boot memory size of RAM is reserved during
  87. early boot (See Fig. 2). This area is released once we finish
  88. collecting the dump from user land scripts (e.g. kdump scripts)
  89. that are run. If there is dump data, then the
  90. /sys/kernel/fadump_release_mem file is created, and the reserved
  91. memory is held.
  92. If there is no waiting dump data, then only the memory required
  93. to hold CPU state, HPTE region, boot memory dump and elfcore
  94. header, is usually reserved at an offset greater than boot memory
  95. size (see Fig. 1). This area is *not* released: this region will
  96. be kept permanently reserved, so that it can act as a receptacle
  97. for a copy of the boot memory content in addition to CPU state
  98. and HPTE region, in the case a crash does occur.
  99. o Memory Reservation during first kernel
  100. Low memory Top of memory
  101. 0 boot memory size |
  102. | | |<--Reserved dump area -->| |
  103. V V | Permanent Reservation | V
  104. +-----------+----------/ /---+---+----+-----------+----+------+
  105. | | |CPU|HPTE| DUMP |ELF | |
  106. +-----------+----------/ /---+---+----+-----------+----+------+
  107. | ^
  108. | |
  109. \ /
  110. -------------------------------------------
  111. Boot memory content gets transferred to
  112. reserved area by firmware at the time of
  113. crash
  114. Fig. 1
  115. o Memory Reservation during second kernel after crash
  116. Low memory Top of memory
  117. 0 boot memory size |
  118. | |<------------- Reserved dump area ----------- -->|
  119. V V V
  120. +-----------+----------/ /---+---+----+-----------+----+------+
  121. | | |CPU|HPTE| DUMP |ELF | |
  122. +-----------+----------/ /---+---+----+-----------+----+------+
  123. | |
  124. V V
  125. Used by second /proc/vmcore
  126. kernel to boot
  127. Fig. 2
  128. Currently the dump will be copied from /proc/vmcore to a
  129. a new file upon user intervention. The dump data available through
  130. /proc/vmcore will be in ELF format. Hence the existing kdump
  131. infrastructure (kdump scripts) to save the dump works fine with
  132. minor modifications.
  133. The tools to examine the dump will be same as the ones
  134. used for kdump.
  135. How to enable firmware-assisted dump (fadump):
  136. -------------------------------------
  137. 1. Set config option CONFIG_FA_DUMP=y and build kernel.
  138. 2. Boot into linux kernel with 'fadump=on' kernel cmdline option.
  139. 3. Optionally, user can also set 'crashkernel=' kernel cmdline
  140. to specify size of the memory to reserve for boot memory dump
  141. preservation.
  142. NOTE: 1. 'fadump_reserve_mem=' parameter has been deprecated. Instead
  143. use 'crashkernel=' to specify size of the memory to reserve
  144. for boot memory dump preservation.
  145. 2. If firmware-assisted dump fails to reserve memory then it
  146. will fallback to existing kdump mechanism if 'crashkernel='
  147. option is set at kernel cmdline.
  148. Sysfs/debugfs files:
  149. ------------
  150. Firmware-assisted dump feature uses sysfs file system to hold
  151. the control files and debugfs file to display memory reserved region.
  152. Here is the list of files under kernel sysfs:
  153. /sys/kernel/fadump_enabled
  154. This is used to display the fadump status.
  155. 0 = fadump is disabled
  156. 1 = fadump is enabled
  157. This interface can be used by kdump init scripts to identify if
  158. fadump is enabled in the kernel and act accordingly.
  159. /sys/kernel/fadump_registered
  160. This is used to display the fadump registration status as well
  161. as to control (start/stop) the fadump registration.
  162. 0 = fadump is not registered.
  163. 1 = fadump is registered and ready to handle system crash.
  164. To register fadump echo 1 > /sys/kernel/fadump_registered and
  165. echo 0 > /sys/kernel/fadump_registered for un-register and stop the
  166. fadump. Once the fadump is un-registered, the system crash will not
  167. be handled and vmcore will not be captured. This interface can be
  168. easily integrated with kdump service start/stop.
  169. /sys/kernel/fadump_release_mem
  170. This file is available only when fadump is active during
  171. second kernel. This is used to release the reserved memory
  172. region that are held for saving crash dump. To release the
  173. reserved memory echo 1 to it:
  174. echo 1 > /sys/kernel/fadump_release_mem
  175. After echo 1, the content of the /sys/kernel/debug/powerpc/fadump_region
  176. file will change to reflect the new memory reservations.
  177. The existing userspace tools (kdump infrastructure) can be easily
  178. enhanced to use this interface to release the memory reserved for
  179. dump and continue without 2nd reboot.
  180. Here is the list of files under powerpc debugfs:
  181. (Assuming debugfs is mounted on /sys/kernel/debug directory.)
  182. /sys/kernel/debug/powerpc/fadump_region
  183. This file shows the reserved memory regions if fadump is
  184. enabled otherwise this file is empty. The output format
  185. is:
  186. <region>: [<start>-<end>] <reserved-size> bytes, Dumped: <dump-size>
  187. e.g.
  188. Contents when fadump is registered during first kernel
  189. # cat /sys/kernel/debug/powerpc/fadump_region
  190. CPU : [0x0000006ffb0000-0x0000006fff001f] 0x40020 bytes, Dumped: 0x0
  191. HPTE: [0x0000006fff0020-0x0000006fff101f] 0x1000 bytes, Dumped: 0x0
  192. DUMP: [0x0000006fff1020-0x0000007fff101f] 0x10000000 bytes, Dumped: 0x0
  193. Contents when fadump is active during second kernel
  194. # cat /sys/kernel/debug/powerpc/fadump_region
  195. CPU : [0x0000006ffb0000-0x0000006fff001f] 0x40020 bytes, Dumped: 0x40020
  196. HPTE: [0x0000006fff0020-0x0000006fff101f] 0x1000 bytes, Dumped: 0x1000
  197. DUMP: [0x0000006fff1020-0x0000007fff101f] 0x10000000 bytes, Dumped: 0x10000000
  198. : [0x00000010000000-0x0000006ffaffff] 0x5ffb0000 bytes, Dumped: 0x5ffb0000
  199. NOTE: Please refer to Documentation/filesystems/debugfs.txt on
  200. how to mount the debugfs filesystem.
  201. TODO:
  202. -----
  203. o Need to come up with the better approach to find out more
  204. accurate boot memory size that is required for a kernel to
  205. boot successfully when booted with restricted memory.
  206. o The fadump implementation introduces a fadump crash info structure
  207. in the scratch area before the ELF core header. The idea of introducing
  208. this structure is to pass some important crash info data to the second
  209. kernel which will help second kernel to populate ELF core header with
  210. correct data before it gets exported through /proc/vmcore. The current
  211. design implementation does not address a possibility of introducing
  212. additional fields (in future) to this structure without affecting
  213. compatibility. Need to come up with the better approach to address this.
  214. The possible approaches are:
  215. 1. Introduce version field for version tracking, bump up the version
  216. whenever a new field is added to the structure in future. The version
  217. field can be used to find out what fields are valid for the current
  218. version of the structure.
  219. 2. Reserve the area of predefined size (say PAGE_SIZE) for this
  220. structure and have unused area as reserved (initialized to zero)
  221. for future field additions.
  222. The advantage of approach 1 over 2 is we don't need to reserve extra space.
  223. ---
  224. Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
  225. This document is based on the original documentation written for phyp
  226. assisted dump by Linas Vepstas and Manish Ahuja.