debugging-via-ohci1394.txt 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. Using physical DMA provided by OHCI-1394 FireWire controllers for debugging
  2. ---------------------------------------------------------------------------
  3. Introduction
  4. ------------
  5. Basically all FireWire controllers which are in use today are compliant
  6. to the OHCI-1394 specification which defines the controller to be a PCI
  7. bus master which uses DMA to offload data transfers from the CPU and has
  8. a "Physical Response Unit" which executes specific requests by employing
  9. PCI-Bus master DMA after applying filters defined by the OHCI-1394 driver.
  10. Once properly configured, remote machines can send these requests to
  11. ask the OHCI-1394 controller to perform read and write requests on
  12. physical system memory and, for read requests, send the result of
  13. the physical memory read back to the requester.
  14. With that, it is possible to debug issues by reading interesting memory
  15. locations such as buffers like the printk buffer or the process table.
  16. Retrieving a full system memory dump is also possible over the FireWire,
  17. using data transfer rates in the order of 10MB/s or more.
  18. Memory access is currently limited to the low 4G of physical address
  19. space which can be a problem on IA64 machines where memory is located
  20. mostly above that limit, but it is rarely a problem on more common
  21. hardware such as hardware based on x86, x86-64 and PowerPC.
  22. Together with a early initialization of the OHCI-1394 controller for debugging,
  23. this facility proved most useful for examining long debugs logs in the printk
  24. buffer on to debug early boot problems in areas like ACPI where the system
  25. fails to boot and other means for debugging (serial port) are either not
  26. available (notebooks) or too slow for extensive debug information (like ACPI).
  27. Drivers
  28. -------
  29. The OHCI-1394 drivers in drivers/firewire and drivers/ieee1394 initialize
  30. the OHCI-1394 controllers to a working state and can be used to enable
  31. physical DMA. By default you only have to load the driver, and physical
  32. DMA access will be granted to all remote nodes, but it can be turned off
  33. when using the ohci1394 driver.
  34. Because these drivers depend on the PCI enumeration to be completed, an
  35. initialization routine which can runs pretty early (long before console_init(),
  36. which makes the printk buffer appear on the console can be called) was written.
  37. To activate it, enable CONFIG_PROVIDE_OHCI1394_DMA_INIT (Kernel hacking menu:
  38. Provide code for enabling DMA over FireWire early on boot) and pass the
  39. parameter "ohci1394_dma=early" to the recompiled kernel on boot.
  40. Tools
  41. -----
  42. firescope - Originally developed by Benjamin Herrenschmidt, Andi Kleen ported
  43. it from PowerPC to x86 and x86_64 and added functionality, firescope can now
  44. be used to view the printk buffer of a remote machine, even with live update.
  45. Bernhard Kaindl enhanced firescope to support accessing 64-bit machines
  46. from 32-bit firescope and vice versa:
  47. - ftp://ftp.suse.de/private/bk/firewire/tools/firescope-0.2.2.tar.bz2
  48. and he implemented fast system dump (alpha version - read README.txt):
  49. - ftp://ftp.suse.de/private/bk/firewire/tools/firedump-0.1.tar.bz2
  50. There is also a gdb proxy for firewire which allows to use gdb to access
  51. data which can be referenced from symbols found by gdb in vmlinux:
  52. - ftp://ftp.suse.de/private/bk/firewire/tools/fireproxy-0.33.tar.bz2
  53. The latest version of this gdb proxy (fireproxy-0.34) can communicate (not
  54. yet stable) with kgdb over an memory-based communication module (kgdbom).
  55. Getting Started
  56. ---------------
  57. The OHCI-1394 specification regulates that the OHCI-1394 controller must
  58. disable all physical DMA on each bus reset.
  59. This means that if you want to debug an issue in a system state where
  60. interrupts are disabled and where no polling of the OHCI-1394 controller
  61. for bus resets takes place, you have to establish any FireWire cable
  62. connections and fully initialize all FireWire hardware __before__ the
  63. system enters such state.
  64. Step-by-step instructions for using firescope with early OHCI initialization:
  65. 1) Verify that your hardware is supported:
  66. Load the ohci1394 or the fw-ohci module and check your kernel logs.
  67. You should see a line similar to
  68. ohci1394: fw-host0: OHCI-1394 1.1 (PCI): IRQ=[18] MMIO=[fe9ff800-fe9fffff]
  69. ... Max Packet=[2048] IR/IT contexts=[4/8]
  70. when loading the driver. If you have no supported controller, many PCI,
  71. CardBus and even some Express cards which are fully compliant to OHCI-1394
  72. specification are available. If it requires no driver for Windows operating
  73. systems, it most likely is. Only specialized shops have cards which are not
  74. compliant, they are based on TI PCILynx chips and require drivers for Win-
  75. dows operating systems.
  76. 2) Establish a working FireWire cable connection:
  77. Any FireWire cable, as long at it provides electrically and mechanically
  78. stable connection and has matching connectors (there are small 4-pin and
  79. large 6-pin FireWire ports) will do.
  80. If an driver is running on both machines you should see a line like
  81. ieee1394: Node added: ID:BUS[0-01:1023] GUID[0090270001b84bba]
  82. on both machines in the kernel log when the cable is plugged in
  83. and connects the two machines.
  84. 3) Test physical DMA using firescope:
  85. On the debug host,
  86. - load the raw1394 module,
  87. - make sure that /dev/raw1394 is accessible,
  88. then start firescope:
  89. $ firescope
  90. Port 0 (ohci1394) opened, 2 nodes detected
  91. FireScope
  92. ---------
  93. Target : <unspecified>
  94. Gen : 1
  95. [Ctrl-T] choose target
  96. [Ctrl-H] this menu
  97. [Ctrl-Q] quit
  98. ------> Press Ctrl-T now, the output should be similar to:
  99. 2 nodes available, local node is: 0
  100. 0: ffc0, uuid: 00000000 00000000 [LOCAL]
  101. 1: ffc1, uuid: 00279000 ba4bb801
  102. Besides the [LOCAL] node, it must show another node without error message.
  103. 4) Prepare for debugging with early OHCI-1394 initialization:
  104. 4.1) Kernel compilation and installation on debug target
  105. Compile the kernel to be debugged with CONFIG_PROVIDE_OHCI1394_DMA_INIT
  106. (Kernel hacking: Provide code for enabling DMA over FireWire early on boot)
  107. enabled and install it on the machine to be debugged (debug target).
  108. 4.2) Transfer the System.map of the debugged kernel to the debug host
  109. Copy the System.map of the kernel be debugged to the debug host (the host
  110. which is connected to the debugged machine over the FireWire cable).
  111. 5) Retrieving the printk buffer contents:
  112. With the FireWire cable connected, the OHCI-1394 driver on the debugging
  113. host loaded, reboot the debugged machine, booting the kernel which has
  114. CONFIG_PROVIDE_OHCI1394_DMA_INIT enabled, with the option ohci1394_dma=early.
  115. Then, on the debugging host, run firescope, for example by using -A:
  116. firescope -A System.map-of-debug-target-kernel
  117. Note: -A automatically attaches to the first non-local node. It only works
  118. reliably if only connected two machines are connected using FireWire.
  119. After having attached to the debug target, press Ctrl-D to view the
  120. complete printk buffer or Ctrl-U to enter auto update mode and get an
  121. updated live view of recent kernel messages logged on the debug target.
  122. Call "firescope -h" to get more information on firescope's options.
  123. Notes
  124. -----
  125. Documentation and specifications: ftp://ftp.suse.de/private/bk/firewire/docs
  126. FireWire is a trademark of Apple Inc. - for more information please refer to:
  127. http://en.wikipedia.org/wiki/FireWire