firmware-assisted-dump.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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 'fadump_reserve_mem=' which will
  50. override the default calculated size. Use this option
  51. if default boot memory size is not sufficient for second
  52. kernel to boot successfully.
  53. -- After the low memory (boot memory) area has been saved, the
  54. firmware will reset PCI and other hardware state. It will
  55. *not* clear the RAM. It will then launch the bootloader, as
  56. normal.
  57. -- The freshly booted kernel will notice that there is a new
  58. node (ibm,dump-kernel) in the device tree, indicating that
  59. there is crash data available from a previous boot. During
  60. the early boot OS will reserve rest of the memory above
  61. boot memory size effectively booting with restricted memory
  62. size. This will make sure that the second kernel will not
  63. touch any of the dump memory area.
  64. -- User-space tools will read /proc/vmcore to obtain the contents
  65. of memory, which holds the previous crashed kernel dump in ELF
  66. format. The userspace tools may copy this info to disk, or
  67. network, nas, san, iscsi, etc. as desired.
  68. -- Once the userspace tool is done saving dump, it will echo
  69. '1' to /sys/kernel/fadump_release_mem to release the reserved
  70. memory back to general use, except the memory required for
  71. next firmware-assisted dump registration.
  72. e.g.
  73. # echo 1 > /sys/kernel/fadump_release_mem
  74. Please note that the firmware-assisted dump feature
  75. is only available on Power6 and above systems with recent
  76. firmware versions.
  77. Implementation details:
  78. ----------------------
  79. During boot, a check is made to see if firmware supports
  80. this feature on that particular machine. If it does, then
  81. we check to see if an active dump is waiting for us. If yes
  82. then everything but boot memory size of RAM is reserved during
  83. early boot (See Fig. 2). This area is released once we finish
  84. collecting the dump from user land scripts (e.g. kdump scripts)
  85. that are run. If there is dump data, then the
  86. /sys/kernel/fadump_release_mem file is created, and the reserved
  87. memory is held.
  88. If there is no waiting dump data, then only the memory required
  89. to hold CPU state, HPTE region, boot memory dump and elfcore
  90. header, is reserved at the top of memory (see Fig. 1). This area
  91. is *not* released: this region will be kept permanently reserved,
  92. so that it can act as a receptacle for a copy of the boot memory
  93. content in addition to CPU state and HPTE region, in the case a
  94. crash does occur.
  95. o Memory Reservation during first kernel
  96. Low memory Top of memory
  97. 0 boot memory size |
  98. | | |<--Reserved dump area -->|
  99. V V | Permanent Reservation V
  100. +-----------+----------/ /----------+---+----+-----------+----+
  101. | | |CPU|HPTE| DUMP |ELF |
  102. +-----------+----------/ /----------+---+----+-----------+----+
  103. | ^
  104. | |
  105. \ /
  106. -------------------------------------------
  107. Boot memory content gets transferred to
  108. reserved area by firmware at the time of
  109. crash
  110. Fig. 1
  111. o Memory Reservation during second kernel after crash
  112. Low memory Top of memory
  113. 0 boot memory size |
  114. | |<------------- Reserved dump area ----------- -->|
  115. V V V
  116. +-----------+----------/ /----------+---+----+-----------+----+
  117. | | |CPU|HPTE| DUMP |ELF |
  118. +-----------+----------/ /----------+---+----+-----------+----+
  119. | |
  120. V V
  121. Used by second /proc/vmcore
  122. kernel to boot
  123. Fig. 2
  124. Currently the dump will be copied from /proc/vmcore to a
  125. a new file upon user intervention. The dump data available through
  126. /proc/vmcore will be in ELF format. Hence the existing kdump
  127. infrastructure (kdump scripts) to save the dump works fine with
  128. minor modifications.
  129. The tools to examine the dump will be same as the ones
  130. used for kdump.
  131. How to enable firmware-assisted dump (fadump):
  132. -------------------------------------
  133. 1. Set config option CONFIG_FA_DUMP=y and build kernel.
  134. 2. Boot into linux kernel with 'fadump=on' kernel cmdline option.
  135. 3. Optionally, user can also set 'fadump_reserve_mem=' kernel cmdline
  136. to specify size of the memory to reserve for boot memory dump
  137. preservation.
  138. NOTE: If firmware-assisted dump fails to reserve memory then it will
  139. fallback to existing kdump mechanism if 'crashkernel=' option
  140. is set at kernel cmdline.
  141. Sysfs/debugfs files:
  142. ------------
  143. Firmware-assisted dump feature uses sysfs file system to hold
  144. the control files and debugfs file to display memory reserved region.
  145. Here is the list of files under kernel sysfs:
  146. /sys/kernel/fadump_enabled
  147. This is used to display the fadump status.
  148. 0 = fadump is disabled
  149. 1 = fadump is enabled
  150. This interface can be used by kdump init scripts to identify if
  151. fadump is enabled in the kernel and act accordingly.
  152. /sys/kernel/fadump_registered
  153. This is used to display the fadump registration status as well
  154. as to control (start/stop) the fadump registration.
  155. 0 = fadump is not registered.
  156. 1 = fadump is registered and ready to handle system crash.
  157. To register fadump echo 1 > /sys/kernel/fadump_registered and
  158. echo 0 > /sys/kernel/fadump_registered for un-register and stop the
  159. fadump. Once the fadump is un-registered, the system crash will not
  160. be handled and vmcore will not be captured. This interface can be
  161. easily integrated with kdump service start/stop.
  162. /sys/kernel/fadump_release_mem
  163. This file is available only when fadump is active during
  164. second kernel. This is used to release the reserved memory
  165. region that are held for saving crash dump. To release the
  166. reserved memory echo 1 to it:
  167. echo 1 > /sys/kernel/fadump_release_mem
  168. After echo 1, the content of the /sys/kernel/debug/powerpc/fadump_region
  169. file will change to reflect the new memory reservations.
  170. The existing userspace tools (kdump infrastructure) can be easily
  171. enhanced to use this interface to release the memory reserved for
  172. dump and continue without 2nd reboot.
  173. Here is the list of files under powerpc debugfs:
  174. (Assuming debugfs is mounted on /sys/kernel/debug directory.)
  175. /sys/kernel/debug/powerpc/fadump_region
  176. This file shows the reserved memory regions if fadump is
  177. enabled otherwise this file is empty. The output format
  178. is:
  179. <region>: [<start>-<end>] <reserved-size> bytes, Dumped: <dump-size>
  180. e.g.
  181. Contents when fadump is registered during first kernel
  182. # cat /sys/kernel/debug/powerpc/fadump_region
  183. CPU : [0x0000006ffb0000-0x0000006fff001f] 0x40020 bytes, Dumped: 0x0
  184. HPTE: [0x0000006fff0020-0x0000006fff101f] 0x1000 bytes, Dumped: 0x0
  185. DUMP: [0x0000006fff1020-0x0000007fff101f] 0x10000000 bytes, Dumped: 0x0
  186. Contents when fadump is active during second kernel
  187. # cat /sys/kernel/debug/powerpc/fadump_region
  188. CPU : [0x0000006ffb0000-0x0000006fff001f] 0x40020 bytes, Dumped: 0x40020
  189. HPTE: [0x0000006fff0020-0x0000006fff101f] 0x1000 bytes, Dumped: 0x1000
  190. DUMP: [0x0000006fff1020-0x0000007fff101f] 0x10000000 bytes, Dumped: 0x10000000
  191. : [0x00000010000000-0x0000006ffaffff] 0x5ffb0000 bytes, Dumped: 0x5ffb0000
  192. NOTE: Please refer to Documentation/filesystems/debugfs.txt on
  193. how to mount the debugfs filesystem.
  194. TODO:
  195. -----
  196. o Need to come up with the better approach to find out more
  197. accurate boot memory size that is required for a kernel to
  198. boot successfully when booted with restricted memory.
  199. o The fadump implementation introduces a fadump crash info structure
  200. in the scratch area before the ELF core header. The idea of introducing
  201. this structure is to pass some important crash info data to the second
  202. kernel which will help second kernel to populate ELF core header with
  203. correct data before it gets exported through /proc/vmcore. The current
  204. design implementation does not address a possibility of introducing
  205. additional fields (in future) to this structure without affecting
  206. compatibility. Need to come up with the better approach to address this.
  207. The possible approaches are:
  208. 1. Introduce version field for version tracking, bump up the version
  209. whenever a new field is added to the structure in future. The version
  210. field can be used to find out what fields are valid for the current
  211. version of the structure.
  212. 2. Reserve the area of predefined size (say PAGE_SIZE) for this
  213. structure and have unused area as reserved (initialized to zero)
  214. for future field additions.
  215. The advantage of approach 1 over 2 is we don't need to reserve extra space.
  216. ---
  217. Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
  218. This document is based on the original documentation written for phyp
  219. assisted dump by Linas Vepstas and Manish Ahuja.