dock.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. This document is released under the Creative Commons Attribution-ShareAlike 4.0 International Public License and all future versions.
  123. A copy of the license can be found at <a href="../cc-by-sa-4.txt">../cc-by-sa-4.txt</a>.
  124. </p>
  125. <p>
  126. This document is distributed in the hope that it will be useful,
  127. but WITHOUT ANY WARRANTY; without even the implied warranty of
  128. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See <a href="../cc-by-sa-4.txt">../cc-by-sa-4.txt</a> for more information.
  129. </p>
  130. </div>
  131. </body>
  132. </html>