dock.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <style type="text/css">
  7. @import url('../css/main.css');
  8. </style>
  9. <title>Notes about DMA and the docking station (X60/T60)</title>
  10. </head>
  11. <body>
  12. <div class="section">
  13. <h1>Notes about DMA and the docking station (X60/T60)</h1>
  14. </div>
  15. <div class="section">
  16. <pre>
  17. Use case:
  18. ---------
  19. Usually when people do full disk encryption, it's not really full disk,
  20. instead they still have a /boot in clear.
  21. So an evil maid attack can still be done, in two passes:
  22. 1) Clone the hdd, Infect the initramfs or the kernel.
  23. 2) Wait for the user to enter its password, recover the password,
  24. luksOpen the hdd image.
  25. I wanted a real full-disk encryption so I've put grub in flash and I
  26. have the following: The HDD has a LUKS rootfs(containing /boot) on an
  27. lvm partition, so no partition is in clear.
  28. So when the computer boots it executes coreboot, then grub as a payload.
  29. Grub then opens the LUKS partition and loads the kernel and initramfs
  30. from there.
  31. To prevent hardware level tempering(like reflashing), I used nail
  32. polish with a lot of gilder, that acts like a seal. Then a high
  33. resolution picture of it is taken, to be able to tell the difference.
  34. The problem:
  35. ------------
  36. But then comes the docking port issue: Some LPC pins are exported
  37. there, such as the CLKRUN and LDRQ#.
  38. LDRQ# is "Encoded DMA/Bus Master Request": "Only needed by
  39. peripherals that need DMA or bus mastering. Requires an
  40. individual signal per peripheral. Peripherals may not share
  41. an LDRQ# signal."
  42. So now DMA access is possible trough the dock connector.
  43. So I want to be able to turn that off.
  44. If I got it right, the X60 has 2 superio, one is in the dock, and the
  45. other one is in the laptop, so we have:
  46. ________________
  47. _________________ | |
  48. | | | Dock connector:|
  49. |Dock: NSC pc87982|&lt;--LPC---&gt;D_LPC_DREQ0 |
  50. |_________________| |_______^________|
  51. |
  52. |
  53. |
  54. |
  55. ___________________|____
  56. | v |
  57. | SuperIO: DLDRQ# |
  58. | NSC pc87382 LDRQ# |
  59. |___________________^____|
  60. |
  61. |
  62. |
  63. |
  64. ___________________|___
  65. | v |
  66. | Southbridge: LDRQ0 |
  67. | ICH7 |
  68. |_______________________|
  69. The code:
  70. ---------
  71. Now if I look at the existing code, there is some superio drivers, like
  72. pc87382 in src/superio/nsc, the code is very small.
  73. The only interesting part is the pnp_info pnp_dev_info struct.
  74. Now if I look inside src/mainboard/lenovo/x60 there is some more
  75. complete dock driver:
  76. Inside dock.c I see some dock_connect and dock_disconnect functions.
  77. Such functions are called during the initialisation (romstage.c) and
  78. from the X60 SMI handler (smihandler.c).
  79. Questions:
  80. ----------
  81. 1) Would the following be sufficent to prevent DMA access from the
  82. outside:
  83. &gt; int dock_connect(void)
  84. &gt; {
  85. &gt; int timeout = 1000;
  86. &gt; + int val;
  87. &gt; +
  88. &gt; + if (get_option(&amp;val, &quot;dock&quot;) != CB_SUCCESS)
  89. &gt; + val = 1;
  90. &gt; + if (val == 0)
  91. &gt; + return 0;
  92. &gt; [...]
  93. &gt; }
  94. >
  95. &gt; void dock_disconnect(void) {
  96. &gt; + if (dock_present())
  97. &gt; + return;
  98. &gt; [...]
  99. &gt; }
  100. 2) Would an nvram option be ok for that? Should a Kconfig option be
  101. added too?
  102. &gt; config DOCK_AUTODETECT
  103. &gt; bool "Autodetect"
  104. &gt; help
  105. &gt; The dock is autodetected. If unsure select this option.
  106. >
  107. &gt; config DOCK_DISABLED
  108. &gt; bool "Disabled"
  109. &gt; help
  110. &gt; The dock is always disabled.
  111. >
  112. &gt; config DOCK_NVRAM_ENABLE
  113. &gt; bool "Nvram"
  114. &gt; help
  115. &gt; The dock autodetection is tried only if it is also enabled
  116. &gt; trough nvram.
  117. </pre>
  118. </div>
  119. <div class="section">
  120. <p>
  121. Copyright &copy; 2014, 2015 Francis Rowe &lt;info@gluglug.org.uk&gt;<br/>
  122. Permission is granted to copy, distribute and/or modify this document
  123. under the terms of the GNU Free Documentation License, Version 1.3
  124. or any later version published by the Free Software Foundation;
  125. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
  126. A copy of the license can be found at <a href="../gfdl-1.3.txt">../gfdl-1.3.txt</a>
  127. </p>
  128. <p>
  129. Updated versions of the license (when available) can be found at
  130. <a href="https://www.gnu.org/licenses/licenses.html">https://www.gnu.org/licenses/licenses.html</a>
  131. </p>
  132. <p>
  133. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
  134. EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
  135. AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
  136. ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
  137. IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
  138. WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
  139. PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
  140. ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
  141. KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
  142. ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
  143. </p>
  144. <p>
  145. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
  146. TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
  147. NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
  148. INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
  149. COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
  150. USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
  151. ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
  152. DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
  153. IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
  154. </p>
  155. <p>
  156. The disclaimer of warranties and limitation of liability provided
  157. above shall be interpreted in a manner that, to the extent
  158. possible, most closely approximates an absolute disclaimer and
  159. waiver of all liability.
  160. </p>
  161. </div>
  162. </body>
  163. </html>