0036-nb-intel-haswell-make-IOMMU-a-runtime-option.patch 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. From 7c755b4502ea007f2216ea76f2ed734452def883 Mon Sep 17 00:00:00 2001
  2. From: Leah Rowe <info@minifree.org>
  3. Date: Sat, 2 Mar 2024 22:51:09 +0000
  4. Subject: [PATCH 1/2] nb/intel/haswell: make IOMMU a runtime option
  5. When I tested graphics cards on a coreboot port for Dell
  6. OptiPlex 9020 SFF, I could not use a graphics card unless
  7. I set iommu=off on the Linux cmdline.
  8. Coreboot's current behaviour is to check whether the CPU
  9. has vt-d support and, if it does, initialise the IOMMU.
  10. This patch maintains the current behaviour by default, but
  11. allows the user to turn *off* the IOMMU, even if vt-d is
  12. supported by the host CPU.
  13. If iommu=Disable is specified, the check will not be
  14. performed, and the IOMMU will be left disabled. This option
  15. has been added to all current Haswell boards, though it is
  16. recommended to leave the IOMMU turned on in most setups.
  17. Signed-off-by: Leah Rowe <info@minifree.org>
  18. ---
  19. src/mainboard/asrock/b85m_pro4/cmos.default | 1 +
  20. src/mainboard/asrock/b85m_pro4/cmos.layout | 3 +++
  21. src/mainboard/asrock/h81m-hds/cmos.default | 1 +
  22. src/mainboard/asrock/h81m-hds/cmos.layout | 6 ++++++
  23. src/mainboard/dell/optiplex_9020/cmos.default | 1 +
  24. src/mainboard/dell/optiplex_9020/cmos.layout | 6 ++++++
  25. src/mainboard/google/beltino/cmos.layout | 5 +++++
  26. src/mainboard/google/slippy/cmos.layout | 5 +++++
  27. src/mainboard/intel/baskingridge/cmos.layout | 4 ++++
  28. src/mainboard/lenovo/haswell/cmos.default | 1 +
  29. src/mainboard/lenovo/haswell/cmos.layout | 3 +++
  30. src/mainboard/supermicro/x10slm-f/cmos.default | 1 +
  31. src/mainboard/supermicro/x10slm-f/cmos.layout | 6 ++++++
  32. src/northbridge/intel/haswell/early_init.c | 5 +++++
  33. 14 files changed, 48 insertions(+)
  34. diff --git a/src/mainboard/asrock/b85m_pro4/cmos.default b/src/mainboard/asrock/b85m_pro4/cmos.default
  35. index c51001c03c..1c5c17f841 100644
  36. --- a/src/mainboard/asrock/b85m_pro4/cmos.default
  37. +++ b/src/mainboard/asrock/b85m_pro4/cmos.default
  38. @@ -2,3 +2,4 @@ boot_option=Fallback
  39. debug_level=Debug
  40. nmi=Enable
  41. power_on_after_fail=Disable
  42. +iommu=Enable
  43. diff --git a/src/mainboard/asrock/b85m_pro4/cmos.layout b/src/mainboard/asrock/b85m_pro4/cmos.layout
  44. index efdc333fc2..c9883ea71d 100644
  45. --- a/src/mainboard/asrock/b85m_pro4/cmos.layout
  46. +++ b/src/mainboard/asrock/b85m_pro4/cmos.layout
  47. @@ -11,6 +11,7 @@
  48. 395 4 e 4 debug_level
  49. 408 1 e 1 nmi
  50. 409 2 e 5 power_on_after_fail
  51. + 412 1 e 6 iommu
  52. 984 16 h 0 check_sum
  53. # -----------------------------------------------------------------
  54. @@ -38,6 +39,8 @@
  55. 5 0 Disable
  56. 5 1 Enable
  57. 5 2 Keep
  58. + 6 0 Disable
  59. + 6 1 Enable
  60. # -----------------------------------------------------------------
  61. # -----------------------------------------------------------------
  62. diff --git a/src/mainboard/asrock/h81m-hds/cmos.default b/src/mainboard/asrock/h81m-hds/cmos.default
  63. index c51001c03c..1c5c17f841 100644
  64. --- a/src/mainboard/asrock/h81m-hds/cmos.default
  65. +++ b/src/mainboard/asrock/h81m-hds/cmos.default
  66. @@ -2,3 +2,4 @@ boot_option=Fallback
  67. debug_level=Debug
  68. nmi=Enable
  69. power_on_after_fail=Disable
  70. +iommu=Enable
  71. diff --git a/src/mainboard/asrock/h81m-hds/cmos.layout b/src/mainboard/asrock/h81m-hds/cmos.layout
  72. index c9ba76c78f..95ee3d36fb 100644
  73. --- a/src/mainboard/asrock/h81m-hds/cmos.layout
  74. +++ b/src/mainboard/asrock/h81m-hds/cmos.layout
  75. @@ -21,6 +21,9 @@ entries
  76. 408 1 e 1 nmi
  77. 409 2 e 5 power_on_after_fail
  78. +# enable or disable iommu
  79. +412 1 e 6 iommu
  80. +
  81. # coreboot config options: check sums
  82. 984 16 h 0 check_sum
  83. @@ -52,6 +55,9 @@ enumerations
  84. 5 1 Enable
  85. 5 2 Keep
  86. +6 0 Disable
  87. +6 1 Enable
  88. +
  89. # -----------------------------------------------------------------
  90. checksums
  91. diff --git a/src/mainboard/dell/optiplex_9020/cmos.default b/src/mainboard/dell/optiplex_9020/cmos.default
  92. index b159660aa8..8253570f19 100644
  93. --- a/src/mainboard/dell/optiplex_9020/cmos.default
  94. +++ b/src/mainboard/dell/optiplex_9020/cmos.default
  95. @@ -2,3 +2,4 @@ boot_option=Fallback
  96. debug_level=Debug
  97. nmi=Disable
  98. power_on_after_fail=Disable
  99. +iommu=Enable
  100. diff --git a/src/mainboard/dell/optiplex_9020/cmos.layout b/src/mainboard/dell/optiplex_9020/cmos.layout
  101. index c9ba76c78f..72ff9c4bee 100644
  102. --- a/src/mainboard/dell/optiplex_9020/cmos.layout
  103. +++ b/src/mainboard/dell/optiplex_9020/cmos.layout
  104. @@ -21,6 +21,9 @@ entries
  105. 408 1 e 1 nmi
  106. 409 2 e 5 power_on_after_fail
  107. +# turn iommu on or off
  108. +412 1 e 6 iommu
  109. +
  110. # coreboot config options: check sums
  111. 984 16 h 0 check_sum
  112. @@ -52,6 +55,9 @@ enumerations
  113. 5 1 Enable
  114. 5 2 Keep
  115. +6 0 Disable
  116. +6 1 Enable
  117. +
  118. # -----------------------------------------------------------------
  119. checksums
  120. diff --git a/src/mainboard/google/beltino/cmos.layout b/src/mainboard/google/beltino/cmos.layout
  121. index 78d44c1415..c143979ae1 100644
  122. --- a/src/mainboard/google/beltino/cmos.layout
  123. +++ b/src/mainboard/google/beltino/cmos.layout
  124. @@ -19,6 +19,9 @@ entries
  125. 408 1 e 1 nmi
  126. 409 2 e 7 power_on_after_fail
  127. +# enable or disable iommu
  128. +412 1 e 8 iommu
  129. +
  130. # coreboot config options: bootloader
  131. #Used by ChromeOS:
  132. 416 128 r 0 vbnv
  133. @@ -47,6 +50,8 @@ enumerations
  134. 7 0 Disable
  135. 7 1 Enable
  136. 7 2 Keep
  137. +8 0 Disable
  138. +8 1 Enable
  139. # -----------------------------------------------------------------
  140. checksums
  141. diff --git a/src/mainboard/google/slippy/cmos.layout b/src/mainboard/google/slippy/cmos.layout
  142. index 78d44c1415..c143979ae1 100644
  143. --- a/src/mainboard/google/slippy/cmos.layout
  144. +++ b/src/mainboard/google/slippy/cmos.layout
  145. @@ -19,6 +19,9 @@ entries
  146. 408 1 e 1 nmi
  147. 409 2 e 7 power_on_after_fail
  148. +# enable or disable iommu
  149. +412 1 e 8 iommu
  150. +
  151. # coreboot config options: bootloader
  152. #Used by ChromeOS:
  153. 416 128 r 0 vbnv
  154. @@ -47,6 +50,8 @@ enumerations
  155. 7 0 Disable
  156. 7 1 Enable
  157. 7 2 Keep
  158. +8 0 Disable
  159. +8 1 Enable
  160. # -----------------------------------------------------------------
  161. checksums
  162. diff --git a/src/mainboard/intel/baskingridge/cmos.layout b/src/mainboard/intel/baskingridge/cmos.layout
  163. index 78d44c1415..f2c602f541 100644
  164. --- a/src/mainboard/intel/baskingridge/cmos.layout
  165. +++ b/src/mainboard/intel/baskingridge/cmos.layout
  166. @@ -19,6 +19,8 @@ entries
  167. 408 1 e 1 nmi
  168. 409 2 e 7 power_on_after_fail
  169. +412 1 e 8 iommu
  170. +
  171. # coreboot config options: bootloader
  172. #Used by ChromeOS:
  173. 416 128 r 0 vbnv
  174. @@ -47,6 +49,8 @@ enumerations
  175. 7 0 Disable
  176. 7 1 Enable
  177. 7 2 Keep
  178. +8 0 Disable
  179. +8 1 Enable
  180. # -----------------------------------------------------------------
  181. checksums
  182. diff --git a/src/mainboard/lenovo/haswell/cmos.default b/src/mainboard/lenovo/haswell/cmos.default
  183. index bb8626d48b..051658d757 100644
  184. --- a/src/mainboard/lenovo/haswell/cmos.default
  185. +++ b/src/mainboard/lenovo/haswell/cmos.default
  186. @@ -12,3 +12,4 @@ trackpoint=Enable
  187. backlight=Keyboard
  188. enable_dual_graphics=Disable
  189. usb_always_on=Disable
  190. +iommu=Enable
  191. diff --git a/src/mainboard/lenovo/haswell/cmos.layout b/src/mainboard/lenovo/haswell/cmos.layout
  192. index 27915d3ab7..59df76b64c 100644
  193. --- a/src/mainboard/lenovo/haswell/cmos.layout
  194. +++ b/src/mainboard/lenovo/haswell/cmos.layout
  195. @@ -23,6 +23,7 @@ entries
  196. # coreboot config options: EC
  197. 411 1 e 8 first_battery
  198. +413 1 e 14 iommu
  199. 415 1 e 1 wlan
  200. 416 1 e 1 trackpoint
  201. 417 1 e 1 fn_ctrl_swap
  202. @@ -72,6 +73,8 @@ enumerations
  203. 13 0 Disable
  204. 13 1 AC and battery
  205. 13 2 AC only
  206. +14 0 Disable
  207. +14 1 Enable
  208. # -----------------------------------------------------------------
  209. checksums
  210. diff --git a/src/mainboard/supermicro/x10slm-f/cmos.default b/src/mainboard/supermicro/x10slm-f/cmos.default
  211. index f4047147f7..eea2c36b88 100644
  212. --- a/src/mainboard/supermicro/x10slm-f/cmos.default
  213. +++ b/src/mainboard/supermicro/x10slm-f/cmos.default
  214. @@ -3,3 +3,4 @@ debug_level=Debug
  215. nmi=Enable
  216. power_on_after_fail=Keep
  217. hide_ast2400=Disable
  218. +iommu=Enable
  219. diff --git a/src/mainboard/supermicro/x10slm-f/cmos.layout b/src/mainboard/supermicro/x10slm-f/cmos.layout
  220. index 38ba87aa45..24d39e97ee 100644
  221. --- a/src/mainboard/supermicro/x10slm-f/cmos.layout
  222. +++ b/src/mainboard/supermicro/x10slm-f/cmos.layout
  223. @@ -21,6 +21,9 @@ entries
  224. 408 1 e 1 nmi
  225. 409 2 e 5 power_on_after_fail
  226. +# enable or disable iommu
  227. +412 1 e 6 iommu
  228. +
  229. # coreboot config options: mainboard
  230. 416 1 e 1 hide_ast2400
  231. @@ -55,6 +58,9 @@ enumerations
  232. 5 1 Enable
  233. 5 2 Keep
  234. +6 0 Disable
  235. +6 1 Enable
  236. +
  237. # -----------------------------------------------------------------
  238. checksums
  239. diff --git a/src/northbridge/intel/haswell/early_init.c b/src/northbridge/intel/haswell/early_init.c
  240. index e47deb5da6..1a7e0b1076 100644
  241. --- a/src/northbridge/intel/haswell/early_init.c
  242. +++ b/src/northbridge/intel/haswell/early_init.c
  243. @@ -5,6 +5,7 @@
  244. #include <device/mmio.h>
  245. #include <device/pci_def.h>
  246. #include <device/pci_ops.h>
  247. +#include <option.h>
  248. #include "haswell.h"
  249. @@ -157,6 +158,10 @@ static void haswell_setup_misc(void)
  250. static void haswell_setup_iommu(void)
  251. {
  252. const u32 capid0_a = pci_read_config32(HOST_BRIDGE, CAPID0_A);
  253. + u8 enable_iommu = get_uint_option("iommu", 1);
  254. +
  255. + if (!enable_iommu)
  256. + return;
  257. if (capid0_a & VTD_DISABLE)
  258. return;
  259. --
  260. 2.39.2